:root {
    --primary: #38bdf8;
    --primary-dark: #2c5ba1;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --success: #10b981;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Logic */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Login Page */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?q=80&w=2070&auto=format&fit=crop') no-repeat center center fixed;
    background-size: cover;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    /* Overlay */
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 2rem;
    margin-bottom: 5px;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #0f172a;
}

.btn-primary:hover {
    background: #60a5fa;
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

.alert-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--glass-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* Nav */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link.active {
    border-left: 3px solid var(--primary);
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(148, 185, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 1.8rem;
    margin-bottom: 2px;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Dark Mode Calendar Icon Fix */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* =========================================
   Mobile Responsiveness
   ========================================= */

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.btn-menu {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        /* Hide off-screen */
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
        overflow-y: auto; 
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        padding: 15px;
    }

    /* Responsive Tables */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: 8px;
        border: 1px solid var(--glass-border);
    }

    table {
        min-width: 600px;
        /* Force scroll for small screens */
    }

    /* Stack Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        /* Single column */
    }

    /* Adjust Forms */
    .form-group label {
        font-size: 0.95rem;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 14px;
    }

    /* Adjust Buttons */
    .btn {
        width: 100%;
        margin-bottom: 10px;
        justify-content: center;
    }

    .btn-sm {
        width: auto;
        display: inline-flex;
        margin-bottom: 0;
    }
}

/* =========================================
   Standardized Icon Buttons (2x Bigger)
   ========================================= */
.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s;
    font-size: 1.35rem;
    /* ~22px icon */
    color: var(--primary);
    background: rgba(59, 130, 246, 0.15);
    /* Blue tint */
    border: none;
    cursor: pointer;
    text-decoration: none;
    margin-right: 5px;
}

.btn-icon:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-3px);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Danger Variant (Delete) */
.btn-icon.danger {
    color: #ef4444;
    /* Red-500 */
    background: rgba(239, 68, 68, 0.15);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Warning/Edit Variant */
.btn-icon.warning {
    color: #f59e0b;
    /* Amber */
    background: rgba(245, 158, 11, 0.15);
}

.btn-icon.warning:hover {
    background: rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

/* Secondary/View Variant */
.btn-icon.secondary {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

.btn-icon.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* =========================================
   Sortable Headers
   ========================================= */
.sortable-header {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

.sortable-header:hover {
    opacity: 0.9;
}

/* Icon (always present but dim unless hovered/active) */
.sortable-header i.bx-sort-alt-2 {
    font-size: 1em;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.sortable-header:hover i.bx-sort-alt-2,
.sortable-header.active i.bx-sort-alt-2 {
    opacity: 1;
}

/* When sorted, show directional icon clearly */
.sortable-header.active i.bx-sort-down,
.sortable-header.active i.bx-sort-up {
    opacity: 1;
    color: var(--primary);
}

/* =========================================
   Responsive Grid Utilities
   ========================================= */
.grid-cols-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-cols-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {

    .grid-cols-2,
    .grid-cols-2-1 {
        grid-template-columns: 1fr !important;
        /* Stack vertically */
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .main-content header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .main-content header>div:last-child {
        text-align: left !important;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: rgba(255, 255, 255, 0.05);
        padding: 10px;
        border-radius: 8px;
    }
}

/* Helper for clickable cards */
.stretched-link::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    content: "";
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    body {
        background: white;
        color: black;
    }

    .sidebar,
    .mobile-header,
    .no-print {
        display: none !important;
    }

    .dashboard-layout {
        display: block;
    }

    .main-content {
        padding: 0;
        margin: 0;
        overflow: visible;
    }

    .glass-card {
        background: white;
        border: 1px solid #ddd;
        box-shadow: none;
        color: black;
    }

    /* Reset text colors for print */
    h1,
    h2,
    h3,
    p,
    td,
    th {
        color: black !important;
    }

    .table {
        border-collapse: collapse;
        width: 100%;
    }

    .table th,
    .table td {
        border: 1px solid #ddd;
    }

    /* Ensure print-only elements are shown */
    .print-only {
        display: block !important;
    }

    /* Expand text/audit areas */
    .audit-container {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Hide print-only elements on screen */
.print-only {
    display: none;
}