/* Brand wordmark. Quicksand (SIL Open Font License), served from this project. */
@font-face {
  font-family: "Quicksand"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/quicksand-latin-400-normal.woff2") format("woff2");
}

/* ── Theme tokens (shared by all pages) ─────────────────────────────── */
/* Dark is the default; light is applied via <html data-theme="light">. */
:root {
  color-scheme: dark;
  --bg:          #000000;
  --surface:     #0b0b0b;
  --surface2:    #151515;
  --surface3:    #222222;
  --agent-bg:    #111111;
  --text:        #ffffff;
  --text-dim:    #9a9a9a;

  --accent:      #39ff14;   /* neon green: buttons, borders, fills */
  --accent-hi:   #7dff5e;   /* hover */
  --accent-text: #39ff14;   /* accent used as text on surfaces */
  --accent-rgb:  57,255,20;
  --on-accent:   #000000;   /* text/icons over accent backgrounds */
  --user-bg:     var(--accent);

  --fg-rgb:      255,255,255; /* for translucent borders/hover overlays */

  --green:       #39ff14;
  --yellow:      #fbbf24;
  --red:         #ff4d4d;
  --blue:        #60a5fa;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #f4f5f4;
  --surface:     #ffffff;
  --surface2:    #eef0ee;
  --surface3:    #e0e3e0;
  --agent-bg:    #ffffff;
  --text:        #0a0a0a;
  --text-dim:    #5c625c;

  --accent:      #39ff14;
  --accent-hi:   #2ee80c;
  --accent-text: #39ff14;
  --accent-rgb:  57,255,20;
  --on-accent:   #000000;

  --fg-rgb:      0,0,0;

  --green:       #39ff14;
  --yellow:      #b45309;
  --red:         #dc2626;
  --blue:        #2563eb;
}

body { transition: background-color .2s, color .2s; }

/* ── Site footer (added by theme.js) ───────────────────────────────── */
.site-footer {
  padding: 18px 16px; text-align: center; font-size: 13px; color: var(--text-dim);
  border-top: 1px solid rgba(var(--fg-rgb),.08); margin-top: auto;
}
/* On short pages the footer stays at the bottom of the window */
body:has(> .site-footer) { min-height: 100dvh; display: flex; flex-direction: column; }
/* Floating pieces (windows, toasts, the guide) keep their own size */
body:has(> .site-footer) > :not(dialog, .toast, .guide) { width: 100%; flex-shrink: 0; }

