/* ===================================================================
   Códice Matriz — Design System RRooster
   Dark mode premium · profundidade por elevação · cor semântica
   =================================================================== */

:root {
  /* Superfícies — profundidade por elevação */
  --surface-base:    #07071C;
  --surface:         #0D0D2B;
  --surface-raised:  #13133A;
  --surface-overlay: #1A1A4A;
  --border:          #1A1A3E;
  --border-strong:   #2A2A5E;

  /* Marca + significado fixo */
  --primary:  #4285F4;
  --accent:   #7A37DB;
  --gold:     #F4B400;
  --danger:   #DB212A;
  --success:  #22C55E;

  /* Texto */
  --text:       #FFFFFF;
  --text-body:  #CDD0E0;
  --text-muted: #9499B5;

  /* Gradiente assinatura — EXCLUSIVO para IA */
  --gradient-ai: linear-gradient(135deg, #7A37DB, #4285F4);

  /* Motion */
  --dur-fast: 150ms;
  --dur-mid: 300ms;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);

  /* Layout */
  --sidebar-w: 264px;
  --radius: 14px;
  --radius-sm: 9px;

  /* Sombra (sutil no escuro) */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3);
  color-scheme: dark;
}

/* ===== Tema claro ===== (marca + gradiente herdam do :root) */
:root[data-theme="light"] {
  --surface-base:    #EEF1F7;
  --surface:         #FFFFFF;
  --surface-raised:  #FFFFFF;
  --surface-overlay: #F4F6FB;
  --border:          #E4E7F0;
  --border-strong:   #CDD2E0;

  --text:       #14152E;
  --text-body:  #3A3E57;
  --text-muted: #6A6E86;

  --shadow-card: 0 1px 3px rgba(20,21,46,0.08), 0 1px 2px rgba(20,21,46,0.04);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--surface-base);
  color: var(--text-body);
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text); font-weight: 700; line-height: 1.2; }
.display { font-size: 40px; font-weight: 700; }
h1, .h1 { font-size: 32px; }
h2, .h2 { font-size: 24px; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }

.label {
  font-size: 13px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
}
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }

/* ---- Layout shell ---- */
.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar__logo { padding: 2px 8px 4px; }
.sidebar__logo img { height: 30px; width: auto; max-width: 100%; }
.brand-logo { display: block; }
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }
.sidebar__product { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); padding: 0 8px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; min-height: 44px; border-radius: var(--radius-sm);
  color: var(--text-body); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast);
  border: none; background: none; text-align: left; width: 100%;
}
.nav__item:hover { background: var(--surface-raised); color: var(--text); }
.nav__item.is-active { background: var(--surface-raised); color: var(--text); }
.nav__item.is-active::before {
  content: ''; position: absolute; left: 0; width: 3px; height: 22px;
  background: var(--primary); border-radius: 0 3px 3px 0;
}
.nav__item { position: relative; }
.nav__item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav__num { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nav__sep { height: 1px; background: var(--border); margin: 14px 8px; }

.main { flex: 1; min-width: 0; padding: 36px 40px; max-width: 1100px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm); font-size: 15px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: transform var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
  min-height: 44px; font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: #5a95f6; }
.btn--ghost { background: transparent; color: var(--text-body); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-raised); color: var(--text); }
.btn--ai {
  background: var(--gradient-ai); color: #fff;
  box-shadow: 0 6px 24px -6px rgba(122,55,219,0.6);
}
.btn--ai:hover { box-shadow: 0 8px 30px -6px rgba(122,55,219,0.75); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(219,33,42,0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--block { width: 100%; }

/* ---- Cards (dashboard) ---- */
.cards-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.block-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px; cursor: pointer; position: relative;
  transition: transform var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
}
.block-card { box-shadow: var(--shadow-card); }
.block-card:hover { transform: translateY(-2px); }
.block-card__top { display: flex; align-items: center; justify-content: space-between; }
.block-card__num { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 1px; }
.block-card__title { font-size: 17px; font-weight: 600; color: var(--text); }
.block-card__desc { font-size: 13px; color: var(--text-muted); }
.block-card__status { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }

.block-card--done { border-left-color: var(--success); }
.block-card--done .block-card__status { background: rgba(34,197,94,0.15); color: var(--success); }
.block-card--current { border-left-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), 0 0 28px -8px var(--primary); }
.block-card--current .block-card__status { background: rgba(66,133,244,0.18); color: var(--primary); animation: pulse 2s ease-in-out infinite; }
.block-card--available { border-left-style: dashed; border-left-color: var(--text-muted); }
.block-card--locked { opacity: 0.5; cursor: not-allowed; filter: saturate(0.4); }
.block-card--locked:hover { transform: none; }
.block-card--locked .block-card__status { color: var(--text-muted); }

