:root {
    /* Color Palette - Modern & Premium */
    --primary: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    
    --secondary: #64748b; /* Slate 500 */
    --accent: #0ea5e9; /* Sky 500 */
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-heading {
    font-family: 'Outfit', sans-serif;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-fade { animation: fadeIn 0.4s ease-out forwards; }
.animate-slide { animation: slideIn 0.3s ease-out forwards; }

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

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: 0;
    padding: 1.5rem 0;
    overflow: hidden;
    transform: translateX(-100%);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar:not(.collapsed) {
        transform: translateX(0);
        width: 280px;
    }
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.3);
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 0.5rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: var(--transition);
}

.nav-group-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-group-header.active {
    color: white;
}

.submenu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1rem;
    margin-top: 0.25rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-out;
}

.nav-group.expanded .submenu {
    max-height: 500px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    left: 1rem;
    top: 1rem;
    z-index: 100;
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background-color: var(--bg-main);
}

.sidebar:not(.collapsed) + .main-content .sidebar-toggle {
    left: 290px;
}

@media (max-width: 768px) {
    .sidebar:not(.collapsed) ~ .sidebar-toggle, 
    .sidebar:not(.collapsed) + .main-content .sidebar-toggle {
        left: 230px; /* Overlap slightly on small screens */
        z-index: 110;
    }
}

/* Sidebar User Info */
.sidebar-user {
    padding: 1rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.8rem;
}

.user-details {
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-role-badge {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
}

/* Password Toggle Styling */
.password-field-container {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    transition: var(--transition);
}

.password-toggle-btn:hover {
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
    transition: var(--transition);
    position: relative;
    max-width: 100vw;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .main-content {
        padding: 4rem 1rem 1rem 1rem; /* Space for the fixed toggle button */
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-top: 0.5rem;
}

/* Login Screen - User List */
.user-list {
    margin-top: 1.5rem;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.user-item:last-child {
    border-bottom: none;
}

.user-item:hover {
    background-color: var(--primary-light);
}

.user-item .name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-item .role {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Cards & Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px border var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-main);
}

/* Inputs */
.form-group {
    margin-bottom: 0.75rem;
}

.label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    transition: var(--transition);
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    overflow-y: auto;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 800px;
    position: relative;
    box-shadow: var(--shadow-lg);
    margin: auto;
    max-height: 85vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal-content {
        max-height: 95vh;
        border-radius: var(--radius-md);
    }
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #f8fafc;
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

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

/* Initial Loader */
.initial-loader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- PRINT MEDIA QUERIES --- */
@media print {
    body * {
        visibility: hidden;
    }
    .print-area, .print-area * {
        visibility: visible;
    }
    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100vw;
        box-shadow: none !important;
        background: white !important;
        margin: 0;
        padding: 0;
    }
    .modal-overlay {
        position: absolute !important;
        background: transparent !important;
        padding: 0 !important;
        align-items: flex-start !important;
    }
    .modal-content {
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .hide-on-print {
        display: none !important;
    }
    .print-no-bg {
        background: white !important;
        padding: 0 !important;
    }
    .print-p-0 {
        padding: 0 !important;
    }
    .print-bg-transparent {
        background-color: transparent !important;
    }
    .print-border-b {
        border: none !important;
        border-bottom: 2px solid #e2e8f0 !important;
    }
    table {
        border-collapse: collapse !important;
        width: 100% !important;
        page-break-inside: auto;
    }
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    th, td {
        border: 1px solid #cbd5e1 !important;
        padding: 0.5rem !important;
    }
    @page {
        margin: 1.5cm;
    }
}