/* ── Theme toggle button ───────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 10px; cursor: pointer;
  background: rgba(var(--fg-rgb),.06);
  border: 1px solid rgba(var(--fg-rgb),.1);
  color: var(--text);
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--accent-text); border-color: var(--accent); }
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── User menu (top bar: photo, name, logout) ──────────────────────── */
.user-menu {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 4px 3px 3px; border-radius: 99px;
  background: rgba(var(--fg-rgb),.06);
  border: 1px solid rgba(var(--fg-rgb),.1);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; border: 2px solid var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 13px; font-weight: 800;
}
.user-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-logout {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid rgba(var(--fg-rgb),.14); border-radius: 99px;
  color: var(--text-dim); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 4px 10px;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-logout:hover { color: var(--red); border-color: rgba(255,77,77,.35); background: rgba(255,77,77,.08); }
@media (max-width: 700px) {
  .user-name, .btn-logout span { display: none; }
  .btn-logout { padding: 6px; }
}

/* ── App bar (shared top bar: logo left, user right) ───────────────── */
:root { --appbar-h: 60px; }
.app-bar {
  position: sticky; top: 0; z-index: 150;
  height: var(--appbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid rgba(var(--fg-rgb),.08);
  box-shadow: 0 1px 0 rgba(var(--accent-rgb),.12), 0 6px 20px rgba(0,0,0,.18);
}
.app-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; min-width: 0;
}
.app-logo {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  overflow: hidden; box-shadow: 0 0 16px rgba(var(--accent-rgb),.35);
}
.app-logo img { display: block; width: 100%; height: 100%; }
.app-name { font-family: "Quicksand", sans-serif; font-size: 21px; font-weight: 400; letter-spacing: .2em; white-space: nowrap; }
.app-name span { color: var(--accent-text); }
.app-bar-right { display: flex; align-items: center; gap: 10px; }
.app-bar-divider { width: 1px; height: 24px; background: rgba(var(--fg-rgb),.12); }
.app-bar-divider:last-child, .app-bar-divider:has(+ [data-user-slot]:empty) { display: none; }
@media (max-width: 700px) {
  .app-bar { padding: 0 12px; }
  .app-name { font-size: 18px; letter-spacing: .16em; }
}
@media (max-width: 460px) {
  .app-name { display: none; }
}

/* ── Voice dropdown: marks the voice in use ─────────────────────────── */
.voice-item.selected .voice-item-name::after {
  content: " (atual)"; font-weight: 500; color: var(--accent-text);
}
:root[data-theme="light"] .voice-item.selected .voice-item-name::after { color: #0b7a00; }

/* ── Main menu (nav.js, in the app bar of logged-in pages) ──────────── */
.app-tabs {
  display: flex; gap: 4px; padding: 4px; width: fit-content; max-width: 100%;
  background: var(--surface); border: 1px solid rgba(var(--fg-rgb),.08); border-radius: 14px;
}
.app-tab {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-dim); text-decoration: none; white-space: nowrap;
  font-size: 14px; font-weight: 700; line-height: 1.55; padding: 9px 16px; border-radius: 10px;
}
.app-tab:hover { color: var(--text); }
.app-tab[aria-current="page"] { background: var(--accent); color: var(--on-accent, #000); }
.app-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The menu shares the app bar: on laptops the avatar stands in for the e-mail */
@media (max-width: 1660px) {
  .app-bar:has(.app-tabs) .user-name { display: none; }
}
/* Laptops: dropping the icons keeps the menu on the app bar's single line */
@media (max-width: 1480px) {
  .app-tab { padding: 9px 11px; font-size: 13px; }
  .app-tab svg { display: none; }
}
/* Too narrow for one line: the menu takes its own row (pages size themselves from --appbar-h) */
@media (max-width: 1260px) {
  :root:has(.app-tabs) { --appbar-h: 112px; }
  .app-bar:has(.app-tabs) { flex-wrap: wrap; align-content: center; row-gap: 8px; }
  .app-tabs { order: 3; flex: 0 0 100%; }
}
@media (max-width: 860px) {
  .app-tabs { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .app-tabs::-webkit-scrollbar { display: none; }
  .app-tab { flex: 0 0 auto; padding: 9px 12px; font-size: 13px; }
  .app-tab svg { display: none; }
}
@media (max-width: 600px) {
  .app-bar .voice-name-label, .app-bar .btn-voice .chevron { display: none; }
  .app-bar:has(.app-tabs) .app-bar-right { gap: 6px; }
}

/* ── Admin menu link (only rendered for admins) ────────────────────── */
.user-slot { display: inline-flex; align-items: center; gap: 10px; }
.app-nav-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 700; text-decoration: none;
  color: var(--accent-text);
  background: rgba(var(--accent-rgb),.08);
  border: 1px solid rgba(var(--accent-rgb),.25);
  transition: background .15s, border-color .15s;
}
.app-nav-link:hover { background: rgba(var(--accent-rgb),.16); border-color: var(--accent); }
.app-nav-link.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
@media (max-width: 700px) {
  .app-nav-link span { display: none; }
  .app-nav-link { padding: 7px; }
}

/* Inner tabs of a page */
.page-tabs { display: flex; gap: 4px; padding: 4px; width: fit-content; margin-bottom: 24px; background: var(--surface); border: 1px solid rgba(var(--fg-rgb),.08); border-radius: 12px; }
.page-tab { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; font-weight: 700; padding: 8px 18px; border-radius: 8px; }
.page-tab:hover { color: var(--text); }
.page-tab[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.page-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shows up as a typed message nears its limit */
.char-count { align-self: center; flex-shrink: 0; font-size: 12px; color: var(--text-dim); }
.char-count.at-limit { color: var(--red); font-weight: 700; }
