/* ============================================================
   VillaBook — Shared Design System
   Warm, earthy, editorial tone. No blue. Light + dark mode.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f6f3ec;
  --bg-soft: #efe9dc;
  --surface: #ffffff;
  --surface-2: #faf7f0;
  --border: #e4dcc8;
  --border-strong: #d5c9ac;
  --text: #2a251d;
  --text-muted: #766c5c;
  --text-faint: #9c9280;

  --accent: #7c6a3f;
  --accent-strong: #5f5030;
  --accent-soft: #ece3cd;
  --accent-contrast: #fffdf8;

  --clay: #b3572f;
  --clay-soft: #f4ded1;
  --moss: #4c6b46;
  --moss-soft: #dfe9d8;
  --wine: #8c3b3b;
  --wine-soft: #f1dcd8;
  --amber: #a97a26;
  --amber-soft: #f4e6c8;

  --shadow-sm: 0 1px 2px rgba(42, 37, 29, 0.06);
  --shadow-md: 0 6px 20px rgba(42, 37, 29, 0.08);
  --shadow-lg: 0 16px 48px rgba(42, 37, 29, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', -apple-system, sans-serif;

  /* ---- Glass / motion tokens ---- */
  --glass-bg: color-mix(in srgb, var(--surface) 72%, transparent);
  --glass-bg-strong: color-mix(in srgb, var(--surface) 88%, transparent);
  --glass-border: color-mix(in srgb, var(--border-strong) 60%, transparent);
  --glass-blur: 16px;
  --glass-blur-strong: 24px;
  --overlay-bg: color-mix(in srgb, var(--text) 38%, transparent);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast: 160ms;
  --dur-base: 280ms;
  --dur-slow: 620ms;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --bg-soft: #1d1912;
  --surface: #211d16;
  --surface-2: #262019;
  --border: #362f22;
  --border-strong: #47402e;
  --text: #ede6d6;
  --text-muted: #b1a68e;
  --text-faint: #877c65;

  --accent: #d8bd82;
  --accent-strong: #ecd9a8;
  --accent-soft: #332a19;
  --accent-contrast: #211d16;

  --clay: #e08a5c;
  --clay-soft: #3a2620;
  --moss: #8fb384;
  --moss-soft: #223122;
  --wine: #d98787;
  --wine-soft: #392222;
  --amber: #e0b45c;
  --amber-soft: #392c18;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; letter-spacing: -0.01em; color: var(--text); }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Layout shells ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(155deg, var(--accent), var(--clay));
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-contrast); font-family: var(--font-display); font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding: 0 10px; margin-bottom: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 13.5px;
  cursor: pointer; margin-bottom: 2px; transition: all .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-sub { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }
.content { padding: 28px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 6px; cursor: pointer;
  width: 56px; height: 30px; position: relative;
}
.theme-toggle .dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); position: absolute; left: 4px; top: 4px;
  transition: transform .25s var(--ease-spring);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-contrast);
}
.theme-toggle .dot svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.2; }
[data-theme="dark"] .theme-toggle .dot { transform: translateX(26px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 13.5px; cursor: pointer; transition: all .15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--accent-strong); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--wine); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 700; margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.stat-card .label { font-size: 12.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-display); font-size: 30px; font-weight: 600; }
.stat-card .delta { font-size: 12.5px; margin-top: 6px; font-weight: 600; }
.delta.up { color: var(--moss); }
.delta.down { color: var(--wine); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 12px 16px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); font-weight: 700; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-moss { background: var(--moss-soft); color: var(--moss); }
.badge-clay { background: var(--clay-soft); color: var(--clay); }
.badge-wine { background: var(--wine-soft); color: var(--wine); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 13.5px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 17, 12, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Misc ---------- */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12.5px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.pill-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 999px; border: 1px solid var(--border); width: fit-content; }
.pill-tab { padding: 7px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--text-muted); }
.pill-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .2s ease;
}
.toast.error { background: var(--wine); color: #fff; }
.toast.success { background: var(--moss); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 90; transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .content { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Glassmorphism, motion, icons, skeletons — shared across pages
   ============================================================ */

/* ---------- Icons (inline SVG, replaces emoji) ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 0; }
.icon svg { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-link .icon svg { width: 17px; height: 17px; }
.check-ic svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.4; }

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}
.glass-strong {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface); }
  .glass-strong { background: var(--surface); }
}

.topbar {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  transition: box-shadow var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.topbar.scrolled { box-shadow: var(--shadow-md); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--surface); }
}

.sidebar {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar { background: var(--surface); }
}

.modal-backdrop {
  background: var(--overlay-bg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: overlay-in var(--dur-base) var(--ease-out);
}
.modal {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  backdrop-filter: blur(var(--glass-blur-strong));
  animation: modal-in var(--dur-base) var(--ease-spring);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .modal-backdrop { background: rgba(20, 17, 12, .55); }
  .modal { background: var(--surface); }
}

/* ---------- Entrance / reveal motion ---------- */
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes float-blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(3%, -4%) scale(1.05); }
  66% { transform: translate(-3%, 3%) scale(.97); }
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
.reveal.in-view { opacity: 1; transform: translateY(0); }

.entrance { animation: fade-up var(--dur-slow) var(--ease-out) both; }
.entrance-fast { animation: fade-up var(--dur-base) var(--ease-out) both; }

.hover-lift { transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.hover-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.btn { transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ---------- Skeleton loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; margin-bottom: 8px; border-radius: 6px; }
.skeleton-card { height: 90px; border-radius: var(--radius-md); }
.skeleton-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ---------- Rating / trust badge ---------- */
.rating-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--moss-soft); color: var(--moss); border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; }
.rating-pill .icon svg { width: 12px; height: 12px; }
.trust-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.trust-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.trust-item .icon { color: var(--accent); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
