/* ============================================================
   AutoLog — Main CSS Design System
   ============================================================ */

/* ── Google Fonts already loaded via HTML link ── */

/* ── CSS Custom Properties (Tokens) ── */
:root {
  /* Colors */
  --clr-bg:          #0A0A0F;
  --clr-bg-2:        #111118;
  --clr-bg-3:        #1A1A24;
  --clr-surface:     #16161F;
  --clr-surface-2:   #1E1E2A;
  --clr-surface-3:   #252535;
  --clr-border:      rgba(255,255,255,0.08);
  --clr-border-2:    rgba(255,255,255,0.14);

  /* Brand */
  --clr-primary:     #FF6B00;
  --clr-primary-dim: rgba(255,107,0,0.18);
  --clr-primary-glow:rgba(255,107,0,0.35);
  --clr-accent:      #FF8C42;
  --clr-accent-2:    #FFB347;

  /* Semantic */
  --clr-success:     #22C55E;
  --clr-success-dim: rgba(34,197,94,0.15);
  --clr-warning:     #F59E0B;
  --clr-warning-dim: rgba(245,158,11,0.15);
  --clr-danger:      #EF4444;
  --clr-danger-dim:  rgba(239,68,68,0.15);
  --clr-info:        #3B82F6;
  --clr-info-dim:    rgba(59,130,246,0.15);

  /* Text */
  --clr-text:        #F1F1F5;
  --clr-text-2:      #A0A0B8;
  --clr-text-3:      #6B6B85;
  --clr-text-inv:    #0A0A0F;

  /* Typography */
  --font:            'Outfit', system-ui, sans-serif;
  --fs-xs:           0.70rem;
  --fs-sm:           0.80rem;
  --fs-base:         0.925rem;
  --fs-md:           1rem;
  --fs-lg:           1.125rem;
  --fs-xl:           1.25rem;
  --fs-2xl:          1.5rem;
  --fs-3xl:          1.875rem;
  --fs-4xl:          2.25rem;

  /* Spacing */
  --sp-1:   4px;
  --sp-2:   8px;
  --sp-3:   12px;
  --sp-4:   16px;
  --sp-5:   20px;
  --sp-6:   24px;
  --sp-8:   32px;
  --sp-10:  40px;
  --sp-12:  48px;
  --sp-16:  64px;

  /* Radius */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.6);
  --shadow-xl:  0 16px 60px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 20px var(--clr-primary-glow);
  --shadow-glow-sm: 0 0 10px var(--clr-primary-glow);

  /* Layout */
  --nav-h:     64px;
  --topbar-h:  56px;
  --safe-top:  env(safe-area-inset-top, 0px);
  --safe-bot:  env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  overflow: hidden;
  height: 100dvh;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--clr-bg);
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + var(--sp-3)) var(--sp-5) var(--sp-3);
  height: calc(var(--topbar-h) + var(--safe-top));
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.top-bar-left { display: flex; align-items: center; gap: var(--sp-3); }
.top-bar-right { display: flex; align-items: center; gap: var(--sp-2); }

.app-logo { display: flex; align-items: center; gap: var(--sp-2); }
.app-logo-text {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #FF6B00, #FF8C42);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding-bottom: calc(var(--nav-h) + var(--safe-bot) + var(--sp-4));
}

/* Scrollbar */
.page-content::-webkit-scrollbar { width: 0; }

/* ── Bottom Navigation ── */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--sp-2) var(--sp-2) calc(var(--safe-bot) + var(--sp-2));
  height: calc(var(--nav-h) + var(--safe-bot));
  background: var(--clr-bg-2);
  border-top: 1px solid var(--clr-border);
  position: sticky;
  bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--clr-text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
  min-width: 56px;
}

.nav-item .nav-icon {
  width: 22px;
  height: 22px;
  transition: all 0.2s ease;
}

.nav-item.active {
  color: var(--clr-primary);
}

.nav-item.active .nav-icon {
  stroke: var(--clr-primary);
  filter: drop-shadow(0 0 6px var(--clr-primary-glow));
}

.nav-item:active { transform: scale(0.92); }

/* ── Utility Classes ── */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }

/* ── Page Wrapper ── */
.page { padding: var(--sp-5); animation: pageFadeIn 0.3s ease; }
.page-header { margin-bottom: var(--sp-6); }
.page-title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--clr-text);
}
.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--clr-text-3);
  margin-top: var(--sp-1);
}

/* ── Section ── */
.section { margin-bottom: var(--sp-6); }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.section-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--clr-text);
  letter-spacing: -0.3px;
}
.section-action {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--clr-primary);
  letter-spacing: 0.3px;
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--clr-surface-3);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loading-text {
  font-size: var(--fs-sm);
  color: var(--clr-text-2);
  font-weight: 500;
}

/* ── Badge ── */
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--clr-danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--r-full);
  min-width: 16px;
  text-align: center;
  line-height: 14px;
  border: 2px solid var(--clr-bg);
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--clr-border);
  margin: var(--sp-4) 0;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  gap: var(--sp-4);
}

.empty-icon {
  width: 72px;
  height: 72px;
  background: var(--clr-surface-2);
  border-radius: var(--r-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-3);
}

.empty-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--clr-text);
}

.empty-desc {
  font-size: var(--fs-sm);
  color: var(--clr-text-3);
  line-height: 1.5;
  max-width: 260px;
}

/* ── Gradient Text ── */
.gradient-text {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Scrollable Row ── */
.scroll-row {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  -webkit-overflow-scrolling: touch;
}
.scroll-row::-webkit-scrollbar { display: none; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-3); }
