/* ============================================================
   ConcurseIA — Design System Components (Fase 1)
   Port vanilla dos componentes React de
   COMPONENTES-PRONTOS-COPIAR-COLAR.md. Zero dependências.
   Todos consomem os tokens --c-* de _variables.css, então
   funcionam em dark e light automaticamente.
   ============================================================ */

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes cia-shimmer { 100% { transform: translateX(100%); } }
@keyframes cia-spin    { 100% { transform: rotate(360deg); } }

/* =====================================================================
   1) Magic Card — spotlight dourado seguindo o mouse (hover)
   JS seta --mx/--my (px) em mousemove.
   ===================================================================== */
.magic-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-6);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  background: var(--c-bg-elevated);
  transition: border-color .2s ease;
}
.magic-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .3s ease;
  background: radial-gradient(
    220px circle at var(--mx, 50%) var(--my, 50%),
    rgba(202, 138, 4, 0.18),
    transparent 70%
  );
  pointer-events: none;
}
.magic-card:hover::before { opacity: 1; }
.magic-card:hover { border-color: rgba(202, 138, 4, 0.45); }
.magic-card > * { position: relative; z-index: 1; }

/* =====================================================================
   2) Shimmer Button — botão ouro com brilho deslizante
   ===================================================================== */
.shimmer-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  overflow: hidden;
  padding: 12px 24px;
  font-weight: 600;
  color: #0A0A0A;
  background: var(--c-accent-600);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-gold);
  transition: transform .15s ease, box-shadow .2s ease;
}
.shimmer-btn:hover  { transform: scale(1.04); box-shadow: var(--shadow-gold-lg); }
.shimmer-btn:active { transform: scale(0.97); }
.shimmer-btn:focus-visible {
  outline: 2px solid var(--c-accent-400);
  outline-offset: 2px;
}
.shimmer-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.30), transparent);
  animation: cia-shimmer 2.5s infinite;
  pointer-events: none;
}
.shimmer-btn > * { position: relative; z-index: 1; }

/* =====================================================================
   3) Bento Grid — grid responsivo de cards
   ===================================================================== */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  grid-auto-rows: minmax(160px, auto);
}
@media (min-width: 640px)  { .bento-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .bento-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .bento-grid { grid-template-columns: repeat(4, 1fr); } }

.bento-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  background: var(--c-bg-elevated);
  transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}
.bento-item:hover {
  border-color: rgba(202, 138, 4, 0.45);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}
.bento-item__title  { margin-top: var(--space-3); font-weight: 700; color: var(--c-text); }
.bento-item__desc   { margin-top: var(--space-1); font-size: 0.8rem; color: var(--c-text2); }
.bento-item--wide   { grid-column: span 2; }
@media (max-width: 639px) { .bento-item--wide { grid-column: span 1; } }

/* =====================================================================
   4) Number Ticker — valor animado (JS controla o número)
   ===================================================================== */
.number-ticker { font-variant-numeric: tabular-nums; }

/* =====================================================================
   5) Animated Circular Progress — anel SVG com gradiente ouro
   JS seta --dash-offset; transição anima o preenchimento.
   ===================================================================== */
.circular-progress { display: inline-flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.circular-progress svg { transform: rotate(-90deg); }
.circular-progress__track {
  stroke: var(--c-bg-subtle);
  fill: none;
}
.circular-progress__bar {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset .8s cubic-bezier(0.22, 1, 0.36, 1);
}
.circular-progress__value { font-size: 1.25rem; font-weight: 700; color: var(--c-accent-600); }
.circular-progress__label { font-size: 0.85rem; color: var(--c-text2); }

/* =====================================================================
   6) Blur Fade — entra com fade + blur ao aparecer no viewport
   JS (IntersectionObserver) adiciona .is-visible.
   ===================================================================== */
[data-theme] .blur-fade {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(6px);
  transition: opacity .4s ease, transform .4s ease, filter .4s ease;
  transition-delay: var(--bf-delay, 0s);
}
.blur-fade.is-visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}
@media (prefers-reduced-motion: reduce) {
  .blur-fade { opacity: 1; transform: none; filter: none; transition: none; }
  .shimmer-btn::after { animation: none; }
}

