/* --- 1. CORE & LAYOUT --- */
:root {
    --primary-dark: #0f172a;
    --slate-300: #cbd5e1;
    --bg-light: #f8fafc;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
    background-color: var(--bg-light);
    margin: 0;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* Sembunyikan scrollbar untuk kesan aplikasi native */
::-webkit-scrollbar {
    width: 0px;
}

.page {
    display: none;
    width: 100%;
    max-width: 480px; /* Lebar maksimal layar HP */
    min-height: 100vh;
    margin: 0 auto;
    background-color: #ffffff;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.05);
}

.page.active {
    display: block;
}

#page-login.active {
    display: flex !important;
    flex-direction: column;
}

/* --- 2. SPLASH SCREEN --- */
#app-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: var(--primary-dark);
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

/* --- 3. BOTTOM NAVIGATION --- */
nav {
    display: none; /* Dikontrol via JS navigateTo */
    position: fixed;
    bottom: 0;
    left: 50% !important;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    z-index: 50;
    transition: all 0.3s ease;
}

.nav-item {
    color: var(--slate-300);
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary-dark) !important;
}

.nav-item.active i {
    transform: translateY(-2px);
}

/* --- 4. REFRESH SPINNER (FIXED CENTER) --- */
/* Ini adalah bagian yang memastikan spinner berada di tengah layar dashboard */
#refresh-spinner,
#history-refresh-spinner {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    transition: all 0.3s ease;
}

/* --- 5. DASHBOARD & HISTORY SPECIFIC --- */
#page-dashboard,
#page-history {
    overscroll-behavior-y: contain; /* Menahan tarikan browser bawaan */
    padding-bottom: 100px;
}

/* --- 6. UI COMPONENTS & UTILITIES --- */
.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.hidden {
    display: none !important;
}

/* Custom Popup Alert */
#custom-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    width: calc(100% - 40px);
    max-width: 440px;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

#custom-popup.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.bg-success { background-color: #ecfdf5; color: #10b981; }
.bg-error { background-color: #fef2f2; color: #ef4444; }
.bg-info { background-color: #eff6ff; color: #3b82f6; }

/* Feedback Ketukan Tombol */
button:active {
    transform: scale(0.97);
}

/* Animasi untuk masuknya halaman */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page.active {
    animation: fadeIn 0.3s ease-in-out;
}

#input-gps {
    min-height: 32px; /* Mencegah layout melompat saat teks muncul */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 2 baris biasanya cukup untuk HP */
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Menghilangkan efek mirror pada tampilan live video */
/* Video tetap di-mirror agar user nyaman saat membidik (seperti cermin) */
#video {
    transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
}

/* Canvas harus NORMAL (Hapus transform scaleX(-1) yang tadi) */
/* Karena JavaScript di atas sudah memutar gambarnya secara permanen */
#canvas {
    transform: none !important;
    -webkit-transform: none !important;
}

/* Tambahkan di style.css agar perpindahan video ke foto halus */
#canvas {
    animation: pulse-in 0.3s ease-out;
}

@keyframes pulse-in {
    0% { transform: scale(1.05); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}