@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(66,133,244,0.5); } 50% { box-shadow: 0 0 0 6px rgba(66,133,244,0); } }

.lock-hint {
  font-size: 12px; color: var(--gold); margin-top: 4px;
  display: flex; align-items: center; gap: 5px;
}

/* ---- Stepper / trilha ---- */
.stepper { display: flex; align-items: center; gap: 0; margin: 24px 0 8px; overflow-x: auto; padding-bottom: 6px; }
.stepper__node {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-raised); border: 1px solid var(--border-strong); color: var(--text-muted);
  transition: all var(--dur-mid) var(--ease-spring);
}
.stepper__node.is-done { background: var(--success); border-color: var(--success); color: #062; }
.stepper__node.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper__line { height: 2px; flex: 1; min-width: 14px; background: var(--border-strong); }
.stepper__line.is-done { background: var(--success); }

/* ---- Forms ---- */
.form-head { margin-bottom: 28px; }
.form-head h1 { margin-bottom: 8px; }
.form-head p { color: var(--text-body); }
.form-grid { display: grid; gap: 22px; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field--full { grid-column: 1 / -1; }
.field > label { font-size: 15px; font-weight: 600; color: var(--text); }
.field__hint { font-size: 13px; color: var(--text-muted); margin-top: -2px; }
.section-title { grid-column: 1/-1; margin-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text);
  font-family: inherit; font-size: 15px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66,133,244,0.2);
}
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%237A7A7A' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

/* ---- Chips multi-select ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-body); font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
  transition: all var(--dur-fast); user-select: none;
}
.chip:hover { border-color: var(--primary); }
.chip.is-selected { background: rgba(66,133,244,0.18); border-color: var(--primary); color: var(--text); }
.chip.is-selected::before { content: '✓'; font-weight: 700; color: var(--primary); }
.chip.is-disabled { opacity: 0.4; cursor: not-allowed; }
.chip-counter { font-size: 12px; color: var(--text-muted); }
.chip-counter.is-max { color: var(--gold); }

/* ---- Radio / checkbox cards ---- */
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: all var(--dur-fast);
}
.opt:hover { border-color: var(--primary); }
.opt input { margin-top: 2px; accent-color: var(--primary); width: 18px; height: 18px; flex-shrink: 0; }
.opt.is-selected { background: rgba(66,133,244,0.12); border-color: var(--primary); }
.opt span { font-size: 14px; color: var(--text-body); }
.opt.is-disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Form footer ---- */
.form-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 32px; padding-top: 22px; border-top: 1px solid var(--border);
}

/* ---- Drawer (resultado IA) ---- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); opacity: 0;
  pointer-events: none; transition: opacity var(--dur-mid); z-index: 40;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(520px, 92vw);
  background: var(--surface-overlay); border-left: 1px solid var(--border-strong);
  transform: translateX(100%); transition: transform var(--dur-mid) var(--ease-spring);
  z-index: 50; display: flex; flex-direction: column; box-shadow: -20px 0 60px -20px rgba(0,0,0,0.7);
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { padding: 22px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer__body { padding: 24px; overflow-y: auto; flex: 1; }
.drawer__body h3 { color: var(--text); margin: 18px 0 8px; font-size: 16px; }
.drawer__body p { margin-bottom: 12px; }
.drawer__close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; }

/* ---- Skeleton shimmer ---- */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface-overlay) 37%, var(--surface-raised) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton + .skeleton { margin-top: 12px; }
.sk-line { height: 14px; } .sk-line.sk-short { width: 55%; } .sk-title { height: 22px; width: 40%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---- Auth screen ---- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 100% at 50% 0%, #10103a 0%, var(--surface-base) 60%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: 18px; padding: 36px; }
.auth-card__logo { text-align: center; margin-bottom: 26px; }
.auth-card__logo img { height: 40px; margin: 0 auto; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; font-size: 14px; margin-bottom: 26px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error { background: rgba(219,33,42,0.12); border: 1px solid rgba(219,33,42,0.4);
  color: #ff8a8f; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; display: none; }
.auth-error.is-visible { display: block; }
.auth-alt { text-align: center; font-size: 14px; margin-top: 18px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 120%);
  background: var(--surface-overlay); border: 1px solid var(--border-strong); color: var(--text);
  padding: 13px 20px; border-radius: var(--radius-sm); font-size: 14px; z-index: 80;
  transition: transform var(--dur-mid) var(--ease-spring); box-shadow: 0 10px 40px -10px rgba(0,0,0,0.6); }
.toast.is-visible { transform: translate(-50%, 0); }
.toast--success { border-color: var(--success); }
.toast--error { border-color: var(--danger); }

/* ---- Spinner ---- */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Mobile ---- */
.hamburger { display: none; }
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform var(--dur-mid); z-index: 60; }
  .sidebar.is-open { transform: translateX(0); }
  .hamburger { display: inline-flex; background: var(--surface-raised); border: 1px solid var(--border-strong); color: var(--text); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; margin-bottom: 20px; }
  .main { padding: 24px 20px; }
}
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .display { font-size: 30px; } h1, .h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===================================================================
   Dashboard Design System — Códice redesign (compartilhado result/painel)
   =================================================================== */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --gap: 16px;
}

