*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gold: #fbbf24;
    --glass-blur: blur(12px);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1e1b4b, var(--bg-dark));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

/* UTILITY */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-gold { color: var(--gold); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.w-100 { width: 100%; }
.d-flex { display: flex; }

/* LAYOUT */
.app-container {
    width: 100%; max-width: 480px;
    height: 100vh; height: 100dvh;
    position: relative; background: inherit;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    overflow: hidden; margin: 0 auto;
    overscroll-behavior-y: none;
}
.screen { width: 100%; height: 100%; display: flex; flex-direction: column; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; width: 100%; position: relative; }

/* GLASS */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
}

/* LOGIN */
.login-wrapper { margin: auto; padding: 2rem; width: 90%; text-align: center; }
.logo { margin-bottom: 2rem; }
.logo i { font-size: 3rem; color: var(--primary); margin-bottom: 1rem; }
.logo h1 { font-weight: 700; letter-spacing: 2px; }
.logo h1 span { color: var(--primary); }
.logo p { color: var(--gold); font-size: 0.9rem; margin-top: 0.5rem; }

.input-group { position: relative; margin-bottom: 1.2rem; }
.input-group > i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); z-index: 1; }
.input-group input, .input-group select, .input-group textarea {
    width: 100%; padding: 1rem 1rem 1rem 3rem;
    background: rgba(0,0,0,0.2); border: 1px solid var(--border-glass);
    border-radius: 12px; color: white; font-size: 1rem;
    font-family: 'Inter', sans-serif; outline: none; transition: var(--transition);
}
.input-group select, .input-group textarea { padding-left: 1rem; }
.input-group input:focus, .input-group select:focus { border-color: var(--primary); box-shadow: 0 0 10px rgba(59,130,246,0.3); }

.btn-primary {
    width: 100%; padding: 1rem;
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: white; border: none; border-radius: 12px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 15px rgba(59,130,246,0.4); transition: var(--transition);
}
.btn-primary:active { transform: scale(0.98); }
.btn-sm { padding: 0.5rem 1rem; width: auto; font-size: 0.85rem; border-radius: 8px; }

.quick-login { margin-top: 2rem; font-size: 0.8rem; color: var(--text-muted); }
.login-badges { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }
.login-badges span { padding: 5px 10px; background: rgba(255,255,255,0.1); border-radius: 20px; cursor: pointer; transition: var(--transition); }
.login-badges span:hover { background: var(--primary); }

/* HEADER */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-radius: 0 0 20px 20px; border-top: none; z-index: 10;
    flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar { width: 45px; height: 45px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.details h3 { font-size: 1.1rem; }
.details p { font-size: 0.8rem; color: var(--gold); }
.actions { display: flex; gap: 8px; }
.icon-btn { background: rgba(255,255,255,0.1); border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; position: relative; transition: var(--transition); }
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.notif-badge { position: absolute; top: -5px; right: -5px; background: var(--danger); color: white; font-size: 0.6rem; padding: 3px 6px; border-radius: 10px; font-weight: bold; }

/* CONTENT */
.content-area { flex: 1; overflow-y: auto; padding: 1.5rem; padding-bottom: 100px; -webkit-overflow-scrolling: touch; }

/* BOTTOM NAV */
.app-nav {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around;
    padding: 0.8rem 0.5rem 1.2rem 0.5rem;
    border-radius: 20px 20px 0 0; border-bottom: none;
    z-index: 200; background: rgba(15,23,42,0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--text-muted); cursor: pointer; font-size: 0.7rem;
    text-decoration: none; transition: var(--transition);
    -webkit-tap-highlight-color: transparent; user-select: none;
    padding: 4px 8px; border-radius: 8px;
}
.nav-item i { font-size: 1.2rem; }
.nav-item.active { color: var(--gold); }
.chat-unread-badge {
    position: absolute; top: -2px; right: -2px;
    background: var(--danger); color: white;
    font-size: 0.6rem; min-width: 18px; height: 18px;
    border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-weight: 700;
    animation: pulse-badge 1.5s infinite;
}
@keyframes pulse-badge { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.nav-item { position: relative; }

/* TABS */
.tabs { display: flex; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 5px; }
.tab { flex: 1; text-align: center; padding: 10px; font-size: 0.85rem; cursor: pointer; border-radius: 8px; color: var(--text-muted); transition: var(--transition); }
.tab.active { background: var(--primary); color: white; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* FILTER BAR */
.filter-bar { border-radius: 12px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select {
    flex: 1; min-width: 100px; padding: 10px 12px; border-radius: 8px;
    background: rgba(0,0,0,0.3); border: 1px solid var(--border-glass);
    color: white; font-size: 0.85rem; outline: none;
}
.btn-filter {
    padding: 10px 16px; border-radius: 8px; border: none;
    background: var(--primary); color: white; cursor: pointer;
    font-size: 0.85rem; font-weight: 600; white-space: nowrap;
    transition: var(--transition);
}
.btn-filter:hover { background: #2563eb; }

/* CARDS */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card-item {
    background: var(--bg-panel); border: 1px solid var(--border-glass);
    border-radius: 12px; padding: 1rem; display: flex;
    justify-content: space-between; align-items: center;
    transition: var(--transition);
}
.card-item:hover { border-color: rgba(255,255,255,0.2); }
.card-left h4 { margin-bottom: 4px; }
.card-left p { font-size: 0.8rem; color: var(--text-muted); }

/* STATUS BADGES */
.status-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; text-align: center; white-space: nowrap; }
.status-badge.bg-warning { background: rgba(245,158,11,0.2); border: 1px solid var(--warning); color: var(--warning); }
.status-badge.bg-success { background: rgba(16,185,129,0.2); border: 1px solid var(--success); color: var(--success); }
.status-badge.bg-primary { background: rgba(59,130,246,0.2); border: 1px solid var(--primary); color: var(--primary); }
.status-badge.bg-danger { background: rgba(239,68,68,0.2); border: 1px solid var(--danger); color: var(--danger); }

/* HISTORY CARDS */
.history-list { display: flex; flex-direction: column; gap: 16px; }
.history-card {
    background: var(--bg-panel); border: 1px solid var(--border-glass);
    border-radius: 16px; overflow: hidden; transition: var(--transition);
}
.history-card:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }
.history-card-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.05); }
.history-card-body { padding: 20px; display: flex; gap: 20px; flex-direction: column; }
.history-photo { margin-top: 8px; }
.history-photo img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; cursor: pointer; transition: transform 0.2s; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.history-photo img:hover { transform: scale(1.02); }
.history-map { margin-top: 8px; }
.history-map iframe { border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); }
.history-info-grid {
    background: rgba(0,0,0,0.3); padding: 16px; border-radius: 12px;
    border: 1px solid var(--border-glass);
}
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.info-row:last-child { border-bottom: none; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { text-align: center; padding: 1rem 0; }
.stat-card h3 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }

