/* ================= RESET & BASE ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --info: #2563eb;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}
body {
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ================= LOGIN PAGE ================= */
.login-body {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { font-size: 40px; }
.login-brand h1 { font-size: 20px; margin: 8px 0 4px; color: var(--primary-dark); }
.login-brand p { color: var(--text-muted); font-size: 13px; }
.login-footer { text-align: center; margin-top: 18px; font-size: 13px; }
.login-footer a { color: var(--primary); font-weight: 600; }

/* ================= FORMS ================= */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 20px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ================= ALERTS ================= */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning, .alert-warning-message { background: #fef3c7; color: #92400e; }

/* ================= APP SHELL ================= */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: #0f172a; color: #cbd5e1; flex-shrink: 0;
    display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0;
    overflow-y: auto; transition: transform 0.2s;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid #1e293b; }
.sidebar-logo { font-size: 24px; }
.sidebar-title { font-weight: 700; color: #fff; font-size: 14px; line-height: 1.3; }
.sidebar-menu { padding: 12px 10px; flex: 1; }
.menu-section { font-size: 11px; text-transform: uppercase; color: #64748b; padding: 14px 10px 6px; letter-spacing: 0.05em; }
.menu-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: 8px; font-size: 13.5px; margin-bottom: 2px; color: #cbd5e1;
}
.menu-item:hover { background: #1e293b; color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; }
.menu-logout { color: #f87171; margin-top: 10px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 14px 20px; gap: 14px;
    position: sticky; top: 0; z-index: 10;
}
.btn-hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.page-title { font-size: 17px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.notif-bell { position: relative; font-size: 18px; }
.notif-badge {
    position: absolute; top: -6px; right: -8px; background: var(--danger); color: #fff;
    font-size: 10px; border-radius: 999px; padding: 1px 5px; font-weight: 700;
}
.topbar-user { text-align: right; font-size: 13px; line-height: 1.3; }
.topbar-user small { color: var(--text-muted); }

.app-content { padding: 22px; flex: 1; }
.app-footer { text-align: center; padding: 16px; font-size: 12px; color: var(--text-muted); }

/* ================= CARDS / WIDGETS ================= */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .stat-icon { font-size: 22px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); }

/* ================= TABLES ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
tr:hover td { background: #f9fafb; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-hadir { background: #dcfce7; color: #166534; }
.badge-terlambat { background: #fef3c7; color: #92400e; }
.badge-izin { background: #dbeafe; color: #1e40af; }
.badge-sakit { background: #ede9fe; color: #5b21b6; }
.badge-cuti { background: #e0e7ff; color: #3730a3; }
.badge-alpha { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-disetujui { background: #dcfce7; color: #166534; }
.badge-ditolak { background: #fee2e2; color: #991b1b; }

/* ================= PRESENSI PAGE ================= */
.presensi-clock { text-align: center; padding: 30px 20px; }
.presensi-clock .jam { font-size: 44px; font-weight: 700; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.presensi-clock .tanggal { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.presensi-status-box { text-align: center; padding: 16px; border-radius: var(--radius); margin: 18px 0; }
.presensi-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.presensi-actions .btn { min-width: 160px; padding: 16px; font-size: 15px; }
.location-status { font-size: 13px; text-align: center; margin-top: 12px; color: var(--text-muted); }
#qr-reader { max-width: 420px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; }

/* ================= KAMERA PRESENSI (foto selfie) ================= */
.camera-box { max-width: 380px; margin: 0 auto 16px; text-align: center; }
.camera-hint { font-size: 13.5px; color: var(--text-muted); margin-bottom: 10px; }
.camera-frame {
    background: #111827; border-radius: var(--radius); overflow: hidden;
    aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
}
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-actions { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.camera-status { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }
.foto-riwayat { display: flex; gap: 14px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.foto-riwayat img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; border: 2px solid var(--border); }
.foto-riwayat div { text-align: center; }
.foto-riwayat span { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ================= RESPONSIVE ================= */
@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar {
        position: fixed; z-index: 100; transform: translateX(-100%); box-shadow: 0 0 0 100vmax rgba(0,0,0,0);
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,0.4); }
    .btn-hamburger { display: block; }
    .app-content { padding: 14px; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .presensi-clock .jam { font-size: 34px; }
    .login-card { padding: 24px 20px; }
}

/* ================= PRINT (untuk laporan) ================= */
@media print {
    .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
}
