/* ============================================
   FIELD PRO v6 - Disciplined Design System
   3 Colors Only: Neutral + Accent + Semantic
   Responsive: Mobile-first → Desktop sidebar
   ============================================ */

:root {
    /* === NEUTRAL SCALE === */
    --bg-base: #0a0a0c;
    --surface-1: #131317;       /* card */
    --surface-2: #1c1c22;       /* elevated card / hover */
    --surface-3: #26262e;       /* highest */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.14);

    --text-1: #f5f5f7;          /* primary text */
    --text-2: #a1a1aa;          /* secondary text */
    --text-3: #6b6b76;          /* muted */
    --text-4: #4a4a55;          /* faint */

    /* === ACCENT (single color) === */
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-border: rgba(99, 102, 241, 0.3);

    /* === SEMANTIC === */
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);

    /* === LAYOUT === */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

    --sidebar-w: 240px;
    --content-max: 1200px;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-1);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
    min-height: 100vh;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'tnum';
    background-image: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(99, 102, 241, 0.06), transparent);
    background-attachment: fixed;
}
.page { display: none !important; }
.page.active { display: block !important; }

/* ===== TYPOGRAPHY ===== */
h1, h2, h3 { letter-spacing: -0.02em; font-weight: 600; color: var(--text-1); }
.text-display { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--text-1); }
.text-eyebrow { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--accent);
    color: white;
    transition: var(--transition);
    border: 1px solid transparent;
    font-weight: 500;
    letter-spacing: -0.01em;
    cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--border-hover); }

/* ===== CARDS (single style) ===== */
.card {
    background: var(--surface-1);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); }

/* ===== INPUT ===== */
.input-field {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    outline: none;
    transition: var(--transition);
    font-size: 14px;
    background: var(--surface-1);
    color: var(--text-1);
    font-family: inherit;
}
.input-field:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface-2);
}
.input-field:disabled { background: var(--bg-base); color: var(--text-3); cursor: not-allowed; }
.input-field::placeholder { color: var(--text-4); }
select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b6b76' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
select.input-field option { background: var(--surface-2); color: var(--text-1); }

/* ===== STATUS BADGES (only 3 variants) ===== */
.status-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid;
}
.status-badge.is-success { background: var(--success-soft); color: var(--success); border-color: rgba(16,185,129,0.2); }
.status-badge.is-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(239,68,68,0.2); }
.status-badge.is-neutral { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.status-badge.is-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }

/* Map old class names to new system */
.status-masuk { background: var(--success-soft); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.status-pulang { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.status-terlambat { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.status-izin, .status-cuti, .status-sakit, .status-lembur { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.weather-badge { padding: 2px 8px; border-radius: 100px; font-size: 10px; font-weight: 500; background: var(--surface-2); color: var(--text-2); }

/* ===== RESPONSIVE LAYOUT ===== */

/* App Shell */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}

/* Sidebar (desktop only) */
.sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: var(--space-6) var(--space-4);
    z-index: 50;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.sidebar.collapsed { width: 64px; padding: var(--space-6) var(--space-2); }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-brand > div:last-child,
.sidebar.collapsed .sidebar-item span,
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed .sidebar-brand { padding: 0; justify-content: center; margin-bottom: var(--space-4); border: none; padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-item svg { margin: 0; }

.sidebar-collapse-btn {
    position: absolute;
    top: 16px; right: -12px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 51;
    transition: var(--transition);
    color: var(--text-3);
}
.sidebar-collapse-btn:hover { background: var(--surface-3); color: var(--text-1); }
.sidebar.collapsed .sidebar-collapse-btn { right: -12px; transform: rotate(180deg); }
.sidebar-brand {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 0 var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
}
.sidebar-brand-logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.sidebar-brand-text { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13.5px;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text-1); }
.sidebar-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-item.active svg { stroke: var(--accent); }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
    position: absolute;
    bottom: var(--space-4); left: var(--space-4); right: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

/* Mobile bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface-1);
    border-top: 1px solid var(--border);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    gap: 4px;
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: none;
    min-height: 56px;
    position: relative;
}
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }
.nav-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 28px; height: 2px;
    background: var(--accent); border-radius: 0 0 4px 4px;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item span { font-size: 10px; font-weight: 500; }

/* Mobile header */
.mobile-header {
    background: rgba(19, 19, 23, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

/* Main content area */
.main-content {
    padding-bottom: 80px; /* space for bottom nav */
}

/* === DESKTOP (≥1024px) === */
@media (min-width: 1024px) {
    .sidebar { display: block; }
    .bottom-nav { display: none; }
    .mobile-header { display: none; }
    .main-content {
        margin-left: var(--sidebar-w);
        padding-bottom: var(--space-6);
        min-height: 100vh;
        transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.collapsed ~ .main-content,
    body.sidebar-collapsed .main-content { margin-left: 64px; }
    .desktop-header {
        display: flex !important;
        position: sticky;
        top: 0;
        background: rgba(10, 10, 12, 0.85);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border);
        z-index: 20;
        padding: var(--space-4) var(--space-6);
        align-items: center;
        justify-content: space-between;
    }
    body.light-mode .desktop-header { background: rgba(248, 250, 252, 0.85); }
    .container-content {
        max-width: var(--content-max);
        margin: 0 auto;
        padding: var(--space-6);
    }
    .grid-desktop-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-desktop-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-desktop-4 { grid-template-columns: repeat(4, 1fr); }
    .hero-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-4); }
    .text-display { font-size: 56px; }
}

@media (max-width: 1023px) {
    .desktop-header { display: none !important; }
    .container-content { padding: var(--space-4); max-width: 600px; margin: 0 auto; }
}

/* ===== TOAST ===== */
.toast {
    position: fixed; top: 20px; left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 12px 20px; border-radius: 100px;
    color: white; font-weight: 500; font-size: 13px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: rgba(16,185,129,0.92); }
.toast.error { background: rgba(239,68,68,0.92); }
.toast.info { background: rgba(99,102,241,0.92); }
.toast.warning { background: rgba(245,158,11,0.92); }

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Map */
#map, #detail-map { height: 200px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 1; }
@media (min-width: 1024px) { #map { height: 280px; } }
#camera-video, #project-camera-video { transform: scaleX(-1); border-radius: var(--radius); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; backdrop-filter: blur(12px); }
.modal-container {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 101;
    background: var(--surface-1); border-radius: 20px 20px 0 0;
    max-height: 85vh; overflow-y: auto; padding: var(--space-6);
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border-strong);
}
@media (min-width: 1024px) {
    .modal-container { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); border-radius: var(--radius-lg); max-width: 500px; width: 90%; max-height: 80vh; animation: fadeIn 0.2s ease; }
    .modal-container::before { display: none; }
}
.modal-container::before { content:''; display:block; width:36px; height:4px; background:var(--border-strong); border-radius:4px; margin:0 auto 20px; }

/* Confirm */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(12px); }
.confirm-box { background: var(--surface-2); border-radius: var(--radius); padding: 28px; max-width: 360px; width: 100%; text-align: center; animation: fadeIn 0.2s ease; border: 1px solid var(--border-strong); }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.2); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress-bar { height: 4px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 100px; transition: width 0.6s ease; }