/* CLOCK/ABSEN */
.clock-display { font-size: 3rem; font-weight: 700; color: var(--gold); letter-spacing: 2px; }
.btn-clock {
    width: 180px; height: 180px; border-radius: 50%; border: none;
    color: white; font-size: 1.1rem; font-weight: bold;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    margin: 0 auto; cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); transition: var(--transition);
}
.btn-clock i { font-size: 2.5rem; }
.btn-clock.in { background: radial-gradient(circle, #3b82f6, #1e3a8a); border: 4px solid var(--primary); }
.btn-clock.out { background: radial-gradient(circle, #ef4444, #7f1d1d); border: 4px solid var(--danger); }
.btn-clock:active { transform: scale(0.95); }

/* PULSE */
.animate-pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.7); } 70% { box-shadow: 0 0 0 15px rgba(59,130,246,0); } 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); } }

/* INFO ALERT */
.info-alert { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); border-radius: 12px; }
.info-alert i { font-size: 1.5rem; color: var(--primary); flex-shrink: 0; }
.info-alert p { font-size: 0.8rem; color: var(--text-muted); }

/* MODAL */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 500; display: flex; align-items: center; justify-content: center;
}
.modal-content { width: 90%; max-width: 420px; padding: 0; overflow: hidden; }
.modal-header { padding: 1rem; border-bottom: 1px solid var(--border-glass); display: flex; justify-content: space-between; align-items: center; }
.close-btn { font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 1.5rem; }
.camera-frame { width: 100%; height: 280px; background: #000; border-radius: 12px; margin-bottom: 1rem; position: relative; overflow: hidden; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.face-guide { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 60%; height: 80%; border: 2px dashed rgba(255,255,255,0.5); border-radius: 50%; }
.gps-status { color: var(--gold); font-size: 0.9rem; margin-bottom: 10px; }

/* SPINNER */
.loader-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.9); z-index: 999; display: flex; align-items: center; justify-content: center; }
.spinner { width: 50px; height: 50px; border: 5px solid rgba(255,255,255,0.1); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* PAGE HEADER */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 1.2rem; font-weight: 600; }

/* SEARCH BAR */
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px; }
.search-bar input { flex: 1; background: transparent; border: none; color: white; outline: none; font-size: 0.9rem; }
.search-bar i { color: var(--text-muted); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

/* LIGHTBOX */
.lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.lightbox.active { opacity: 1; pointer-events: all; }
.lightbox img { max-width: 95%; max-height: 90%; border-radius: 12px; box-shadow: 0 0 40px rgba(255,255,255,0.15); }
.lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 2.5rem; color: white; cursor: pointer; z-index: 1001; }

