/* ═══════════════════════════════════════════════════════════
   Blog Administração — Liberdade Médica
   Identidade visual portada de Pagina-LM-Inst/src/index.css:
   mesmas variáveis, mesmo vermelho, mesmo toggle claro/escuro.
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* Brand */
  --red:     #E22D36;
  --red-2:   #B71E26;
  --bordo-1: #761525;
  --bordo-2: #4D0307;
  --black:   #000000;
  --white:   #FFFFFF;

  /* Superfícies */
  --card:       rgba(255,255,255,0.04);
  --card-2:     rgba(255,255,255,0.06);
  --border:     rgba(255,255,255,0.08);
  --border-red: rgba(226,45,54,0.32);

  --text:       #FFFFFF;
  --text-muted: rgba(255,255,255,0.66);
  --text-dim:   rgba(255,255,255,0.42);

  --header-bg:      rgba(0,0,0,0.78);
  --field-bg:       rgba(0,0,0,0.4);
  --field-bg-focus: rgba(0,0,0,0.6);
  --surface:        rgba(255,255,255,0.03);

  /* Estados — verde/âmbar entram só para feedback (sucesso, aviso) */
  --ok:   #2f9e5f;
  --warn: #d98a1f;

  --tint: radial-gradient(ellipse 90% 60% at 50% 0%, rgba(118,21,37,0.20) 0%, rgba(0,0,0,0) 60%);

  --max:      1180px;
  --header-h: 76px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --black:   #ffffff;
  --bordo-1: #a83144;
  --bordo-2: #7c1623;

  --card:       rgba(24,26,31,0.05);
  --card-2:     rgba(24,26,31,0.085);
  --border:     rgba(24,26,31,0.12);
  --border-red: rgba(226,45,54,0.30);

  --text:       #181a1f;
  --text-muted: rgba(24,26,31,0.66);
  --text-dim:   rgba(24,26,31,0.46);

  --header-bg:      rgba(255,255,255,0.82);
  --field-bg:       #ffffff;
  --field-bg-focus: #ffffff;
  --surface:        #ffffff;

  --ok:   #1f7a47;
  --warn: #a8650f;

  --tint: radial-gradient(ellipse 90% 60% at 50% 0%, rgba(226,45,54,0.07) 0%, rgba(255,255,255,0) 60%);

  color-scheme: light;
}

body {
  min-height: 100vh;
  background: var(--black);
  background-image: var(--tint);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 32px; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }

/* ── BOTÕES ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--red-2); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:not(:disabled):hover { border-color: var(--red); color: var(--red); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--border-red); }
.btn-danger:not(:disabled):hover { background: var(--red); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; }

/* ── TOGGLE DE TEMA (idêntico ao institucional) ── */
.theme-toggle {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 30px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.theme-toggle:hover { border-color: var(--border-red); }
.theme-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.theme-toggle-thumb {
  position: absolute;
  top: 50%; left: 3px;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.theme-toggle.is-light .theme-toggle-thumb { transform: translateY(-50%) translateX(28px); }
.theme-toggle-thumb svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
.theme-toggle.is-light .icon-sun  { display: block; }
.theme-toggle.is-light .icon-moon { display: none; }

/* troca de logo conforme o tema (mesma convenção do institucional:
   tema escuro usa o logo de texto branco) */
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark  { display: none; }
:root[data-theme="light"] .logo-light { display: block; }

/* ═══════════ LOGIN ═══════════ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 36px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 24px 64px rgba(0,0,0,0.35);
}
:root[data-theme="light"] .login-card {
  box-shadow: 0 1px 2px rgba(24,26,31,0.05), 0 20px 48px rgba(24,26,31,0.12);
}
.login-topo { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.login-logo img { height: 34px; width: auto; }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 6px; }
.login-card h1 .red { color: var(--red); }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-rodape { margin-top: 24px; text-align: center; font-size: 12px; color: var(--text-dim); }

/* ═══════════ CAMPOS ═══════════ */
.campo { margin-bottom: 18px; }
.campo label {
  display: block;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.campo textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--red);
  background: var(--field-bg-focus);
}
.campo input::placeholder, .campo textarea::placeholder { color: var(--text-dim); }
.campo select option { background: var(--black); color: var(--text); }
.campo-linha { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.contador { font-size: 12px; color: var(--text-dim); margin-top: 6px; display: block; text-align: right; }
.contador.warn { color: var(--warn); }
.contador.erro { color: var(--red); }

/* ═══════════ HEADER ═══════════ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.header-linha {
  height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
}
.header-logo img { height: 30px; width: auto; }
.header-dir { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.nav-abas { display: flex; gap: 4px; }
.aba {
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.aba:hover { color: var(--text); background: var(--card); }
.aba.ativa { background: var(--red); color: #fff; }

.chip-usuario { display: flex; align-items: center; gap: 10px; }
.chip-nome { font-size: 14px; font-weight: 600; line-height: 1.2; }
.chip-papel {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--red);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

/* ═══════════ LAYOUT ═══════════ */
.conteudo { padding: 44px 0 96px; }
.vista-titulo {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800; letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.vista-titulo .red { color: var(--red); }
.vista-sub { color: var(--text-muted); font-size: 15px; }
.vista-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 32px; }

.painel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  margin-bottom: 24px;
}
:root[data-theme="light"] .painel {
  box-shadow: 0 1px 2px rgba(24,26,31,0.04), 0 10px 28px rgba(24,26,31,0.06);
}
.painel h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.painel h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.vazio { color: var(--text-dim); font-size: 14px; padding: 24px 0; text-align: center; }

/* ═══════════ MÉTRICAS ═══════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
}
:root[data-theme="light"] .stat { box-shadow: 0 1px 2px rgba(24,26,31,0.04), 0 10px 28px rgba(24,26,31,0.06); }
.stat-rotulo {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 10px;
}
.stat-valor { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.stat-valor.red { color: var(--red); }

/* barras horizontais — comprimento proporcional às visualizações */
.barras { display: flex; flex-direction: column; gap: 16px; }
.barra-linha { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; align-items: center; }
.barra-nome { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-valor { font-size: 13px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.barra-trilho {
  grid-column: 1 / -1;
  height: 8px; border-radius: 100px;
  background: var(--card-2);
  overflow: hidden;
}
.barra-preenchida {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--bordo-1), var(--red));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ═══════════ TABELAS ═══════════ */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--border); }
th {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-dim); white-space: nowrap;
}
td { font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--card); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.acoes-celula { display: flex; gap: 8px; justify-content: flex-end; }

