/* ─── Reset & Variables ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --green: #059669;
    --green-light: #10b981;
    --amber: #d97706;
    --amber-light: #f59e0b;
    --red: #dc2626;
    --bg: #fafbfc;
    --bg2: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text2: #1e293b;
    --text3: #475569;
    --text4: #94a3b8;
    --text5: #cbd5e1;
    --border: #e2e8f0;
    --border2: #f1f5f9;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ─── */
.page {
    max-width: 420px;
    margin: 0 auto;
    padding: 0 20px;
    padding-top: calc(20px + var(--safe-top));
    padding-bottom: calc(32px + var(--safe-bottom));
    min-height: 100vh;
    min-height: 100dvh;
}

/* ═══════════════════════════════════════════════════════════════ */
/* ═══ LOGIN ═══ */
/* ═══════════════════════════════════════════════════════════════ */

.login-page {
    background: linear-gradient(155deg, #0f172a 0%, #1e3a8a 40%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59,130,246,.15) 0%, transparent 70%);
    top: -300px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,.1) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
}

.login-page .page {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 44px 28px 36px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.1);
    text-align: center;
    animation: cardIn .5s cubic-bezier(.22,1,.36,1);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(30,64,175,.3);
}

.login-logo i {
    font-size: 28px;
    color: white;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text4);
    margin-top: 2px;
    font-weight: 500;
}

/* ─── Forms ─── */
.field {
    margin-top: 24px;
    text-align: left;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.field input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    transition: all .2s ease;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
    background: white;
}

.field input::placeholder {
    color: var(--text5);
}

.pw-wrap {
    position: relative;
}

.pw-toggle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text4);
    cursor: pointer;
    border-radius: var(--radius);
}

.pw-toggle:active {
    background: var(--bg2);
}

/* ─── Buttons ─── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    -webkit-appearance: none;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    margin-top: 28px;
    width: 100%;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(30,64,175,.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(30,64,175,.35);
}

.login-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border2);
    font-size: 12px;
    color: var(--text5);
}

/* ─── Alert ─── */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    animation: cardIn .3s ease;
}

.alert-error {
    background: #fef2f2;
    color: var(--red);
    border: 1px solid #fecaca;
}

/* ═══════════════════════════════════════════════════════════════ */
/* ═══ DASHBOARD ═══ */
/* ═══════════════════════════════════════════════════════════════ */

/* ─── Header ─── */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 18px;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-logo i {
    font-size: 15px;
    color: white;
}

.dash-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.3px;
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--text4);
    background: var(--bg2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    letter-spacing: .3px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text4);
    text-decoration: none;
    transition: all .15s;
}

.icon-btn:active {
    background: var(--bg2);
    transform: scale(.93);
}

.icon-btn.logout:active {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--red);
}

/* ─── Status Card ─── */
.status-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    animation: cardIn .3s ease;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.status-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text4);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
}

.badge.hadir {
    background: #ecfdf5;
    color: var(--green);
}

.badge.belum {
    background: #fefce8;
    color: var(--amber);
}

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ─── Clock ─── */
.clock-wrap {
    text-align: center;
    padding: 20px 0;
}

.clock {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -3px;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.clock-sep {
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.clock-date {
    font-size: 14px;
    color: var(--text3);
    margin-top: 6px;
    font-weight: 500;
}

/* ─── Today Info ─── */
.today-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border2);
}

.today-item {
    text-align: center;
    padding: 14px 8px;
    background: var(--bg);
    border-radius: var(--radius-lg);
}

.today-item .label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text4);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.today-item .value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.today-item .value.empty {
    color: var(--text5);
    font-size: 14px;
}

.status-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text4);
}

.status-footer i {
    font-size: 12px;
    color: var(--text5);
}

/* ─── Section Labels ─── */
.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text4);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 10px;
    padding-left: 2px;
}

/* ─── Camera Card ─── */
.camera-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    animation: cardIn .4s ease;
}

.camera-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #0f172a;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.camera-viewport video,
.camera-viewport img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,.3);
    font-size: 13px;
    font-weight: 500;
}

.camera-placeholder i {
    font-size: 36px;
    opacity: .5;
}

.photo-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(5,150,105,.4);
    animation: popIn .3s cubic-bezier(.22,1,.36,1);
}

@keyframes popIn {
    from { transform: scale(0); }
    60% { transform: scale(1.15); }
    to { transform: scale(1); }
}

/* ─── Camera Action Buttons ─── */
.camera-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.camera-actions .btn {
    flex: 1;
    height: 44px;
    font-size: 13px;
    border-radius: var(--radius);
}

.btn-camera {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(15,23,42,.2);
}

.btn-retake {
    background: var(--bg2);
    color: var(--text3);
    border: 1px solid var(--border) !important;
}

.btn-upload {
    background: var(--bg2);
    color: var(--text3);
    border: 1px solid var(--border) !important;
}

.btn-upload i {
    font-size: 14px;
}

/* ─── Absen Card ─── */
.absen-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    animation: cardIn .5s ease;
}

.absen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.absen-btn {
    height: 88px;
    border: none;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: .3px;
}

.absen-btn i {
    font-size: 24px;
}

.absen-btn.masuk {
    background: linear-gradient(145deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 12px rgba(5,150,105,.3);
}

.absen-btn.pulang {
    background: linear-gradient(145deg, #d97706, #f59e0b);
    color: white;
    box-shadow: 0 4px 12px rgba(217,119,6,.3);
}

.absen-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    box-shadow: none;
    filter: saturate(.3);
}

.absen-btn:not(:disabled):active {
    transform: scale(.95);
}

.absen-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text5);
    margin-top: 12px;
    font-weight: 500;
}

/* ─── History ─── */
.history-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    animation: cardIn .6s ease;
}

.history-list {
    max-height: 240px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--bg);
    margin-bottom: 6px;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    min-width: 70px;
}

.history-times {
    display: flex;
    gap: 16px;
    flex: 1;
}

.history-time-block {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-dot.in { background: var(--green); }
.history-dot.out { background: var(--amber); }

.history-time {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.history-empty {
    text-align: center;
    padding: 24px 0;
    color: var(--text5);
    font-size: 13px;
    font-weight: 500;
}

.history-empty i {
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text5);
    opacity: .5;
}

/* ═══════════════════════════════════════════════════════════════ */
/* ═══ OVERLAY / TOAST ═══ */
/* ═══════════════════════════════════════════════════════════════ */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.loading-box {
    background: white;
    padding: 36px 44px;
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-box p {
    font-size: 14px;
    color: var(--text3);
    font-weight: 500;
}

.toast {
    position: fixed;
    bottom: calc(28px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    animation: toastUp .35s cubic-bezier(.22,1,.36,1);
    white-space: nowrap;
    max-width: calc(100vw - 32px);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

@keyframes toastUp {
    from { opacity: 0; transform: translate(-50%, 12px) scale(.96); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text5); border-radius: 3px; }

/* ─── Hidden file input ─── */
#fileInput { display: none; }