/* ============================================================
   FASE 2 — Componentes de interação e formulário
   Mesmo padrão: tokens --c-*, declarativo via data-*, zero deps.
   ============================================================ */
@keyframes cia-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Nota: botões (.btn/.btn-primary…), inputs globais, .card, .upload-zone e
   o chat (.chat-*/.msg-bubble) já existem em style.css — reutilizamos.
   A Fase 2 só adiciona o que faltava: .field helper, .badge, dialog, combobox. */

/* =====================================================================
   7) Field — wrapper de formulário (label/hint/erro) p/ inputs globais
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--c-text); }
.field__hint  { font-size: 0.75rem; color: var(--c-text3); }
.field--error .field__hint { color: var(--c-red); }
.field--error input, .field--error textarea, .field--error select { border-color: var(--c-red); }

/* =====================================================================
   8) Badge — selo de status
   ===================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--radius-full);
  border: 1px solid var(--c-border);
  color: var(--c-text2);
  background: var(--c-bg-subtle);
}
.badge--success { color: var(--c-green);  background: var(--c-green-bg);  border-color: var(--c-green-bd); }
.badge--danger  { color: var(--c-red);    background: var(--c-red-bg);    border-color: var(--c-red-bd); }
.badge--warning { color: var(--c-amber);  background: var(--c-amber-bg);  border-color: var(--c-amber-bd); }
.badge--gold    { color: var(--c-accent-600); background: rgba(202,138,4,.12); border-color: rgba(202,138,4,.35); }

/* =====================================================================
   9) Dialog / Modal — overlay + caixa central
   JS: data-dialog-target abre; data-dialog-close / Esc / overlay fecha.
   ===================================================================== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity .2s ease;
}
.dialog-overlay[hidden] { display: none; }
.dialog-overlay.is-open { opacity: 1; }
.dialog {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
  background: var(--c-bg-popover, var(--c-bg-elevated));
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: cia-dialog-in .2s cubic-bezier(0.22, 1, 0.36, 1);
}
.dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }
.dialog__title  { font-size: 1.05rem; font-weight: 700; color: var(--c-text); }
.dialog__close  {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--c-text3); cursor: pointer; transition: background .15s ease, color .15s ease;
}
.dialog__close:hover { background: var(--c-bg2); color: var(--c-text); }
.dialog__body   { padding: var(--space-3) var(--space-5); color: var(--c-text2); font-size: 0.9rem; line-height: 1.5; }
.dialog__footer { display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5) var(--space-5); }
@media (prefers-reduced-motion: reduce) {
  .dialog { animation: none; }
  .dialog-overlay { transition: none; }
}

/* =====================================================================
   10) Combobox — input com busca + listbox (JS controla abertura)
   ===================================================================== */
.combobox { position: relative; }
.combobox__input { padding-right: 34px; }
.combobox__toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--c-text3); cursor: pointer;
}
.combobox__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 40;
  max-height: 220px;
  overflow-y: auto;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--c-bg-popover, var(--c-bg-elevated));
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.combobox__list[hidden] { display: none; }
.combobox__option {
  padding: 8px 10px;
  font-size: 0.875rem;
  color: var(--c-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.combobox__option[hidden] { display: none; }
.combobox__option:hover,
.combobox__option.is-active { background: var(--c-bg2); }
.combobox__option[aria-selected="true"] { color: var(--c-accent-600); font-weight: 600; }
.combobox__empty { padding: 10px; font-size: 0.8rem; color: var(--c-text3); text-align: center; }

/* =====================================================================
   Theme Toggle — botões dark/light/system (ThemeToggle dos docs)
   ===================================================================== */
.theme-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-bg-elevated);
}
.theme-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text2);
  transition: background .15s ease, color .15s ease;
}
.theme-toggle button svg { width: 16px; height: 16px; display: block; }
.theme-toggle button:hover { background: var(--c-bg5); color: var(--c-text); }
.theme-toggle button.is-active:hover { background: var(--c-accent-500); color: #0A0A0A; }
.theme-toggle button.is-active {
  background: var(--c-accent-600);
  color: #0A0A0A;
}
.theme-toggle button:focus-visible {
  outline: 2px solid var(--c-accent-400);
  outline-offset: 1px;
}

/* =====================================================================
   Account Panel — "Minha Conta" (drawer da direita, estilo WhatsApp "Você")
   JS: js/account-panel.js. Abre com [data-account-open]; Esc/backdrop fecham.
   ===================================================================== */
.acct-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity .28s ease;
}
.acct-overlay[hidden] { display: none; }
.acct-overlay.is-open { opacity: 1; }

