/* Marketing OS — base design system.
   Desktop-first, low-decoration, colors reserved for status/priority/alerts. */

:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e3e5e9;
  --color-text: #1a1d23;
  --color-text-muted: #6b7280;
  --color-primary: #2f3b52;
  --color-primary-hover: #232c3d;
  --color-accent: #3763e0;

  --color-success: #1f9d55;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #2563eb;

  --priority-urgent: #dc2626;
  --priority-alta: #d97706;
  --priority-media: #2563eb;
  --priority-baixa: #6b7280;

  --radius: 8px;
  --sidebar-width: 232px;
  --topbar-height: 56px;

  font-size: 15px;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.45;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--color-primary);
  color: #dfe3ea;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar__brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  padding: 0 .5rem;
}

.sidebar__brand small {
  display: block;
  font-weight: 400;
  font-size: .7rem;
  color: #9aa4b6;
  letter-spacing: .04em;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar__link {
  color: #cfd5e0;
  padding: .55rem .65rem;
  border-radius: var(--radius);
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.sidebar__link:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar__link.is-active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }

.topbar {
  grid-area: topbar;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.topbar__search {
  flex: 1;
  max-width: 420px;
  margin: 0 1rem;
}

.topbar__search input {
  width: 100%;
  padding: .45rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  font-size: .875rem;
}

.topbar__actions { display: flex; align-items: center; gap: .75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: .5rem .9rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn:hover { text-decoration: none; background: var(--color-bg); }

.btn--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.btn--primary:hover { background: #2c52c0; }

.main {
  grid-area: main;
  padding: 1.5rem;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header p { color: var(--color-text-muted); margin: .1rem 0 0; font-size: .9rem; }

/* ---------- Cards / widgets ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat__value { font-size: 1.6rem; font-weight: 700; }
.stat__label { font-size: .8rem; color: var(--color-text-muted); }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Badges (status/priority/alerts) ---------- */

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge--success { background: #e5f6ea; color: var(--color-success); }
.badge--warning { background: #fef3e2; color: var(--color-warning); }
.badge--danger  { background: #fdeaea; color: var(--color-danger); }
.badge--info    { background: #e8effd; color: var(--color-info); }
.badge--muted   { background: #eef0f3; color: var(--color-text-muted); }

/* ---------- Auth pages ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-card h1 { font-size: 1.15rem; }
.auth-card .subtitle { color: var(--color-text-muted); font-size: .85rem; margin-bottom: 1.5rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; }
.field input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .9rem;
}

.alert {
  padding: .65rem .85rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

.alert--danger { background: #fdeaea; color: #a11b1b; border: 1px solid #f6c6c6; }
.alert--success { background: #e5f6ea; color: #157a3a; border: 1px solid #bfe6cb; }

/* ---------- Empty / placeholder states ---------- */

.empty-state {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar { display: none; }
  .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

/* Fase 10.5: campaigns/show.php and projects/show.php implement a
 * tab-switching UI (toggling this class on click via inline JS) but
 * this project has no Tailwind build — .hidden was never actually
 * defined anywhere, so every tab's content rendered stacked and
 * visible at once instead of one at a time. This is the one rule the
 * existing JS needs to function; it does not attempt to restyle the
 * rest of those pages' Tailwind-named classes (bg-white, rounded-lg,
 * grid-cols-*, etc.), which is a larger, separate styling gap. */
.hidden { display: none !important; }

/* ==========================================================================
   Fase 10.8.5 — refinamento de layout
   ========================================================================== */

:root {
  --color-border-subtle: rgba(255, 255, 255, .14); /* divisórias dentro da sidebar escura (variável era usada mas nunca definida) */
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .05);
  --focus-ring: 0 0 0 3px rgba(55, 99, 224, .22);
}

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* Foco visível para quem navega por teclado (antes não havia indicação). */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Sidebar fixa enquanto a página rola (em telas longas como a de demanda o
   menu sumia ao descer) e topbar sempre à vista. */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
}

.sidebar__link { transition: background .15s ease, color .15s ease; }
.sidebar__section-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #9aa4b6;
  padding: .5rem .65rem;
}
.sidebar__divider { margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid var(--color-border-subtle); }

/* Cartões e botões com acabamento mais consistente. */
.card { box-shadow: var(--shadow-card); }
.btn { transition: background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn--primary:active { background: #2547a8; }

.page-header { flex-wrap: wrap; gap: .75rem; }
.page-header h1 { font-size: 1.45rem; line-height: 1.2; }

/* Campos de formulário: selects/textarea ficavam sem estilo (só input tinha). */
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font: inherit;
  font-size: .9rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
}
.field input:disabled,
.field select:disabled,
.field textarea:disabled { background: var(--color-bg); color: var(--color-text-muted); cursor: not-allowed; }

/* Linhas de tabela com destaque ao passar o mouse e cabeçalho que não quebra. */
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: rgba(55, 99, 224, .035); }
th { white-space: nowrap; }

/* Estado vazio mais acolhedor. */
.empty-state { background: var(--color-surface); }

/* Botão do menu (só aparece no celular/tablet) e cortina atrás do menu aberto. */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-right: .5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; flex: none; }

  /* Antes o menu lateral simplesmente sumia no celular, deixando o usuário
     sem navegação nenhuma. Agora vira uma gaveta que abre pelo botão ☰. */
  .sidebar {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 84vw);
    height: 100%;
    z-index: 60;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: none;
  }
  .app-shell.is-menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .app-shell.is-menu-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 23, 42, .45);
  }

  .topbar { padding: 0 .75rem; }
  .topbar__search { margin: 0 .5rem; min-width: 0; }
  .topbar__actions { gap: .4rem; }
  .topbar__actions .btn { padding: .45rem .6rem; }
  .main { padding: 1.1rem .9rem; }
}

@media (max-width: 700px) {
  /* Tabelas largas rolam na horizontal em vez de estourar a tela. */
  .main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar__actions a[href="/profile"] span:last-child { display: none; }
}

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