/* PresensiKu — CSS Native & Modern Mobile-First */
:root {
    --primary: #1e40af;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --dark: #0f172a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 25px rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 15px;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Container & Layout */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 16px 85px 16px;
    min-height: 100vh;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px 20px;
}

/* Header */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control, input[type="text"], input[type="password"], input[type="time"], input[type="date"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.2s;
    outline: none;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-block {
    width: 100%;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-hadir, .badge-disetujui, .badge-success { background: var(--success-light); color: var(--success); }
.badge-terlambat, .badge-warning, .badge-menunggu { background: var(--warning-light); color: var(--warning); }
.badge-alpa, .badge-ditolak, .badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-izin, .badge-sakit, .badge-cuti, .badge-info { background: var(--primary-light); color: var(--primary); }
.badge-libur, .badge-secondary { background: #f1f5f9; color: #475569; }

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* Camera Viewport */
.camera-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 380px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-box video, .camera-box canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Efek cermin untuk selfie */
}

.camera-overlay {
    position: absolute;
    inset: 0;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.face-guide {
    width: 180px;
    height: 230px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

.camera-switch-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* GPS Info Box */
.gps-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gps-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-dot.active { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.error { background: var(--danger); }

/* Bottom Nav for Mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 4px;
    z-index: 99;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-bottom: 3px;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
}

/* Admin Nav */
.admin-navbar {
    background: #1e293b;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

.admin-nav-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.admin-nav-links a {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
}

.admin-nav-links a:hover, .admin-nav-links a.active {
    background: #334155;
    color: #fff;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin: 6px 0 2px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

/* --- Responsif: dashboard & halaman admin di HP --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

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

@media (max-width: 768px) {
    .admin-container {
        padding: 16px 12px 40px 12px;
    }
    .admin-navbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }
    .admin-nav-links {
        flex-wrap: wrap;
        gap: 4px;
    }
    .admin-nav-links a {
        font-size: 12px;
        padding: 6px 8px;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
        margin-bottom: 16px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-value {
        font-size: 24px;
    }
    .card {
        padding: 14px;
    }
    .card-title {
        flex-wrap: wrap;
        gap: 8px;
        font-size: 15px;
    }
    table {
        font-size: 12px;
    }
    th, td {
        padding: 8px 10px;
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    .modal-content {
        padding: 16px;
    }
}