.acct-panel {
  position: relative;
  width: 400px;
  max-width: 100%;
  height: 100%;
  background: var(--c-bg1);
  border-left: 1px solid var(--c-border2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(0.22, 1, 0.36, 1);
}
.acct-overlay.is-open .acct-panel { transform: translateX(0); }

.acct-main,
.acct-sub {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg1);
}

/* Header (compartilhado por main e sub-tela) */
.acct-header {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--c-border);
}
.acct-header__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.acct-header__title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
}
.acct-sub__header .acct-header__title { font-size: 1rem; }
.acct-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--c-text3);
  cursor: pointer;
  font-size: 18px;
  transition: background .15s ease, color .15s ease;
}
.acct-close:hover { background: var(--c-bg4); color: var(--c-text); }
.acct-close svg { width: 20px; height: 20px; }

/* Campo de busca (pill, borda ouro no focus) */
.acct-search {
  position: relative;
  display: flex;
  align-items: center;
}
.acct-search__icon {
  position: absolute;
  left: 12px;
  display: inline-flex;
  color: var(--c-text3);
  pointer-events: none;
}
.acct-search__icon svg { width: 16px; height: 16px; }
.acct-search__input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  font-size: 13.5px;
  color: var(--c-text);
  background: var(--c-bg3);
  border: 1px solid var(--c-border2);
  border-radius: var(--radius-full);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.acct-search__input::placeholder { color: var(--c-text4); }
.acct-search__input:focus {
  border-color: var(--c-accent-600);
  background: var(--c-bg2);
  box-shadow: 0 0 0 3px var(--c-primary-bg);
}

.acct-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

/* Card de perfil */
.acct-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3) var(--space-6);
}
.acct-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: #0A0A0A;
  background: linear-gradient(135deg, var(--c-accent-500), var(--c-accent-700));
  box-shadow: var(--shadow-gold);
  user-select: none;
}
.acct-profile__name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--c-text);
}
.acct-profile__badge { margin-top: 2px; }

/* Lista de seções */
.acct-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.acct-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--c-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s ease;
}
.acct-item:hover { background: var(--c-bg4); }
.acct-item[hidden] { display: none; }
.acct-item__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--c-text2);
}
.acct-item__icon svg { width: 20px; height: 20px; }
.acct-item__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.acct-item__title { font-size: 14px; font-weight: 600; color: var(--c-text); }
.acct-item__sub {
  font-size: 12px;
  color: var(--c-text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acct-item__chevron {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--c-text4);
}
.acct-item__chevron svg { width: 16px; height: 16px; }
.acct-item--danger { margin-top: var(--space-2); }
.acct-item--danger .acct-item__icon,
.acct-item--danger .acct-item__title { color: var(--c-red); }
.acct-item--danger:hover { background: var(--c-red-bg); }

.acct-empty {
  padding: var(--space-5);
  text-align: center;
  font-size: 13px;
  color: var(--c-text3);
}

/* Sub-tela (desliza sobre a lista) */
.acct-sub {
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .26s cubic-bezier(0.22, 1, 0.36, 1), visibility .26s;
}
.acct-sub.is-active { transform: translateX(0); visibility: visible; }
.acct-sub__body { display: flex; flex-direction: column; gap: var(--space-3); }
.acct-sub-block {
  padding: var(--space-3);
  background: var(--c-bg3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
.acct-sub-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text3);
  margin-bottom: var(--space-2);
}
.acct-sub-value { font-size: 14px; color: var(--c-text); }
.acct-sub-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  text-decoration: none;
}
.acct-sub .theme-toggle button svg { width: 16px; height: 16px; }
.acct-sub-note {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--c-text3);
  padding: var(--space-2) 0;
}