/* Gallery */
.gallery-item { border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; cursor: pointer; transition: var(--transition); border: 1px solid var(--border); }
.gallery-item:hover { transform: scale(1.02); border-color: var(--border-hover); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* Hero check-in card */
.checkin-hero {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    position: relative;
    overflow: hidden;
}
.checkin-hero::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 60%; height: 200%;
    background: radial-gradient(ellipse, var(--accent-soft), transparent 60%);
    pointer-events: none;
}
@media (min-width: 1024px) { .checkin-hero { padding: var(--space-8); } }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.02) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Splash */
#splash-screen { position: fixed; inset: 0; z-index: 99999; background: var(--bg-base); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.5s ease, visibility 0.5s ease; }
#splash-screen.hide { opacity: 0; visibility: hidden; pointer-events: none; }
#splash-screen .splash-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
#splash-screen .splash-text { color: var(--text-1); font-size: 16px; font-weight: 600; margin-top: 16px; letter-spacing: -0.02em; }
#splash-screen .splash-loader { width: 80px; height: 2px; background: var(--surface-2); border-radius: 100px; margin-top: 20px; overflow: hidden; }
#splash-screen .splash-loader-bar { width: 30%; height: 100%; background: var(--accent); border-radius: 100px; animation: splashLoad 1.2s ease-in-out infinite; }
@keyframes splashLoad { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }

/* Success */
.success-overlay { position: fixed; inset: 0; z-index: 9998; background: rgba(0,0,0,0.7); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.success-circle { width: 80px; height: 80px; border-radius: 50%; background: var(--success); display: flex; align-items: center; justify-content: center; animation: successPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes successPop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.success-check { width: 32px; height: 32px; stroke: white; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawCheck 0.5s ease 0.3s forwards; }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

/* Page transition */
.page-enter { animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1); }

/* Offline */
.offline-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: white; text-align: center; padding: 8px; font-size: 11px; font-weight: 600; z-index: 10000; transform: translateY(-100%); transition: transform 0.3s ease; }
.offline-banner.show { transform: translateY(0); }

/* Admin tabs */
.admin-subtab { background: transparent; border: 1px solid transparent; transition: var(--transition); color: var(--text-3); cursor: pointer; }
.admin-subtab.active { background: var(--surface-1); color: var(--text-1); border-color: var(--border); }
.admin-subcontent.hidden { display: none; }

