/* ─────────────────────────────────────────────────────────────────
   Lia dashboard — design system in plain CSS (Light theme).
   Tailwind CDN handles utility classes; this file owns component
   classes (.card, .btn-primary, .nav-link, etc.).
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg:          #f7f7f8;   /* page background — soft warm-ish white */
  --bg-elev:     #ffffff;   /* card / surface */
  --bg-card:     rgba(255, 255, 255, 0.85);
  --bg-hover:    #f3f4f6;   /* zinc-100 */
  --bg-mute:     #f4f4f5;   /* zinc-100 */

  /* Borders */
  --border:        #e4e4e7;            /* zinc-200 */
  --border-strong: #d4d4d8;            /* zinc-300 */

  /* Text — strong → faint */
  --text-1: #18181b;   /* zinc-900 */
  --text-2: #27272a;   /* zinc-800 */
  --text-3: #52525b;   /* zinc-600 — secondary */
  --text-4: #71717a;   /* zinc-500 — muted */
  --text-5: #a1a1aa;   /* zinc-400 — placeholder */

  /* Accent (violet) */
  --accent:        #7c3aed;   /* violet-600 — primary */
  --accent-hover:  #6d28d9;   /* violet-700 */
  --accent-light:  #8b5cf6;   /* violet-500 — text on light bg */
  --accent-soft:   rgba(124, 58, 237, 0.08);
  --accent-soft-2: rgba(124, 58, 237, 0.18);

  /* Status hues */
  --emerald:  #059669;
  --amber:    #d97706;
  --rose:     #e11d48;
  --sky:      #0284c7;
  --pink:     #db2777;

  --radius-sm: 0.5rem;
  --radius:    0.875rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  --shadow-sm:   0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow:      0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 1px 2px rgba(124, 58, 237, 0.18), 0 8px 28px -8px rgba(124, 58, 237, 0.40);
}

/* ── Base ───────────────────────────────────────────────────────── */
html { font-feature-settings: "liga" 1, "calt" 1, "kern" 1; }
body {
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.gradient-bg {
  background:
    radial-gradient(ellipse 70% 50% at 90% 0%, rgba(124, 58, 237, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 40% at 10% 100%, rgba(236, 72, 153, 0.04), transparent 60%),
    var(--bg);
}

/* Scrollbars */
::-webkit-scrollbar       { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ── Form controls ──────────────────────────────────────────────── */
input, textarea, select {
  background: var(--bg-elev) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-1) !important;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-5); }

/* override autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--bg-elev) inset !important;
  -webkit-text-fill-color: var(--text-1) !important;
  caret-color: var(--text-1);
}

.input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}
.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 0.375rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 0.625rem 1rem;
  transition: background 150ms, color 150ms, transform 100ms, box-shadow 150ms;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: var(--bg-elev);
  color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-1);
}

.btn-danger {
  background: rgba(225, 29, 72, 0.08);
  color: #be123c;
  border-color: rgba(225, 29, 72, 0.25);
  padding: 0.5rem 0.875rem;
}
.btn-danger:hover { background: rgba(225, 29, 72, 0.14); }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  border-radius: var(--radius-xl);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms, box-shadow 150ms;
}
.card:hover { border-color: var(--border-strong); }
.card-pad { padding: 1.25rem; }
@media (min-width: 640px) {
  .card-pad { padding: 1.5rem; }
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 500;
  border: 1px solid;
  white-space: nowrap;
}
.badge-violet, .badge-brand {
  background: rgba(124, 58, 237, 0.08);
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.20);
}
.badge-emerald {
  background: rgba(5, 150, 105, 0.08);
  color: #047857;
  border-color: rgba(5, 150, 105, 0.22);
}
.badge-amber {
  background: rgba(217, 119, 6, 0.08);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.22);
}
.badge-rose {
  background: rgba(225, 29, 72, 0.08);
  color: #be123c;
  border-color: rgba(225, 29, 72, 0.22);
}
.badge-zinc {
  background: rgba(113, 113, 122, 0.10);
  color: #52525b;
  border-color: rgba(113, 113, 122, 0.24);
}

/* ── Sidebar nav links ──────────────────────────────────────────── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-3);
  transition: background 150ms, color 150ms;
  border: 1px solid transparent;
}
.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent-soft-2);
}

/* ── Tables ─────────────────────────────────────────────────────── */
.table-row {
  border-bottom: 1px solid var(--border);
  transition: background 150ms;
}
.table-row:hover { background: var(--bg-hover); }

/* ── htmx loading indicator ─────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: flex; }
.htmx-request.htmx-indicator { display: flex; }

/* ── Dialog (modal) polish ──────────────────────────────────────── */
dialog {
  background: var(--bg-elev) !important;
  color: var(--text-1) !important;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 56px -12px rgba(15, 23, 42, 0.20);
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.40);
  backdrop-filter: blur(4px);
}

