/* Atendimentos · Julia — painel interno. Tema automático (claro/escuro).
   Caráter: Bricolage Grotesque (display) + Public Sans (texto), 1 verde de acento.
   Rigor: foco visível, hit targets >=24px, tabular-nums, reduced-motion. */

:root {
  color-scheme: light dark;

  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1b1a17;
  --muted: #74706a;
  --border: rgba(27, 26, 23, 0.10);
  --border-strong: rgba(27, 26, 23, 0.18);

  --accent: #0f7a52;       /* verde Julia */
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --bubble-them: #ffffff;
  --bubble-them-text: #1b1a17;

  --warn: #b45309;         /* fila / pendência */
  --warn-soft: #fbeede;

  --shadow-1: 0 1px 2px rgba(27, 26, 23, 0.06), 0 1px 1px rgba(27, 26, 23, 0.04);
  --shadow-2: 0 6px 20px rgba(27, 26, 23, 0.10), 0 2px 6px rgba(27, 26, 23, 0.06);

  --radius: 14px;
  --radius-sm: 9px;
  --font-display: "Bricolage Grotesque", ui-sans-serif, sans-serif;
  --font-body: "Public Sans", ui-sans-serif, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1310;
    --surface: #171c18;
    --surface-2: #1f251f;
    --text: #e9e7e0;
    --muted: #9aa097;
    --border: rgba(233, 231, 224, 0.10);
    --border-strong: rgba(233, 231, 224, 0.16);

    --accent: #2fae7a;
    --accent-ink: #07140d;
    --accent-soft: #16271e;
    --bubble-them: #20261f;
    --bubble-them-text: #e9e7e0;

    --warn: #e6a04b;
    --warn-soft: #2a2114;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 26px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* Foco visível consistente (guideline) */
:where(button, input, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Botões ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  min-height: 38px;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--text); border-color: var(--text); }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 30px 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 27px; letter-spacing: -0.02em;
  margin: 0; line-height: 1;
}
.login-title span { color: var(--accent); margin: 0 4px; }
.login-sub { margin: -6px 0 8px; color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.login-error { margin: 0; color: #c0392b; font-size: 13px; }
@media (prefers-color-scheme: dark) { .login-error { color: #f0917f; } }

input[type="password"], input[type="search"], input[type="text"] {
  font: inherit;
  font-size: 16px; /* >=16px evita zoom no iOS (guideline) */
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input::placeholder { color: var(--muted); }

/* ---------- App shell ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-dot { color: var(--accent); margin: 0 5px; }

.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.sidebar-tools {
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.search { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }

.fila-toggle {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer; user-select: none;
  min-height: 24px; font-size: 13.5px; color: var(--muted);
}
.fila-toggle input { width: 17px; height: 17px; accent-color: var(--warn); cursor: pointer; }
.fila-toggle-text { display: inline-flex; align-items: center; gap: 7px; }
.fila-badge {
  font-variant-numeric: tabular-nums;
  background: var(--warn); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
}

.lista { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  align-items: baseline;
  padding: 9px 11px; border-radius: var(--radius-sm);
  cursor: pointer;
  content-visibility: auto;          /* virtualização barata p/ 151 itens */
  contain-intrinsic-size: 0 56px;
  transition: background-color .12s ease;
}
.item:hover { background: var(--surface-2); }
.item[aria-selected="true"] { background: var(--accent-soft); }
.item.is-fila {
  border-left: 3px solid var(--warn);
  padding-left: 8px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warn) 26%, transparent) 0%,
    color-mix(in srgb, var(--warn) 10%, transparent) 38%,
    transparent 82%);
}
.item.is-fila:hover {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warn) 38%, transparent) 0%,
    color-mix(in srgb, var(--warn) 14%, transparent) 40%,
    transparent 84%);
}
.item.is-fila[aria-selected="true"] {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warn) 34%, transparent) 0%,
    var(--accent-soft) 92%);
}
.item.is-fila .item-nome { color: var(--warn); font-weight: 700; }
.item-nome {
  grid-column: 1; font-weight: 600; font-size: 14.5px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-time { grid-column: 2; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-sub {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); min-width: 0;
}
.item-sub .item-vaga { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-fila-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }

/* ---------- Badges de etapa ---------- */
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.etapa-triagem { background: #e7eefb; color: #2b5fb3; border-color: transparent; }
.badge.etapa-aprovado, .badge.etapa-entrevista_agendada, .badge.etapa-entrevista_agendada2 { background: #e3f1ea; color: #0f7a52; border-color: transparent; }
.badge.etapa-reprovado, .badge.etapa-eliminado, .badge.etapa-vaga_recusada { background: #f8e5e2; color: #b0392b; border-color: transparent; }
.badge.etapa-aguardando_score, .badge.etapa-agendamento, .badge.etapa-reagendando, .badge.etapa-score_falhou { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.etapa-triagem { background: #1a2740; color: #8fb4f2; }
  .badge.etapa-reprovado, .badge.etapa-eliminado, .badge.etapa-vaga_recusada { background: #36211d; color: #f0917f; }
}

/* ---------- Chat ---------- */
.chat { min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-placeholder { flex: 1; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.chat-placeholder-art { font-size: 40px; opacity: .8; }

.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-header {
  padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 4px;
}
.chat-header-main { display: flex; align-items: center; gap: 10px; }
.chat-nome { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.chat-fila { font-size: 11px; font-weight: 700; color: #fff; background: var(--warn); padding: 2px 8px; border-radius: 999px; }
.chat-header-meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.chat-vaga { overflow: hidden; text-overflow: ellipsis; }
.chat-tel { font-variant-numeric: tabular-nums; }
.chat-fila-motivo {
  margin: 10px 18px 0; padding: 9px 12px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-sm); font-size: 13px;
}

.mensagens {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px clamp(14px, 6vw, 64px);
  display: flex; flex-direction: column; gap: 7px;
}
.bubble {
  max-width: min(72ch, 76%);
  padding: 8px 12px; border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  font-size: 14.5px;
}
.bubble.from-candidate {
  align-self: flex-start;
  background: var(--bubble-them); color: var(--bubble-them-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble.from-julia {
  align-self: flex-end;
  background: var(--accent); color: var(--accent-ink);
  border-bottom-right-radius: 4px;
}
.bubble.from-julia.by-human { background: color-mix(in srgb, var(--accent) 78%, #6b4d12); }
.bubble .by-human-tag { display: block; font-size: 10.5px; opacity: .85; margin-bottom: 2px; font-weight: 600; }

.empty, .chat-error { padding: 20px; color: var(--muted); font-size: 13.5px; text-align: center; }
.chat-error { color: #b0392b; }
@media (prefers-color-scheme: dark) { .chat-error { color: #f0917f; } }

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .app[data-view="chat"] .sidebar { display: none; }
  .app:not([data-view="chat"]) .chat { display: none; }
}

/* ---------- Motion ---------- */
/* só anima bolhas NOVAS (append no polling) — não re-anima a conversa toda */
.bubble.is-new { animation: rise .18s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