/* CHAT */
.chat-layout { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 400px; overflow: hidden; border-radius: 16px; border: 1px solid var(--border-glass); }
.chat-contacts { padding: 16px; overflow-y: auto; flex: 1; }
.contact-item {
    display: flex; align-items: center; gap: 14px; padding: 14px 12px;
    cursor: pointer; border-radius: 12px; transition: background 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.contact-item:hover, .contact-item.active { background: rgba(255,255,255,0.08); }
.contact-item .contact-name { font-size: 0.95rem; font-weight: 600; margin: 0; }
.contact-item .contact-role { font-size: 0.75rem; color: var(--gold); margin: 0; }

.chat-room {
    display: flex; flex-direction: column; flex: 1; height: 100%;
    background: var(--bg-dark); position: relative;
}
.chat-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-glass);
    font-weight: 600; background: rgba(0,0,0,0.4); font-size: 1rem;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.chat-header .btn-back {
    background: rgba(255,255,255,0.1); border: none; color: white;
    padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.8rem;
}
.chat-messages {
    flex: 1; padding: 20px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
}
.chat-placeholder { text-align: center; color: var(--text-muted); margin: auto; }
.chat-placeholder i { font-size: 3rem; margin-bottom: 12px; display: block; }
.bubble {
    max-width: 82%; padding: 12px 16px; border-radius: 18px;
    font-size: 0.9rem; line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    word-wrap: break-word;
}
.bubble.me { background: linear-gradient(135deg, var(--primary), #2563eb); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.other { background: rgba(255,255,255,0.08); color: white; align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid var(--border-glass); }
.bubble .bubble-time { font-size: 0.65rem; opacity: 0.6; margin-top: 4px; display: block; }

.chat-input-area {
    padding: 12px 16px; background: rgba(15,23,42,0.95);
    border-top: 1px solid var(--border-glass);
    display: flex; gap: 10px; align-items: center; flex-shrink: 0;
}
.chat-input-area input {
    flex: 1; padding: 12px 18px; border-radius: 25px;
    border: 1px solid var(--border-glass); background: rgba(0,0,0,0.4);
    color: white; outline: none; font-size: 0.9rem;
}
.chat-input-area input:focus { border-color: var(--primary); }
.chat-input-area button {
    background: var(--primary); color: white; border: none;
    border-radius: 50%; width: 46px; height: 46px; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.1rem; flex-shrink: 0; transition: var(--transition);
}
.chat-input-area button:hover { transform: scale(1.05); }

/* CUTI BADGES */
.badge-status { padding: 5px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-status.Pending { background: rgba(245,158,11,0.2); color: var(--warning); border: 1px solid var(--warning); }
.badge-status.Disetujui { background: rgba(16,185,129,0.2); color: var(--success); border: 1px solid var(--success); }
.badge-status.Ditolak { background: rgba(239,68,68,0.2); color: var(--danger); border: 1px solid var(--danger); }

/* ============================================ */
/* RESPONSIVE: DESKTOP >= 768px                 */
/* ============================================ */
@media (min-width: 768px) {
    .app-container {
        max-width: 100%; width: 100vw; height: 100vh;
        margin: 0; border-radius: 0; box-shadow: none; display: flex;
    }
    .screen { flex-direction: row; }

    .app-nav {
        position: static; width: 240px; min-width: 240px; height: 100vh;
        flex-direction: column; justify-content: flex-start;
        padding: 30px 0 0 0; border-radius: 0;
        border-right: 1px solid var(--border-glass);
        background: rgba(15,23,42,0.98);
    }
    .nav-item {
        flex-direction: row; font-size: 1rem; padding: 14px 24px;
        justify-content: flex-start; gap: 12px; margin-bottom: 2px;
        border-radius: 0; border-right: 3px solid transparent;
    }
    .nav-item i { font-size: 1.3rem; width: 30px; text-align: center; }
    .nav-item.active { background: rgba(59,130,246,0.1); border-right-color: var(--primary); }

    .app-header { position: relative; border-radius: 0; border-bottom: 1px solid var(--border-glass); padding: 16px 32px; }
    .content-area { padding: 32px; padding-bottom: 32px; }

    /* History Desktop */
    .history-card-body { flex-direction: row; }
    .history-card-body > div { flex: 1; }
    .history-photo img { max-height: 280px; }

    /* Chat Desktop: split view */
    .chat-layout { flex-direction: row; height: calc(100vh - 140px); }
    .chat-contacts { width: 300px; min-width: 300px; flex: none; border-right: 1px solid var(--border-glass); border-bottom: none; }
    .chat-room { display: flex !important; flex: 1; }
    .chat-header .btn-back { display: none; }
}

/* SMALL PHONE */
@media (max-width: 380px) {
    .clock-display { font-size: 2.2rem; }
    .btn-clock { width: 150px; height: 150px; font-size: 0.9rem; }
    .btn-clock i { font-size: 2rem; }
    .stats-grid { grid-template-columns: 1fr; }
}
