/* DocManager Professional Enterprise Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A; /* Slate 900 */
    --border-glass: #E2E8F0; /* Slate 200 */
    --border-active: #94A3B8; /* Slate 400 */
    
    --primary: #3B82F6; /* Blue 500 */
    --primary-hover: #2563EB; /* Blue 600 */
    --primary-light: #EFF6FF; /* Blue 50 */
    
    --success: #10B981; /* Emerald 500 */
    --warning: #F59E0B; /* Amber 500 */
    --danger: #EF4444; /* Red 500 */
    --text-primary: #1E293B; /* Slate 800 */
    --text-secondary: #64748B; /* Slate 500 */
    --text-muted: #94A3B8; /* Slate 400 */
    
    --sidebar-text: #F8FAFC;
    --sidebar-text-muted: #94A3B8;
    
    --font-body: 'Inter', sans-serif;
    --font-heading: 'Inter', sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    justify-content: space-between;
}

.sidebar-header .brand {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.sidebar-tab-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 24px 16px;
}

.sidebar-tab-nav-item, .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-muted);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-tab-nav-item:hover, .sidebar-nav-item:hover, .sidebar-tab-nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
}

.sidebar-tab-nav-item.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-main);
}

.app-header {
    height: 70px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.header-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.app-content {
    flex: 1;
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.mobile-menu-btn, .mobile-close-btn {
    display: none;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 5px;
}

@media(max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }
    
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }
    
    .mobile-menu-btn {
        display: block;
        color: var(--text-primary);
    }
    
    .mobile-close-btn {
        display: block;
        color: var(--sidebar-text);
    }

    .app-content {
        padding: 20px 16px;
    }

    .app-header {
        padding: 0 16px;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #F8FAFC;
    border-color: var(--border-active);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: #FFFFFF;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.doc-table th, .doc-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
    font-size: 14px;
}

.doc-table th {
    background: #F8FAFC;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.doc-table tr:last-child td {
    border-bottom: none;
}

.doc-table tbody tr {
    transition: var(--transition);
}

.doc-table tbody tr:hover {
    background: #F1F5F9;
}

/* Badges */
.doc-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.badge-active {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-expired {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-noexpiry {
    background: #F1F5F9;
    color: #475569;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #34D399;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #F87171;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FBBF24;
}


/* Filtering & Utilities */
.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .filter-bar > div {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .filter-bar select {
        width: 100% !important;
    }
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-input-search {
    padding-left: 36px;
}

/* Add Category Toggle Sections */
.category-view {
    display: block;
}
.category-form {
    display: none;
}



/* Mobile Responsive Tables */
@media (max-width: 768px) {
    .doc-table, .doc-table tbody, .doc-table tr, .doc-table td {
        display: block;
        width: 100%;
    }
    .doc-table {
        min-width: 0 !important;
    }
    .doc-table thead {
        display: none;
    }
    .doc-table tr {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center; /* align top row items */
        border: 1px solid var(--border-glass);
        border-radius: var(--radius-sm);
        margin-bottom: 12px;
        background: #fff;
        padding: 12px 16px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        position: relative;
        cursor: pointer;
        transition: background 0.2s;
        padding-right: 40px; /* leave space for chevron */
    }
    .doc-table tr:hover {
        background: #f8fafc;
    }
    
    /* Chevron for expand/collapse */
    .doc-table tr::after {
        content: '';
        position: absolute;
        top: 20px;
        right: 16px;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--text-muted);
        border-bottom: 2px solid var(--text-muted);
        transform: rotate(45deg);
        transition: transform 0.2s;
    }
    .doc-table tr.expanded::after {
        transform: rotate(-135deg);
        top: 24px;
    }

    /* Hide internal rows by default */
    .doc-table td {
        text-align: left !important;
        padding: 0;
        border: none;
        display: none; /* hidden by default */
    }
    
    /* Top Row: Name */
    .doc-table td:first-child {
        display: block;
        flex: 1 1 0%;
        min-width: 0; /* allow truncation */
        padding-right: 8px;
    }
    .doc-table td:first-child::before {
        display: block;
        margin-bottom: 2px;
    }
    
    /* Top Row: Badges */
    #section-docs .doc-table td:nth-child(3),
    #section-cats .doc-table td:nth-child(2) {
        display: block;
        flex: 0 0 auto;
        order: 2; /* after name */
        position: static !important;
        width: auto !important;
        margin-right: 8px; /* space before actions */
    }
    #section-docs .doc-table td:nth-child(3)::before,
    #section-cats .doc-table td:nth-child(2)::before {
        display: none !important;
    }
    #section-docs .doc-table td:nth-child(3) span.doc-badge {
        font-size: 10px;
        padding: 4px 6px;
    }
    #section-docs .doc-table td:nth-child(3) div > span:last-child {
        display: none;
    }

    /* Top Row: Actions */
    .doc-table td:last-child {
        display: flex !important;
        flex: 0 0 auto;
        order: 3; /* after badges */
        position: static !important;
        width: auto !important;
        border: none;
        padding: 0;
        margin: 0;
        background: transparent;
    }
    .doc-table td:last-child > div {
        display: flex;
        gap: 6px !important;
    }
    .doc-table td:last-child::before {
        display: none !important;
    }
    
    /* Hide hidden actions when collapsed */
    .doc-table td:last-child .action-hidden {
        display: none;
    }

    /* --- Expanded State --- */
    .doc-table tr.expanded td {
        display: block;
        flex: 0 0 100%;
        order: 10;
        padding: 8px 0;
    }
    .doc-table tr.expanded td:first-child {
        flex: 0 0 100%;
        border-bottom: 1px solid var(--border-glass);
        margin-bottom: 8px;
        padding-bottom: 12px;
    }

    /* Badges Expanded */
    #section-docs .doc-table tr.expanded td:nth-child(3),
    #section-cats .doc-table tr.expanded td:nth-child(2) {
        margin-right: 0;
    }
    #section-docs .doc-table tr.expanded td:nth-child(3)::before,
    #section-cats .doc-table tr.expanded td:nth-child(2)::before {
        display: block !important;
    }
    #section-docs .doc-table tr.expanded td:nth-child(3) div > span:last-child {
        display: block;
    }

    /* Actions Expanded */
    .doc-table tr.expanded td:last-child {
        order: 99;
        margin-top: 12px;
        padding-top: 12px !important;
        border-top: 1px solid var(--border-glass) !important;
        justify-content: flex-end;
    }
    .doc-table tr.expanded td:last-child > div {
        gap: 8px !important;
    }
    .doc-table tr.expanded td:last-child .action-hidden {
        display: inline-block;
    }
    .doc-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 4px;
        font-weight: 600;
        letter-spacing: 0.5px;
    }
    .table-responsive {
        border: none;
        background: transparent;
    }
}

/* Auth Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 70px);
    padding: 40px 20px;
    background: var(--bg-body);
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 40px;
    background: #FFF;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

/* Base structural classes (used in auth, admin, index) */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.navbar .brand {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-primary);
}

header {
    background: #FFF;
    border-bottom: 1px solid var(--border-glass);
}

/* Feature Grids & Admin */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.admin-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table-wrapper th, .admin-table-wrapper td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
}
.admin-table-wrapper th {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Responsive Header */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-links {
        display: none; /* hidden by default on mobile */
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-glass);
        padding: 24px;
        gap: 16px;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
    }
    
    .nav-links.show {
        display: flex;
        animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
    
    .nav-links .nav-link {
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px solid rgba(0,0,0,0.02);
    }
    
    .nav-links .btn {
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 12px;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