.pill {
  display: inline-block;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.pill-cat  { background: var(--card-2); color: var(--text-muted); }
.pill-red  { background: rgba(226,45,54,0.14); color: var(--red); }
.pill-adm      { background: rgba(226,45,54,0.14); color: var(--red); }
.pill-leitor   { background: var(--card-2); color: var(--text-muted); }

/* Escritor fica entre o vermelho do adm e o cinza do leitor. O bordô puro
   some sobre o fundo preto, então no escuro usamos um rosé claro; no claro,
   o bordô escuro é que dá o contraste. */
.pill-escritor { background: rgba(118,21,37,0.30); color: #f0a3ae; }
:root[data-theme="light"] .pill-escritor { background: rgba(118,21,37,0.12); color: #8d2338; }
.pill-inativo { background: var(--card-2); color: var(--text-dim); }
.pill-ativo   { background: rgba(47,158,95,0.15); color: var(--ok); }

/* ═══════════ CARTÕES DE ARTIGO ═══════════ */
.artigos-lista { display: flex; flex-direction: column; gap: 12px; }
.artigo-card {
  display: grid;
  grid-template-columns: 96px minmax(0,1fr) auto;
  gap: 18px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.artigo-card:hover { border-color: var(--border-red); transform: translateY(-1px); }
:root[data-theme="light"] .artigo-card { box-shadow: 0 1px 2px rgba(24,26,31,0.04), 0 8px 22px rgba(24,26,31,0.05); }
.artigo-thumb {
  width: 96px; height: 72px; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--border);
}
.artigo-thumb-vazia {
  width: 96px; height: 72px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 22px;
}
.artigo-titulo { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.artigo-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--text-muted); }
.artigo-views { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.artigo-views svg { width: 15px; height: 15px; stroke: var(--red); fill: none; stroke-width: 2; }
.artigo-acoes { display: flex; gap: 8px; }

/* ═══════════ UPLOAD ═══════════ */
.upload-area {
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--red); background: var(--card); }
.upload-area.enviando { opacity: 0.6; pointer-events: none; }
.upload-icone { font-size: 26px; margin-bottom: 8px; }
.upload-area p { font-size: 14px; margin-bottom: 4px; }
.upload-area small { font-size: 12px; color: var(--text-dim); }

.img-preview { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.img-preview img { width: 100%; max-height: 280px; object-fit: cover; }
.img-remover {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.7); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.img-remover:hover { background: var(--red); }

/* ═══════════ BLOCOS / PREVIEW ═══════════ */
.blocos { display: flex; flex-direction: column; gap: 10px; }
.bloco {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto;
  gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.bloco-tipo {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  padding: 4px 8px; border-radius: 6px;
  background: rgba(226,45,54,0.14); color: var(--red);
  min-width: 60px; text-align: center;
}
.bloco-texto {
  font-size: 13px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bloco-mini { width: 44px; height: 34px; border-radius: 6px; object-fit: cover; }
.bloco-acoes { display: flex; gap: 4px; }
.icone-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.icone-btn:hover:not(:disabled) { background: var(--card-2); color: var(--text); }
.icone-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icone-btn.perigo:hover { background: var(--red); color: #fff; }

.preview-render {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  min-height: 140px;
}
.preview-render h1 { font-size: 28px; font-weight: 800; margin-bottom: 14px; letter-spacing: -0.01em; }
.preview-render h2 { font-size: 22px; margin: 18px 0 10px; }
.preview-render h3 { font-size: 18px; margin: 16px 0 8px; }
.preview-render h4, .preview-render h5, .preview-render h6 { margin: 14px 0 8px; }
.preview-render p  { margin-bottom: 12px; color: var(--text-muted); }
.preview-render img { border-radius: 10px; margin: 16px 0; }
.preview-resumo {
  background: var(--card-2); border-left: 3px solid var(--red);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 18px;
  font-size: 14px;
}

/* ═══════════ AÇÕES / MODAL / AVISOS ═══════════ */
.acoes-barra { display: flex; flex-wrap: wrap; gap: 12px; }
.acoes-barra .cresce { margin-left: auto; }

.modal-fundo {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--black);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  max-height: 88vh; overflow-y: auto;
}
:root[data-theme="light"] .modal { box-shadow: 0 24px 64px rgba(24,26,31,0.2); }
.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 22px; }
.modal-acoes { display: flex; gap: 12px; justify-content: flex-end; margin-top: 26px; }

.aviso {
  padding: 12px 16px; border-radius: 12px;
  font-size: 14px; margin-bottom: 18px;
  border: 1px solid transparent;
}
.aviso.erro { background: rgba(226,45,54,0.10); border-color: var(--border-red); color: var(--red); }
.aviso.ok   { background: rgba(47,158,95,0.10); border-color: rgba(47,158,95,0.3); color: var(--ok); }
.aviso.info { background: var(--card); border-color: var(--border); color: var(--text-muted); }

/* toast global */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 14px 24px; border-radius: 100px;
  font-size: 14px; font-weight: 600;
  background: var(--black); border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
}
:root[data-theme="light"] .toast { box-shadow: 0 12px 40px rgba(24,26,31,0.18); }
.toast.visivel { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.erro { border-color: var(--border-red); color: var(--red); }
.toast.ok   { border-color: rgba(47,158,95,0.4); color: var(--ok); }

/* status de conexão */
.status-conexao { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.status-bolinha { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.status-conexao.ok   .status-bolinha { background: var(--ok); }
.status-conexao.erro .status-bolinha { background: var(--red); }

/* ═══════════ RESPONSIVO ═══════════ */
@media (max-width: 900px) {
  .container { padding: 0 20px; }
  .header-linha { height: auto; padding: 14px 0; flex-wrap: wrap; gap: 14px; }
  .nav-abas { order: 3; width: 100%; overflow-x: auto; }
  .campo-linha { grid-template-columns: 1fr; }
  .artigo-card { grid-template-columns: 72px minmax(0,1fr); }
  .artigo-thumb, .artigo-thumb-vazia { width: 72px; height: 56px; }
  .artigo-acoes { grid-column: 1 / -1; justify-content: flex-end; }
  .vista-topo { flex-direction: column; }
  .chip-nome, .chip-papel { display: none; }
  .theme-toggle { width: 52px; height: 28px; }
  .theme-toggle-thumb { width: 22px; height: 22px; }
  .theme-toggle.is-light .theme-toggle-thumb { transform: translateY(-50%) translateX(24px); }
}

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