/* ── Utility class kept for templates that already reference it ── */
.shadow-glow { box-shadow: var(--shadow-glow); }

/* ── PWA: app-like feel ─────────────────────────────────────────── */
/* Installed app: no rubber-band page bounce, no grey tap flash, no
   double-tap zoom delay on controls. */
.pwa-standalone body { overscroll-behavior-y: none; }
a, button, [role="button"], .nav-link { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.pwa-standalone .nav-link, .pwa-standalone .bnav-item { -webkit-user-select: none; user-select: none; }

/* Bottom navigation (phones/tablets, < lg). --bnav-h is reserved at the
   bottom of the page so content and the chat composer never sit under it. */
:root { --bnav-h: 0px; }
@media (max-width: 1023.98px) {
  :root { --bnav-h: calc(3.75rem + env(safe-area-inset-bottom)); }
  body { padding-bottom: var(--bnav-h); }
  /* The bar already clears the home indicator. */
  main .pwa-safe-bottom { padding-bottom: 0.75rem; }
}
.bnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: var(--bnav-h);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
@media (min-width: 1024px) { .bnav { display: none; } }
.bnav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  font-size: 0.68rem; font-weight: 600; color: var(--text-4);
  background: none; border: 0; cursor: pointer;
}
.bnav-item svg { width: 1.3rem; height: 1.3rem; }
.bnav-item.active { color: var(--accent); }
.bnav-item:active { transform: scale(0.94); }

/* PWA bars: offline notice (top), update / iOS install sheet (bottom). */
.pwa-bar {
  position: fixed; z-index: 60; inset-inline: 0.75rem;
  bottom: calc(var(--bnav-h) + 0.75rem);
  margin-inline: auto; max-width: 30rem;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-lg);
  background: var(--text-1); color: #fff;
  font-size: 0.85rem; line-height: 1.4;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.35);
  opacity: 0; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}
.pwa-bar > span:first-child { flex: 1; }
.pwa-bar-in { opacity: 1; transform: none; }
.pwa-bar-top {
  top: calc(env(safe-area-inset-top) + 0.5rem); bottom: auto;
  transform: translateY(-12px);
}
.pwa-bar-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; box-shadow: var(--shadow); }
.pwa-bar-sheet { background: var(--bg-elev); color: var(--text-2); border: 1px solid var(--border); }
.pwa-dot { width: 0.5rem; height: 0.5rem; border-radius: 9999px; background: var(--amber); flex: none !important; }
.pwa-ios-body { flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.pwa-ios-body svg { display: inline; vertical-align: -3px; color: var(--sky); }
.pwa-btn, .pwa-btn-ghost {
  flex: none; border-radius: 0.6rem; padding: 0.45rem 0.8rem;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; border: 0;
}
.pwa-btn { background: var(--accent); color: #fff; }
.pwa-btn:hover { background: var(--accent-hover); }
.pwa-btn-ghost { background: transparent; color: var(--text-4); }
.pwa-btn-ghost:hover { color: var(--text-1); }
@media (prefers-reduced-motion: reduce) {
  .pwa-bar { transition: none; }
  .bnav-item:active { transform: none; }
}
