/* Nova Chat — Phase 1 (auth). ChatGPT-inspired: neutral surfaces, green accent, generous spacing. */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --surface: #ffffff;
  --text: #0d0d0d;
  --muted: #6e6e80;
  --border: #d9d9e3;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --accent-contrast: #ffffff;
  --danger: #d92d20;
  --danger-bg: #fef3f2;
  --success: #067647;
  --success-bg: #ecfdf3;
  --sidebar-bg: #f9f9f9;
  --hover: rgba(0,0,0,.05);
  --active: rgba(0,0,0,.09);
  --user-bubble: #f0f0f2;
  --scrim: rgba(0,0,0,.4);
  color-scheme: light;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 30px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* Dark mode: follows the OS unless the user picked a theme (theme.js sets data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121;
    --bg-soft: #171717;
    --surface: #2a2a2a;
    --text: #ececec;
    --muted: #a1a1aa;
    --border: #404040;
    --accent: #19c37d;
    --accent-hover: #15a86a;
    --accent-contrast: #0d0d0d;
    --danger: #ff7b72;
    --danger-bg: #3a1c1c;
    --success: #4ade80;
    --success-bg: #14301f;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
    --sidebar-bg: #171717;
    --hover: rgba(255,255,255,.07);
    --active: rgba(255,255,255,.12);
    --user-bubble: #303030;
    --scrim: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #212121;
    --bg-soft: #171717;
    --surface: #2a2a2a;
    --text: #ececec;
    --muted: #a1a1aa;
    --border: #404040;
    --accent: #19c37d;
    --accent-hover: #15a86a;
    --accent-contrast: #0d0d0d;
    --danger: #ff7b72;
    --danger-bg: #3a1c1c;
    --success: #4ade80;
    --success-bg: #14301f;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
    --sidebar-bg: #171717;
    --hover: rgba(255,255,255,.07);
    --active: rgba(255,255,255,.12);
    --user-bubble: #303030;
    --scrim: rgba(0,0,0,.6);
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Auth layout ---------- */
.auth-page { background: var(--bg-soft); min-height: 100vh; min-height: 100dvh; }
.auth-shell {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow);
}
.brand { display: flex; justify-content: center; margin-bottom: 16px; }
.brand img { display: block; border-radius: 12px; }
.auth-title { margin: 0 0 4px; text-align: center; font-size: 1.65rem; font-weight: 600; letter-spacing: -.01em; }
.auth-subtitle { margin: 0 0 24px; text-align: center; color: var(--muted); font-size: .95rem; }
.auth-title:not(:has(+ .auth-subtitle)) { margin-bottom: 24px; }
.auth-switch { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: .95rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.field label { font-size: .875rem; font-weight: 500; }
.link-small { font-size: .8125rem; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 48px; padding: 0 14px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap input[type="password"], .input-wrap input.is-revealed { padding-right: 48px; }
.input-wrap input::placeholder { color: var(--muted); opacity: .8; }
.input-wrap input:hover { border-color: var(--muted); }
.input-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field.has-error input { border-color: var(--danger); }
.field.has-error input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.field-hint { margin: 6px 0 0; font-size: .8125rem; color: var(--muted); }
.field-error { margin: 6px 0 0; font-size: .8125rem; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }

.toggle-password {
  position: absolute; top: 0; right: 0; width: 48px; height: 48px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0;
}
.toggle-password:hover { color: var(--text); }
.toggle-password .eye-closed { display: none; }
.toggle-password[aria-pressed="true"] .eye-open { display: none; }
.toggle-password[aria-pressed="true"] .eye-closed { display: block; }

/* Password strength meter */
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.strength span { height: 4px; border-radius: 2px; background: var(--border); transition: background .2s; }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] span:nth-child(-n+2) { background: #f79009; }
.strength[data-level="3"] span:nth-child(-n+3) { background: #84cc16; }
.strength[data-level="4"] span { background: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 48px;
  padding: 0 18px; font: inherit; font-weight: 500; border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-small { width: auto; height: 36px; font-size: .875rem; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn.is-loading .btn-label::after {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: .75rem; letter-spacing: .08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Alerts & toast ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: .9rem; margin-bottom: 16px; border: 1px solid; }
.alert-error { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-success { color: var(--success); background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .875rem;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dashboard placeholder ---------- */
.app-page { background: var(--bg); min-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }
.topbar-brand:hover { text-decoration: none; }
.welcome { max-width: 640px; margin: 14vh auto 0; padding: 0 20px; text-align: center; }
.welcome h1 { font-size: 2rem; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .auth-page { background: var(--surface); }
  .auth-shell { align-items: flex-start; padding: 24px 20px; }
  .auth-card { border: 0; box-shadow: none; padding: 16px 0; max-width: none; }
  .input-wrap input, .btn { font-size: 16px; } /* prevents iOS zoom on focus */
}
@media (min-width: 900px) {
  .auth-shell { background: radial-gradient(900px 400px at 50% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%); }
  .auth-card { max-width: 420px; padding: 40px 36px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } }

/* Site logo (can be replaced in Admin > Website Settings): never stretch a non-square picture */
.site-logo { object-fit: contain; }
