/* ─── Dashboard Layout ───────────────────────────── */
.dashboard {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    height: 100%;
    background: transparent;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar.glass-panel {
    background: var(--sidebar-bg);
    border: none;
    border-right: 1px solid var(--sidebar-border);
    border-radius: 20px 0 0 20px;
    color: var(--sidebar-text);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: none;
    overflow-y: auto;
}

.sidebar .text-muted { color: rgba(199,210,254,0.5) !important; }
.sidebar h3 { color: #fff; font-size: 1rem; font-weight: 700; }

/* ─── Sidebar Logo Area ──────────────────────────── */
.sidebar-logo-area {
    text-align: center;
    padding: 8px 0 20px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 12px;
}

/* ─── User Profile ───────────────────────────────── */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    margin-bottom: 16px;
}

.avatar {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ─── Sidebar Brand ──────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 16px;
}

.sidebar-brand-icon {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.sidebar-brand-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
}

.sidebar-brand-name span {
    color: #818cf8;
}

/* ─── Navigation Items ───────────────────────────── */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--sidebar-text);
    opacity: 0.7;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    gap: 12px;
    user-select: none;
}

.nav-item i {
    width: 20px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    opacity: 1;
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    opacity: 1;
    box-shadow: 0 4px 14px rgba(99,102,241,0.4);
    font-weight: 600;
}

/* ─── Logout ─────────────────────────────────────── */
#logout-btn {
    margin-top: auto;
    color: #fca5a5;
    opacity: 0.8;
    background: transparent;
}
#logout-btn:hover {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    opacity: 1;
}

/* ─── Main Content ───────────────────────────────── */
.main-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 28px;
    background: var(--bg);
    border-radius: 0 20px 20px 0;
}

.main-content::-webkit-scrollbar { width: 5px; }
.main-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ─── Top Bar ────────────────────────────────────── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.topbar h2 { font-size: 1.4rem; letter-spacing: -0.025em; }

/* ─── Dashboard Stat Cards Grid ─────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 4px 4px 0 0;
}
.stat-card:nth-child(1)::after { background: var(--primary); }
.stat-card:nth-child(2)::after { background: var(--success); }
.stat-card:nth-child(3)::after { background: var(--danger); }
.stat-card:nth-child(4)::after { background: var(--warning); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-blue { background: #eef2ff; color: var(--primary); }
.stat-green { background: #ecfdf5; color: var(--success); }
.stat-red { background: #fef2f2; color: var(--danger); }
.stat-orange { background: #fffbeb; color: var(--warning); }

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 0 2px;
    letter-spacing: -0.03em;
    color: var(--text);
}
.stat-info p {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── Data Tables ────────────────────────────────── */
.table-container {
    overflow-x: auto;
    margin-top: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

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

th {
    padding: 11px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 13px 16px;
    color: var(--text);
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ─── Badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-present { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.badge-absent  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-pending { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

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

.view-section { display: none; animation: fadeIn 0.3s ease-out; }
.view-section.active { display: block; }

/* ─── 900px breakdown ────────────────────────────── */
@media (max-width: 900px) {
    .dashboard { grid-template-columns: 220px 1fr; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE — NATIVE APP LAYOUT (≤768px)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 768px) {

    /* ── Root container ─────────────────────────── */
    body { align-items: flex-start; }

    .app-container {
        width: 100%;
        height: 100%;
        min-height: 100vh;
        padding: 0;
        max-width: 100%;
    }

    .dashboard {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    /* ── Mobile Top Header Bar ──────────────────── */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 14px 18px;
        padding-top: calc(14px + env(safe-area-inset-top));
        background: var(--sidebar-bg);
        position: sticky;
        top: 0;
        z-index: 500;
        box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
        gap: 10px;
        text-decoration: none;
    }

    .mobile-header-logo img {
        height: 30px;
        border-radius: 6px;
    }

    .mobile-header-title {
        font-weight: 800;
        font-size: 1.1rem;
        color: #fff;
        letter-spacing: -0.02em;
    }

    .mobile-header-avatar {
        width: 36px; height: 36px;
        border-radius: 10px;
        background: linear-gradient(135deg, #f59e0b, #ef4444);
        color: #fff;
        display: flex; align-items: center; justify-content: center;
        font-weight: 800;
        font-size: 1rem;
    }

    /* ── Sidebar becomes Bottom Tab Bar ─────────── */
    .sidebar.glass-panel {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        width: 100%;
        z-index: 1000;
        flex-direction: row;
        align-items: stretch;
        padding: 8px 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        border-radius: 0;
        box-shadow: 0 -1px 0 rgba(255,255,255,0.06), 0 -8px 24px rgba(0,0,0,0.25);
        background: #1e1b4b;
        margin: 0;
        border: none;
        border-top: 1px solid rgba(255,255,255,0.07);
        min-height: 64px;
    }

    .user-profile,
    .sidebar-logo-area { display: none; }

    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        align-items: stretch;
        width: 100%;
        gap: 0;
        flex: 1;
        margin: 0;
    }

    .nav-item {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex: 1;
        height: auto;
        min-height: 48px;
        padding: 6px 4px 4px;
        font-size: 0.62rem;
        font-weight: 600;
        gap: 3px;
        border-radius: 10px;
        color: rgba(199, 210, 254, 0.55);
        opacity: 1;
        letter-spacing: 0.01em;
        margin-bottom: 0;
    }

    .nav-item i {
        margin: 0;
        font-size: 1.2rem;
        display: block;
    }

    .nav-item.active {
        color: #a5b4fc;
        background: rgba(99, 102, 241, 0.18);
    }

    .nav-item.active i {
        color: #818cf8;
    }

    #logout-btn { display: none !important; }

    /* ── Main Content Area ──────────────────────── */
    .main-content {
        flex: 1;
        padding: 20px 12px 100px;
        border-radius: 0;
        overflow-y: auto;
        background: var(--bg);
    }

    /* Hide normal topbar on mobile — we have .mobile-header */
    .topbar { display: none; }

    /* ── Cards & Panels ─────────────────────────── */
    .glass-panel {
        padding: 16px;
        border-radius: 14px;
        border: 1px solid var(--border);
    }

    /* ── Stat Cards ─────────────────────────────── */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stat-icon {
        width: 40px; height: 40px;
        font-size: 1.1rem;
        border-radius: 10px;
    }

    .stat-info h3 { font-size: 1.4rem; }
    .stat-info p  { font-size: 0.68rem; }

    /* ── Tables → Horizontal Scroll ─────────────── */
    .table-container {
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
        margin-top: 8px;
    }

    th { font-size: 0.68rem; padding: 9px 12px; }
    td { font-size: 0.82rem; padding: 10px 12px; }

    /* ── Form fields ────────────────────────────── */
    .form-control {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 13px 14px;
    }

    .form-group label { font-size: 0.72rem; }

    /* ── Buttons ────────────────────────────────── */
    .btn { padding: 12px 18px; font-size: 0.9rem; }

    /* ── Section headings inside cards ─────────── */
    h3 { font-size: 1rem; }

    /* ── Stack Create Employee + Directory on mobile ── */
    #users-view .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    /* ── Hide sidebar brand in bottom tab bar ────────── */
    .sidebar-brand { display: none; }

    /* ── Hide the desktop flex spacer in mobile tab bar ── */
    .sidebar-nav > div[style] { display: none !important; }
}