/* ═══════════════════════════════════════════════════════════════
   APG LIMOS — MAIN APP STYLES
═══════════════════════════════════════════════════════════════ */

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ─── SCROLLBAR ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ─── HEADER ─────────────────────────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background 0.3s;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer;
  padding: 0; flex-shrink: 0;
}

.logo-text-group { display: flex; flex-direction: column; text-align: left; }

.logo-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); line-height: 1;
}

.logo-tagline {
  font-size: 0.52rem; font-weight: 400;
  letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 3px;
}

.nav-links { display: flex; gap: 0.25rem; margin-left: auto; }

.nav-link {
  background: none; border: none; cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.5rem 0.85rem; border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--gold); background: var(--gold-subtle); }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

/* Theme toggle */
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--text-secondary);
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--gold-border); color: var(--gold); }
/* Three-state icon visibility:
   auto  → show the auto (circle) icon
   dark  → show the sun (switch to light)
   light → show the moon (switch to dark) */
.theme-icon-auto,
.theme-icon-dark,
.theme-icon-light { display: none; }

[data-theme-source="auto"]  .theme-icon-auto  { display: inline-flex; align-items: center; }
[data-theme-source="dark"]  .theme-icon-dark  { display: inline; }
[data-theme-source="light"] .theme-icon-light { display: inline; }

/* Smooth theme transition — only on color properties, not layout */
*, *::before, *::after {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
/* Exclude elements where transitions cause flicker */
input, select, textarea, button, a { transition: none; }
.btn-gold, .btn-ghost, .btn-outline, .nav-link, .theme-toggle,
.vehicle-card, .fleet-card, .tab-btn, .admin-nav-item {
  transition: all 0.2s;
}

/* Buttons */
.btn-outline {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-secondary); border-radius: 3px; cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--gold-border); color: var(--gold); }

.btn-gold {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  padding: 0.6rem 1.4rem;
  background: var(--gold); border: none; border-radius: 3px;
  color: var(--bg-base); cursor: pointer;
  transition: all 0.2s; position: relative; overflow: hidden;
}
.btn-gold:hover { background: var(--gold-light); transform: translateY(-1px); box-shadow: var(--shadow-gold); }
.btn-gold:active { transform: translateY(0); }

.btn-ghost {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  background: transparent; border: 1px solid var(--gold-border);
  color: var(--gold); border-radius: 3px; cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { background: var(--gold-subtle); border-color: var(--gold-border-hover); }

.btn-danger {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.5rem 1rem; background: var(--color-error-bg);
  border: 1px solid var(--color-error); color: var(--color-error);
  border-radius: 3px; cursor: pointer; transition: all 0.2s;
  font-family: 'Montserrat', sans-serif;
}
.btn-danger:hover { background: var(--color-error); color: white; }

/* Hamburger */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.hamburger span { display: block; width: 22px; height: 1.5px; background: var(--text-primary); transition: all 0.3s; }

/* Mobile menu */
.mobile-menu {
  display: none; flex-direction: column; gap: 0.5rem;
  padding: 1rem 2rem 1.5rem; border-top: 1px solid var(--border);
  background: var(--bg-overlay);
}

/* ─── MAIN & PAGES ───────────────────────────────────────────────────────── */
#main { padding-top: 70px; min-height: 100vh; }

.page { display: none; }
.page.active { display: block; }

/* ─── SECTION WRAPPER ────────────────────────────────────────────────────── */
.section { max-width: 1280px; margin: 0 auto; padding: 5rem 2rem; }
.section-sm { max-width: 860px; margin: 0 auto; padding: 4rem 2rem; }

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 0.62rem; font-weight: 500;
  letter-spacing: 0.45em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 1rem; display: block;
}

.display-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 300; line-height: 1.08;
  letter-spacing: 0.02em; color: var(--text-primary);
}
.display-title em { font-style: italic; color: var(--gold); }

.section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 300; letter-spacing: 0.04em;
  color: var(--text-primary); margin-bottom: 0.5rem;
}

.body-text {
  font-size: 0.82rem; font-weight: 300;
  letter-spacing: 0.06em; color: var(--text-secondary);
  line-height: 1.8;
}

/* ─── DIVIDER ─────────────────────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 1rem;
  color: var(--text-muted); font-size: 0.6rem;
  letter-spacing: 0.25em; text-transform: uppercase;
  margin: 1.5rem 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ─── FORM ELEMENTS ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }

.field label {
  font-size: 0.58rem; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.83rem; font-weight: 300;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--gold-dim); background: var(--bg-elevated); }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); font-weight: 300; }
.field select option { background: var(--bg-card); color: var(--text-primary); }
.field textarea { resize: vertical; min-height: 80px; }

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: var(--shadow-md);
  overflow: hidden; max-height: 220px; overflow-y: auto;
}

.autocomplete-item {
  padding: 0.7rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-elevated); }
.autocomplete-item .place-main { font-size: 0.82rem; color: var(--text-primary); }
.autocomplete-item .place-secondary { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ─── GRID HELPERS ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 2px;
  font-size: 0.58rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
}
.badge-gold { background: var(--gold-subtle); border: 1px solid var(--gold-border); color: var(--gold); }
.badge-success { background: var(--color-success-bg); border: 1px solid var(--color-success); color: var(--color-success); }
.badge-error { background: var(--color-error-bg); border: 1px solid var(--color-error); color: var(--color-error); }
.badge-info { background: var(--color-info-bg); border: 1px solid var(--color-info); color: var(--color-info); }
.badge-stripe { background: var(--stripe-bg); border: 1px solid var(--stripe-border); color: var(--stripe-color); }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toastContainer {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 999;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-md);
  font-size: 0.78rem;
  min-width: 260px; max-width: 380px;
  animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-error); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

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

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 2.5rem;
  max-width: 520px; width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}

/* ─── LOADING ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 3rem; color: var(--text-muted);
  font-size: 0.78rem; letter-spacing: 0.1em;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links, .header-actions .btn-outline { display: none; }
  .hamburger { display: flex; }
  .mobile-menu.open { display: flex; }
  .header-actions { gap: 0.5rem; }
  .header-actions .btn-gold { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .section { padding: 3rem 1.25rem; }
}

@media (max-width: 480px) {
  .header-inner { padding: 0 1.25rem; }
}
