/* ============================================================
   APP.CSS — Global CSS
   Lapak Mamih Siang
   Diekstrak dari 4 prototype: customer.html, mitra.html, admin.html, driver.html
   Perubahan: modal center (PO-DEC-07), tambah .loading/.spinner
   ============================================================ */

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.5; color: var(--text); background: var(--bg);
  min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ============ CSS VARIABLES ============ */
:root {
  --navy: #10172A; --midnight: #172554; --electric: #3B82F6; --cyan: #22D3EE;
  --green: #22C55E; --orange: #F59E0B; --red: #EF4444; --purple: #8B5CF6; --pink: #EC4899;
  --bg: #F5F7FC; --surface: #FFFFFF; --surface-2: #F0F4FA;
  --text: #0B1020; --text-2: #475569; --text-3: #94A3B8;
  --border: #E2E8F0; --shadow: 0 4px 20px rgba(16,23,42,.08);
  --shadow-lg: 0 20px 50px rgba(16,23,42,.12);
  --grad-primary: linear-gradient(135deg, #2563EB 0%, #06B6D4 100%);
  --grad-dark: linear-gradient(135deg, #111827 0%, #1E3A8A 55%, #0891B2 100%);
  --grad-card: linear-gradient(135deg, rgba(37,99,235,.08), rgba(6,182,212,.08));
  --grad-warm: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);
  --grad-purple: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  --grad-green: linear-gradient(135deg, #22C55E 0%, #06B6D4 100%);
  --radius: 16px; --radius-sm: 10px; --radius-lg: 24px;
  --sidebar-w: 260px;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
[data-theme="dark"] {
  --bg: #0B1020; --surface: #141C30; --surface-2: #1A2340;
  --text: #F1F5F9; --text-2: #CBD5E1; --text-3: #64748B;
  --border: #1E293B; --shadow: 0 4px 20px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.5);
  --grad-card: linear-gradient(135deg, rgba(37,99,235,.15), rgba(6,182,212,.1));
}

/* ============ KEYFRAMES ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes float { 0%, 100% { transform: translate(0,0); } 50% { transform: translate(30px, -30px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes dotPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,.5); } 50% { box-shadow: 0 0 0 8px rgba(59,130,246,0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============ SPLASH ============ */
#splash {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: var(--grad-dark); transition: opacity .6s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: #fff; animation: fadeUp 1s ease; }
.splash-logo {
  width: 100px; height: 100px; margin: 0 auto 20px; border-radius: 28px;
  background: linear-gradient(135deg, #fff, rgba(255,255,255,.6));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 0 60px rgba(34,211,238,.5); animation: pulse 2s ease-in-out infinite;
}
.splash-logo img { width: 70%; height: 70%; object-fit: contain; }
.splash-title { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 8px; }
.splash-tagline { font-size: 14px; opacity: .8; margin-bottom: 30px; }
.splash-progress {
  width: 200px; height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin: 0 auto; overflow: hidden;
}
.splash-progress::after {
  content: ""; display: block; width: 40%; height: 100%;
  background: linear-gradient(90deg, #22D3EE, #3B82F6); border-radius: 2px;
  animation: progress 1.8s ease-in-out infinite;
}

/* ============ AUTH ============ */
#auth {
  display: none; min-height: 100dvh; padding: 20px; background: var(--grad-dark);
  position: relative; overflow: hidden; align-items: center; justify-content: center;
}
#auth.active { display: flex; }
.auth-bg { position: absolute; inset: 0; opacity: .3; }
.auth-bg::before, .auth-bg::after {
  content: ""; position: absolute; border-radius: 50%;
  background: radial-gradient(circle, #22D3EE, transparent 70%); filter: blur(60px);
}
.auth-bg::before { width: 400px; height: 400px; top: -100px; right: -100px; animation: float 8s ease-in-out infinite; }
.auth-bg::after { width: 300px; height: 300px; bottom: -50px; left: -50px;
  background: radial-gradient(circle, #3B82F6, transparent 70%); animation: float 10s ease-in-out infinite reverse; }
.auth-card {
  position: relative; width: 100%; max-width: 420px; background: var(--surface);
  border-radius: var(--radius-lg); padding: 32px 24px; box-shadow: var(--shadow-lg); animation: fadeUp .6s ease;
}
.auth-logo {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--grad-primary); display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 10px 30px rgba(37,99,235,.3);
}
.auth-logo img { width: 70%; height: 70%; object-fit: contain; }
.auth-title { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 6px; color: var(--text); }
.auth-sub { text-align: center; font-size: 13px; color: var(--text-2); margin-bottom: 24px; }
.auth-error {
  background: rgba(239,68,68,.1); color: var(--red); padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; display: none;
}
.auth-error.show { display: block; animation: shake .3s; }
.auth-divider { text-align: center; color: var(--text-3); font-size: 12px; margin: 20px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border);
}
.auth-divider::before { left: 0; } .auth-divider::after { right: 0; }
.auth-notice {
  margin-top: 20px; padding: 10px; background: rgba(245,158,11,.1);
  border-radius: var(--radius-sm); font-size: 11px; color: var(--orange); text-align: center;
}

/* ============ FORM ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.input-wrap { position: relative; }
.form-input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
  transition: all .2s; font-size: 14px;
}
.form-input:focus { outline: 0; border-color: var(--electric); background: var(--surface); box-shadow: 0 0 0 4px rgba(59,130,246,.1); }
textarea.form-input { resize: vertical; min-height: 80px; font-family: inherit; }
select.form-input { cursor: pointer; }
.btn-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); padding: 6px; }

/* ============ BUTTONS ============ */
.btn-primary {
  width: 100%; padding: 14px; border-radius: var(--radius-sm);
  background: var(--grad-primary); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 25px rgba(37,99,235,.3); transition: transform .15s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn {
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 700;
  transition: all .2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad-primary); color: #fff; box-shadow: 0 6px 18px rgba(37,99,235,.25); }
.btn.success { background: var(--green); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.warn { background: var(--orange); color: #fff; }
.btn.purple { background: var(--grad-purple); color: #fff; }
.btn.green { background: var(--grad-green); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 11px; }
.btn.full { width: 100%; }
.btn.icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn.icon svg { width: 14px; height: 14px; }
.btn-group { display: flex; gap: 4px; flex-wrap: wrap; }

/* ============ MODAL (CENTER — PO-DEC-07) ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(11,16,32,.6);
  backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.active { display: flex; animation: fadeIn .2s; }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 90dvh;
  border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column; animation: fadeInScale .3s ease;
  box-shadow: var(--shadow-lg);
}
.modal-handle { display: none; }
.modal-head {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.modal-close svg { width: 18px; height: 18px; color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 8px;
}

/* ============ TOAST ============ */
#toast {
  position: fixed; top: calc(20px + var(--safe-top)); left: 50%; transform: translateX(-50%) translateY(-100px);
  z-index: 9999; background: var(--surface); color: var(--text); padding: 12px 18px;
  border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; transition: transform .3s ease; max-width: 90%; border: 1px solid var(--border);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--green); color: #fff; border-color: var(--green); }
#toast.error { background: var(--red); color: #fff; border-color: var(--red); }

/* ============ EMPTY STATE ============ */
.empty { text-align: center; padding: 40px 20px; }
.empty-icon {
  width: 80px; height: 80px; margin: 0 auto 16px; border-radius: 50%;
  background: var(--grad-card); display: flex; align-items: center; justify-content: center;
}
.empty-icon svg { width: 40px; height: 40px; color: var(--electric); }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }

/* ============ CHIPS ============ */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 4px 10px; background: var(--surface-2); border-radius: 20px; font-size: 10px; color: var(--text-2); font-weight: 600; }

/* ============ FILTER TABS ============ */
.filter-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 7px 14px; background: var(--surface-2); border-radius: 20px; font-size: 12px;
  font-weight: 600; color: var(--text-2); white-space: nowrap; cursor: pointer; transition: all .2s; border: 1.5px solid transparent;
}
.filter-tab.active { background: var(--grad-card); color: var(--electric); border-color: var(--electric); }

/* ============ STATUS PILL ============ */
.status-pill { padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; white-space: nowrap; display: inline-block; }
.status-paid { background: rgba(34,197,94,.15); color: var(--green); }
.status-pending { background: rgba(245,158,11,.15); color: var(--orange); }
.status-failed { background: rgba(239,68,68,.15); color: var(--red); }
.status-confirmed { background: rgba(59,130,246,.15); color: var(--electric); }
.status-preparing { background: rgba(245,158,11,.15); color: var(--orange); }
.status-transit { background: rgba(34,211,238,.15); color: var(--cyan); }
.status-delivered { background: rgba(34,197,94,.15); color: var(--green); }
.status-inactive { background: rgba(148,163,184,.15); color: var(--text-3); }
.status-purple { background: rgba(139,92,246,.15); color: var(--purple); }
.status-pink { background: rgba(236,72,153,.15); color: var(--pink); }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr); backdrop-filter: blur(20px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; color: var(--text-3); transition: color .2s; position: relative;
}
.nav-item.active { color: var(--electric); }
.nav-item.active::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--grad-primary); border-radius: 0 0 3px 3px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; font-weight: 600; }
.nav-item .badge {
  position: absolute; top: 0; right: calc(50% - 18px); min-width: 16px; height: 16px;
  padding: 0 4px; background: var(--red); color: #fff; border-radius: 8px; font-size: 9px;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* ============ TOGGLE ============ */
.toggle {
  position: relative; width: 44px; height: 24px; background: var(--border);
  border-radius: 12px; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.toggle.on { background: var(--electric); }
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { transform: translateX(20px); }

/* ============ LOADING (BARU — tidak ada di prototype) ============ */
.loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; gap: 12px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--electric);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text { font-size: 13px; color: var(--text-3); font-weight: 600; }

/* ============ RESPONSIVE ============ */
@media (min-width: 768px) {
  .modal { max-width: 600px; }
}

/* ============ MAPS (Phase 11) ============ */
.map-container { width: 100%; min-height: 300px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.map-canvas { width: 100%; height: 100%; }
.map-radius-info { padding: 10px 12px; background: var(--grad-card); border-radius: 10px; font-size: 12px; margin-top: 10px; color: var(--text-2); }
.leaflet-container { font-family: inherit !important; border-radius: 12px; }

/* ============ FOCUS VISIBLE (Accessibility) ============ */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--electric);
  outline-offset: 2px;
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ RESPONSIVE POLISH ============ */
@media (max-width: 360px) {
  .main { padding: 12px; }
  .kpi-grid { gap: 6px; }
  .menu-grid { gap: 8px; }
  .btn { padding: 8px 12px; font-size: 12px; }
  .modal { max-width: 100%; }
}

/* ============ MODAL CENTER FULL-WIDTH MOBILE ============ */
@media (max-width: 640px) {
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 92dvh; }
}

/* ============ AUTH TABS (Phase E) ============ */
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px; text-align: center; font-size: 13px; font-weight: 700; border-radius: 8px; color: var(--text-2); cursor: pointer; transition: all .2s; }
.auth-tab.active { background: var(--surface); color: var(--electric); box-shadow: var(--shadow); }
.auth-tab-content { animation: fadeUp .3s ease; }
.btn-google { width: 100%; padding: 12px; background: #fff; color: var(--text); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; transition: all .2s; }
.btn-google:hover { background: var(--surface-2); transform: translateY(-1px); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-2); }

/* ============ MAPS SEARCH (Phase F) ============ */
.map-search-wrap { display: flex; gap: 8px; margin-bottom: 10px; position: relative; }
.map-search-box { flex: 1; position: relative; }
.map-search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.map-search-box input { width: 100%; padding: 12px 14px 12px 38px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; transition: all .2s; }
.map-search-box input:focus { outline: 0; border-color: var(--electric); background: var(--surface); }
.map-loc-btn { width: 44px; height: 44px; border-radius: 10px; background: var(--grad-primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 12px rgba(37,99,235,.3); transition: all .2s; cursor: pointer; }
.map-loc-btn:hover { transform: scale(1.05); }
.map-loc-btn svg { width: 20px; height: 20px; }
.map-search-results { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 100; max-height: 250px; overflow-y: auto; margin-top: 4px; }
.map-search-item { padding: 10px 12px; font-size: 12px; color: var(--text-2); cursor: pointer; border-bottom: 1px solid var(--border); transition: background .15s; line-height: 1.4; }
.map-search-item:last-child { border-bottom: 0; }
.map-search-item:hover { background: var(--surface-2); color: var(--text); }