/* Entrada na topbar */
.acct-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: #0A0A0A;
  background: linear-gradient(135deg, var(--c-accent-500), var(--c-accent-700));
  cursor: pointer;
  flex-shrink: 0;
  transition: box-shadow .15s ease, transform .12s ease;
}
.acct-trigger:hover { box-shadow: var(--shadow-gold); }
.acct-trigger:active { transform: scale(0.95); }

@media (prefers-reduced-motion: reduce) {
  .acct-overlay,
  .acct-panel,
  .acct-sub { transition: none; }
}

/* Mobile: tela cheia */
@media (max-width: 600px) {
  .acct-panel { width: 100%; border-left: none; }
  .acct-avatar { width: 96px; height: 96px; font-size: 2rem; }
}

/* ── AI Progress Ring ──────────────────────────────────────────────
   r=48 → circunferência≈301.6  |  r=24 (mini) → circunferência≈150.8
   ────────────────────────────────────────────────────────────────── */
.ai-ring-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 48px 28px; text-align: center;
}
.ai-ring-wrap.ai-ring-mini {
  padding: 14px 16px; gap: 12px;
  flex-direction: row; align-items: center; text-align: left;
}
.ai-ring-svg { transform: rotate(-90deg); display: block; overflow: visible; }
.ai-ring-track { fill: none; stroke: var(--c-border2); stroke-width: 6; }
.ai-ring-fill {
  fill: none; stroke: var(--c-blue); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 301.6; stroke-dashoffset: 301.6;
  transition: stroke .4s ease;
}
.ai-ring-mini .ai-ring-fill { stroke-dasharray: 150.8; stroke-dashoffset: 150.8; }
.ai-ring-wrap.running .ai-ring-fill {
  animation: ai-ring-sweep 28s cubic-bezier(.35,0,.65,1) forwards;
}
.ai-ring-mini.running .ai-ring-fill {
  animation: ai-ring-sweep-mini 20s cubic-bezier(.35,0,.65,1) forwards;
}
@keyframes ai-ring-sweep {
  0%   { stroke-dashoffset: 301.6; }
  100% { stroke-dashoffset: 45.2; }  /* para em ~85% */
}
@keyframes ai-ring-sweep-mini {
  0%   { stroke-dashoffset: 150.8; }
  100% { stroke-dashoffset: 22.6; }
}
.ai-ring-wrap.done .ai-ring-fill  { animation: none; stroke-dashoffset: 0;     stroke: var(--c-green); }
.ai-ring-wrap.error .ai-ring-fill { animation: none; stroke-dashoffset: 180.9; stroke: var(--c-red);   }
.ai-ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ai-ring-icon { font-size: 28px; color: var(--c-blue); transition: opacity .2s ease, transform .2s ease; }
.ai-ring-mini .ai-ring-icon { font-size: 16px; }
.ai-ring-wrap.done  .ai-ring-icon { color: var(--c-green); }
.ai-ring-wrap.error .ai-ring-icon { color: var(--c-red);   }
.ai-ring-status { font-size: 15px; font-weight: 600; color: var(--c-text); }
.ai-ring-mini .ai-ring-status { font-size: 14px; font-weight: 500; }
.ai-ring-sub { font-size: 12px; color: var(--c-text3); margin-top: -8px; }
.ai-ring-mini .ai-ring-sub { font-size: 12px; margin-top: 2px; }
.ai-ring-slow { font-size: 12px; color: var(--c-text3); opacity: 0; transition: opacity .8s ease; }
.ai-ring-slow.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .ai-ring-fill { animation: none !important; stroke-dashoffset: 150 !important; }
  .ai-ring-icon { transition: none !important; }
  .ai-ring-slow { transition: none !important; }
}
}