/* Cabeçalho de bloco (ícone na cor do bloco + número + título + síntese) */
.ckm-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: var(--sp-5); }
.ckm-ibadge { display: grid; place-items: center; border-radius: 12px; flex-shrink: 0;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.ckm-ibadge svg { width: 56%; height: 56%; }
.ckm-head__meta { min-width: 0; }
.ckm-head__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); color: color-mix(in srgb, var(--c, var(--text-muted)) 42%, var(--text)); }
.ckm-head__title { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.12; margin-top: 3px; }
.ckm-head__sub { color: var(--text-body); margin-top: 9px; max-width: 90ch; }

/* Título de seção com tick de cor */
.ckm-sec { margin-top: var(--sp-6); }
.ckm-sec__title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--text); margin-bottom: var(--sp-4); }
.ckm-sec__title::before { content: ''; width: 4px; height: 15px; border-radius: 2px; background: var(--c, var(--primary)); flex-shrink: 0; }
.ckm-help { font-size: 12px; color: var(--text-muted); margin: -8px 0 12px; line-height: 1.45; }

/* Bento de 12 colunas + tile unificado */
.ckm-bento { display: grid; gap: var(--gap); grid-template-columns: repeat(12, 1fr); align-items: start; }
.tile { background: var(--surface-raised); border: 1px solid var(--border);
  border-left: 3px solid var(--c, var(--border-strong)); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow-card); grid-column: span 12; }
@media (min-width: 720px) {
  .tile { grid-column: span 6; }
  .tile--span3 { grid-column: span 3; }
  .tile--span4 { grid-column: span 4; }
  .tile--span8 { grid-column: span 8; }
  .tile--span12 { grid-column: span 12; }
}
.tile--accent { background: color-mix(in srgb, var(--c) 8%, var(--surface-raised)); }
.tile__label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); color: color-mix(in srgb, var(--c, var(--text-muted)) 40%, var(--text)); }
.tile__body { color: var(--text-body); margin-top: 8px; }
.tile__body p { color: var(--text-body); }
.tile__body p + p { margin-top: 8px; }

/* Faixa de KPIs */
.kpi-strip { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: var(--sp-5); align-items: start; }
.kpi { background: var(--surface-raised); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--primary));
  border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow-card); }
.kpi__label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.kpi__value { font-size: 21px; font-weight: 700; color: var(--text); margin-top: 6px; line-height: 1.2; }
/* Valor longo (parágrafo) num card de KPI: usa o corpo de texto normal, não o display grande. */
.kpi__value--long { font-size: 15px; font-weight: 600; line-height: 1.5; }
.kpi__hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.35; }

/* Chips e listas compartilhados */
.ckm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ckm-chip { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--surface-overlay); color: var(--text-body); border: 1px solid var(--border); }
.ckm-chip--ok { background: rgba(34,197,94,0.14); color: color-mix(in srgb, #22C55E 55%, var(--text)); border-color: transparent; }
.ckm-chip--no { background: rgba(219,33,42,0.16); color: color-mix(in srgb, #DB212A 60%, var(--text)); border-color: transparent; }
.ckm-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; color: var(--text-body); }

/* ===== Toques finos & elegantes ===== */
html, body { transition: background-color var(--dur-mid) var(--ease-out), color var(--dur-mid) var(--ease-out); }
.sidebar, .tile, .kpi, .px-exec, .px-block, .block-card, .rm-card, .rm-node, .arq-quote, .ckm-ibadge,
input, textarea, select {
  transition: background-color var(--dur-mid) var(--ease-out), border-color var(--dur-mid) var(--ease-out),
    color var(--dur-mid) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 38%, transparent); }

/* Scrollbar fino e elegante (substitui as barras grossas padrão) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

/* Realce sutil de borda no hover dos tiles (vida sem peso) */
.tile:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
