/* ============================================================
   VanGo v2 — Main Stylesheet
   Clean, professional, mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

/* ── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --accent:   #00C896;
  --accent2:  #00A87D;
  --red:      #FF4757;
  --orange:   #FF6B35;
  --blue:     #3B82F6;
  --yellow:   #F59E0B;
  --purple:   #8B5CF6;

  --bg:       #F8FAFC;
  --bg2:      #FFFFFF;
  --bg3:      #F1F5F9;
  --bg4:      #E2E8F0;

  --text:     #0F172A;
  --text2:    #475569;
  --text3:    #94A3B8;

  --border:   #E2E8F0;
  --shadow:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow2:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow3:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);

  --radius:   12px;
  --radius2:  8px;
  --font:     'Sora', sans-serif;

  --nav-h:    64px;
  --top-h:    56px;
}

[data-theme="dark"] {
  --bg:    #0A0F1A;
  --bg2:   #111827;
  --bg3:   #1E293B;
  --bg4:   #334155;
  --text:  #F1F5F9;
  --text2: #94A3B8;
  --text3: #64748B;
  --border:#1E293B;
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── TYPOGRAPHY ─────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 700; color: var(--text); }
h2 { font-size: 18px; font-weight: 600; color: var(--text); }
h3 { font-size: 15px; font-weight: 600; color: var(--text); }

/* ── LAYOUT ─────────────────────────────────────────────────── */
#app { display: none; }

.page {
  padding: calc(var(--top-h) + 12px) 16px calc(var(--nav-h) + 16px);
  min-height: 100dvh;
}

.page-full {
  padding: 0;
  min-height: 100dvh;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.topbar-right { justify-content: flex-end; }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:active { background: var(--bg3); }
.icon-btn .material-icons { font-size: 22px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

/* ── BOTTOM NAV ─────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
  padding: 6px 0;
  cursor: pointer;
}

.nav-item.active { color: var(--accent); }
.nav-item .material-icons { font-size: 22px; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 10px; }

/* ── LIST ITEMS ─────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.list-item:last-child { border-bottom: none; }

.list-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-avatar.red    { background: linear-gradient(135deg, #FF4757, #FF6B81); }
.list-avatar.blue   { background: linear-gradient(135deg, #3B82F6, #60A5FA); }
.list-avatar.purple { background: linear-gradient(135deg, #8B5CF6, #A78BFA); }
.list-avatar.orange { background: linear-gradient(135deg, #FF6B35, #FF8C61); }

.list-content { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 600; color: var(--text); }
.list-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

.list-amount { font-size: 15px; font-weight: 700; color: var(--text); text-align: right; }
.list-amount.red { color: var(--red); }
.list-amount.green { color: var(--accent); }

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

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

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.stat-value.accent { color: var(--accent); }
.stat-value.red    { color: var(--red); }
.stat-value.blue   { color: var(--blue); }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:active { background: var(--bg4); }

.btn-danger {
  background: rgba(255,71,87,0.1);
  color: var(--red);
  border: 1px solid rgba(255,71,87,0.2);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(0,200,150,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
}

.fab:active { transform: scale(0.92); box-shadow: 0 2px 8px rgba(0,200,150,0.3); }
.fab .material-icons { font-size: 26px; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  outline: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: var(--bg2);
}

.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 8L0 0h12z' fill='%2394A3B8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── STATUS BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-paid    { background: rgba(0,200,150,0.12); color: var(--accent2); }
.badge-unpaid  { background: rgba(255,71,87,0.12); color: var(--red); }
.badge-partial { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-draft   { background: rgba(148,163,184,0.15); color: var(--text3); }

/* ── SECTION HEADERS ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ── TOAST ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--top-h) + 8px);
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.25s ease;
  pointer-events: auto;
}

.toast.success { background: var(--accent); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--orange); }
.toast.info    { background: var(--blue); }
.toast .material-icons { font-size: 18px; }

@keyframes slideDown {
  from { opacity:0; transform: translateY(-12px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ── LOADING ────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(2px);
}

.loading-box {
  background: var(--bg2);
  border-radius: 16px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.inline-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-handle {
  width: 40px; height: 4px;
  background: var(--bg4);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 10px;
}

.empty-state .material-icons {
  font-size: 48px;
  color: var(--bg4);
}

.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text2); }
.empty-state-sub   { font-size: 13px; color: var(--text3); }

/* ── FILTER TABS ────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 10px;
  scrollbar-width: none;
  margin-bottom: 4px;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ── SEARCH ─────────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  transition: border-color 0.15s;
}

.search-box:focus-within { border-color: var(--accent); background: var(--bg2); }
.search-box .material-icons { font-size: 20px; color: var(--text3); }
.search-box input { flex: 1; background: none; border: none; outline: none; font-size: 14px; color: var(--text); font-family: var(--font); }

/* ── INVOICE ITEMS TABLE ────────────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.items-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
.items-table td:last-child, .items-table th:last-child { text-align: right; }
.items-table tr:last-child td { border-bottom: none; }

/* ── TOTAL ROW ──────────────────────────────────────────────── */
.totals-section { border-top: 2px solid var(--border); padding-top: 12px; margin-top: 4px; }
.totals-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; color: var(--text2); }
.totals-row.total { font-size: 17px; font-weight: 800; color: var(--text); padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.totals-row.balance { font-size: 15px; font-weight: 700; color: var(--red); }

/* ── SYNC STATUS ────────────────────────────────────────────── */
#sync-btn .material-icons { font-size: 20px; transition: color 0.3s; }
#sync-btn.online .material-icons  { color: var(--accent); }
#sync-btn.offline .material-icons { color: var(--red); }
#sync-btn.syncing .material-icons { color: var(--yellow); animation: spin 1s linear infinite; }

/* ── SPLASH ─────────────────────────────────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s, transform 0.5s;
}

.splash.hide { opacity: 0; transform: scale(1.04); pointer-events: none; }

.splash-logo {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(0,200,150,0.35);
}

.splash-title { font-size: 36px; font-weight: 800; letter-spacing: -1px; text-align: center; }
.splash-sub { font-size: 13px; color: var(--text3); text-align: center; margin-top: 4px; letter-spacing: 2px; text-transform: uppercase; }
.splash-bar { width: 120px; height: 3px; background: var(--bg3); border-radius: 2px; margin: 24px auto 0; overflow: hidden; }
.splash-progress { height: 100%; background: var(--accent); border-radius: 2px; animation: loading 1.5s ease-in-out infinite; }

@keyframes loading {
  0%   { width: 0%;   margin-left: 0%; }
  50%  { width: 70%;  margin-left: 15%; }
  100% { width: 0%;   margin-left: 100%; }
}

/* ── AUTH ───────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-top: 14px; }
.auth-logo p { font-size: 13px; color: var(--text3); letter-spacing: 2px; text-transform: uppercase; }

.auth-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow2);
}

.auth-form h2 { margin-bottom: 4px; }
.auth-form p  { font-size: 13px; color: var(--text3); margin-bottom: 22px; }

/* ── UTILS ──────────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-accent { color: var(--accent); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text3); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 11px; }
.font-bold   { font-weight: 700; }

.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── SHIFT GROUP ────────────────────────────────────────────── */
.shift-group-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 16px 0 6px;
  display: flex;
  justify-content: space-between;
}

/* ── PASSWORD TOGGLE ────────────────────────────────────────── */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px; }
.pass-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 17px; }
}