/* Rekap table */
.rekap-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.rekap-table th, .rekap-table td { padding: 6px 4px; border: 1px solid var(--border); text-align: center; white-space: nowrap; }
.rekap-table th { background: var(--surface-2); font-weight: 600; color: var(--text-3); position: sticky; top: 0; text-transform: uppercase; letter-spacing: 0.05em; font-size: 10px; }
.rekap-table td:first-child { text-align: left; font-weight: 500; position: sticky; left: 0; background: var(--surface-1); min-width: 100px; color: var(--text-1); }
.rekap-table th:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface-2); }
.rekap-table .cell-h { background: var(--success-soft); color: var(--success); font-weight: 600; }
.rekap-table .cell-t { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.rekap-table .cell-i, .rekap-table .cell-s, .rekap-table .cell-c, .rekap-table .cell-l { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rekap-table .cell-a { background: rgba(255,255,255,0.02); color: var(--text-4); }

/* === GLOBAL TAILWIND OVERRIDES (force consistency) === */
.bg-gray-50, .bg-gray-100 { background: var(--surface-2) !important; }
.bg-gray-800, .bg-gray-900 { background: #000 !important; }
.text-gray-700, .text-gray-600, .text-gray-500 { color: var(--text-2) !important; }
.text-gray-400 { color: var(--text-3) !important; }
.text-secondary { color: var(--text-1) !important; }
.text-primary-light, .text-blue-500, .text-blue-600 { color: var(--accent) !important; }
.text-green-600, .text-green-500 { color: var(--success) !important; }
.text-orange-500, .text-amber-500, .text-amber-400 { color: var(--text-2) !important; }
.text-red-500, .text-red-600 { color: var(--danger) !important; }
.text-purple-600, .text-purple-500, .text-purple-400 { color: var(--accent) !important; }
.text-blue-400, .text-blue-300 { color: var(--accent) !important; }
.text-amber-300, .text-amber-700 { color: var(--text-2) !important; }
.text-green-300, .text-green-400, .text-green-700 { color: var(--success) !important; }
.text-purple-300, .text-purple-700 { color: var(--accent) !important; }
.text-indigo-700, .text-indigo-300 { color: var(--accent) !important; }
.border-gray-200, .border-gray-300 { border-color: var(--border) !important; }
.border-blue-500\/20, .border-purple-500\/20, .border-amber-500\/20, .border-green-500\/20 { border-color: var(--border) !important; }
.bg-blue-500\/10, .bg-blue-500\/20, .bg-purple-500\/10, .bg-purple-500\/20, .bg-amber-500\/10, .bg-amber-500\/20, .bg-green-500\/10, .bg-green-500\/20 { background: var(--surface-2) !important; }
.bg-green-600 { background: var(--success) !important; }
.bg-green-600:hover, .hover\:bg-green-700:hover { background: #059669 !important; }
.bg-blue-600 { background: var(--accent) !important; }
.bg-blue-600:hover, .hover\:bg-blue-700:hover { background: var(--accent-hover) !important; }
.btn-primary { background: var(--accent) !important; }
.btn-primary:hover { background: var(--accent-hover) !important; }
#profile-avatar, #header-avatar { background: var(--accent) !important; color: white !important; }
.hover\:bg-gray-50:hover, .hover\:bg-gray-100:hover { background: var(--surface-2) !important; }
.hover\:bg-purple-50:hover, .hover\:bg-red-50:hover, .hover\:bg-amber-50:hover, .hover\:bg-indigo-50:hover, .hover\:bg-green-100:hover, .hover\:bg-blue-100:hover, .hover\:bg-amber-100:hover, .hover\:bg-purple-100:hover { background: var(--surface-2) !important; }
.border-purple-200, .border-red-200, .border-amber-200, .border-indigo-200 { border-color: var(--border) !important; }

/* Buttons in modal */
.modal-container button.bg-primary, .modal-container button.bg-primary-dark { background: var(--accent) !important; }
.modal-container .text-red-600 { color: var(--danger) !important; }
.modal-container .border-red-200 { border-color: rgba(239,68,68,0.3) !important; }
.modal-container .text-blue-600 { color: var(--accent) !important; }
.modal-container .border-blue-200 { border-color: var(--accent-border) !important; }

/* Print */
@media print {
    body { background: white !important; color: black !important; }
    .card { background: white !important; border: 1px solid #ccc !important; }
    nav, header, .sidebar, .bottom-nav { display: none !important; }
    .main-content { margin-left: 0 !important; }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================
   ACCESSIBILITY FIXES (WCAG AA)
   ============================================ */

/* Higher contrast text colors */
:root {
    --text-1: #ffffff;          /* Pure white for max readability */
    --text-2: #c4c4cc;          /* 5:1 contrast ratio */
    --text-3: #9494a0;          /* 4.5:1 minimum */
    --text-4: #6e6e7a;          /* Decorative only */
}

/* Bigger base font for outdoor readability */
body { font-size: 15px; }
.input-field { font-size: 15px; padding: 12px 16px; min-height: 48px; }
label { font-size: 13px !important; }
.text-eyebrow { font-size: 12px; }

/* Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    z-index: 100000;
    border-radius: 0 0 8px 0;
    font-weight: 500;
    text-decoration: none;
}
.skip-link:focus { top: 0; }

/* Touch targets ≥44px */
button, a, input, select, textarea, [role="button"] { min-height: 44px; }
.btn-icon { min-width: 44px; min-height: 44px; }
.nav-item { min-height: 60px; }

/* Better focus rings */
*:focus { outline: none; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* sr-only utility */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Error states with proper contrast */
.input-field[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.input-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Status announcements */
.live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: more) {
    :root {
        --border: rgba(255, 255, 255, 0.2);
        --border-hover: rgba(255, 255, 255, 0.3);
        --text-2: #d4d4dc;
        --text-3: #a8a8b2;
    }
}

/* Focus within modal */
.modal-container:focus { outline: none; }
.modal-container:focus-within { outline: none; }

/* ============================================
   LIGHT MODE SUPPORT
   ============================================ */
body.light-mode {
    --bg-base: #f8fafc;
    --surface-1: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.12);
    --border-strong: rgba(0, 0, 0, 0.16);
    --text-1: #0f172a;
    --text-2: #475569;
    --text-3: #64748b;
    --text-4: #94a3b8;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: rgba(79, 70, 229, 0.08);
    --accent-border: rgba(79, 70, 229, 0.25);
    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.08);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    background-image: none;
    color-scheme: light;
}
body.light-mode .login-bg::before { background: radial-gradient(circle, rgba(79,70,229,0.08) 0%, transparent 60%); }
body.light-mode .login-bg::after { background-image: none; }
body.light-mode .checkin-hero::before { background: radial-gradient(ellipse, rgba(79,70,229,0.05), transparent 60%); }
body.light-mode .toast { box-shadow: 0 10px 40px rgba(0,0,0,0.15); }
body.light-mode .card { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
body.light-mode .btn-primary { box-shadow: 0 2px 8px rgba(79,70,229,0.25); }
body.light-mode #splash-screen { background: #f8fafc; }
body.light-mode #splash-screen .splash-text { color: #0f172a; }
body.light-mode .confirm-box { box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
body.light-mode .modal-container { box-shadow: 0 -4px 24px rgba(0,0,0,0.1); }

/* Theme toggle button */
.theme-toggle {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-3);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--border-hover); }

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 32px 16px;
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.4; color: var(--text-3); }
.empty-state p { color: var(--text-3); font-size: 13px; margin-top: 8px; }
.empty-state .empty-title { color: var(--text-2); font-weight: 500; font-size: 14px; margin-top: 12px; }

/* ============================================
   ONBOARDING TOOLTIP
   ============================================ */
.onboarding-overlay {
    position: fixed; inset: 0; z-index: 9990;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 24px;
}
.onboarding-card {
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 360px;
    width: 100%;
    animation: fadeIn 0.3s ease;
}
.onboarding-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.onboarding-card p { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.onboarding-dots { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.onboarding-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.onboarding-dot.active { background: var(--accent); width: 18px; border-radius: 100px; }

/* ============================================
   INSTALL PROMPT (PWA)
   ============================================ */
.install-banner {
    position: fixed; bottom: 80px; left: 16px; right: 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 16px;
    z-index: 50;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease;
    max-width: 400px;
    margin: 0 auto;
}
@media (min-width: 1024px) { .install-banner { bottom: 24px; left: auto; right: 24px; } }

/* ============================================
   SIDEBAR COLLAPSED TOOLTIPS
   ============================================ */
@media (min-width: 1024px) {
    .sidebar.collapsed .sidebar-item {
        position: relative;
    }
    .sidebar.collapsed .sidebar-item:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--surface-3);
        color: var(--text-1);
        padding: 6px 12px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        border: 1px solid var(--border);
        pointer-events: none;
        z-index: 100;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    .sidebar.collapsed .sidebar-item:hover::before {
        content: '';
        position: absolute;
        left: calc(100% + 6px);
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-right-color: var(--surface-3);
        pointer-events: none;
        z-index: 100;
    }

    /* Desktop layout: 2-column for forms */
    .desktop-2col {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
        align-items: start;
    }
    .desktop-2col .col-span-2 { grid-column: span 2; }

    /* Wider content on desktop */
    #tab-absen .container-content,
    #tab-laporan .container-content,
    #tab-proyek .container-content,
    #tab-riwayat .container-content,
    #tab-admin .container-content,
    #tab-profil .container-content {
        max-width: 900px;
    }

    /* Absen tab: camera + map side by side */
    .absen-desktop-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
    }
    .absen-desktop-grid .absen-full { grid-column: span 2; }
}
