/* GeraPost components (plain CSS over tokens.css; Tailwind utilities are used for layout). */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--gp-font);
  background: var(--gp-bg);
  color: var(--gp-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--gp-primary); }
[data-theme="dark"] a { color: var(--gp-accent); }
code, .gp-mono { font-family: var(--gp-mono); font-size: .85em; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--gp-accent); outline-offset: 2px; }

/* ---- layout ---- */
.gp-header {
  height: 68px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--gp-surface); border-bottom: 1px solid var(--gp-border);
  position: sticky; top: 0; z-index: 30;
}
.gp-header__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--gp-text); }
.gp-header__brand small { color: var(--gp-muted); font-size: 13px; }
.gp-header__spacer { flex: 1; }
.gp-shell { flex: 1; display: flex; min-height: 0; }
.gp-sidebar {
  width: 232px; flex-shrink: 0; background: var(--gp-surface); border-right: 1px solid var(--gp-border);
  padding: 12px 8px; position: sticky; top: 68px; height: calc(100vh - 68px); overflow-y: auto;
}
.gp-sidebar.is-collapsed { width: 64px; }
.gp-sidebar.is-collapsed .gp-nav__label { display: none; }
.gp-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--gp-text); font-weight: 500;
}
.gp-nav a:hover { background: var(--gp-bg); }
.gp-nav a.is-active { background: var(--gp-primary); color: #fff; }
.gp-nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.gp-nav__section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gp-muted); padding: 14px 12px 4px; }
.gp-main { flex: 1; min-width: 0; padding: 24px; }
.gp-page-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }
.gp-page-title h1 { font-size: 24px; margin: 0; flex: 1; letter-spacing: -.01em; }
.gp-bottom-nav { display: none; }

/* ---- footer (obrigatório em todas as páginas) ---- */
.gp-footer {
  min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 0 16px; border-top: 1px solid var(--gp-border); background: var(--gp-surface);
  color: var(--gp-muted); font-size: 13px; margin-top: auto; flex-wrap: wrap;
}
.gp-footer a { color: var(--gp-muted); }
.gp-footer__brand { display: inline-flex; color: var(--gp-muted); }
.gp-footer__brand img { height: 28px; width: auto; opacity: .85; }
[data-theme="dark"] .gp-footer__brand img { filter: brightness(1.7); }
.gp-footer__meta { font-family: var(--gp-mono); font-size: 12px; }

/* ---- components ---- */
.gp-card { background: var(--gp-surface); border: 1px solid var(--gp-border); border-radius: var(--gp-radius); padding: 18px; }
.gp-card h2 { font-size: 16px; margin: 0 0 12px; }
.gp-kpi { display: flex; flex-direction: column; gap: 2px; }
.gp-kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.gp-kpi__label { color: var(--gp-muted); font-size: 13px; }
.gp-muted { color: var(--gp-muted); }
.gp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--gp-border); background: var(--gp-surface);
  color: var(--gp-text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.gp-btn:hover { filter: brightness(.97); }
.gp-btn--primary { background: var(--gp-primary); border-color: var(--gp-primary); color: #fff !important; }
.gp-btn--accent { background: var(--gp-accent); border-color: var(--gp-accent); color: #04263a !important; }
.gp-btn--danger { background: var(--gp-danger); border-color: var(--gp-danger); color: #fff !important; }
.gp-btn--ghost { background: transparent; border-color: transparent; }
.gp-btn--sm { padding: 4px 10px; font-size: 13px; }
.gp-btn[disabled] { opacity: .5; cursor: not-allowed; }
.gp-input, .gp-form input:not([type=checkbox]):not([type=radio]):not([type=file]), .gp-form select, .gp-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--gp-border); border-radius: 8px;
  background: var(--gp-surface); color: var(--gp-text); font: inherit;
}
.gp-form textarea { min-height: 90px; }
.gp-field { margin-bottom: 14px; }
.gp-field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.gp-field .gp-help { color: var(--gp-muted); font-size: 12px; margin-top: 3px; }
.gp-field .gp-error { color: var(--gp-danger); font-size: 13px; margin-top: 3px; }
.gp-field--check label { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; }
.gp-table { width: 100%; border-collapse: collapse; background: var(--gp-surface); }
.gp-table th, .gp-table td { padding: 10px 12px; border-bottom: 1px solid var(--gp-border); text-align: left; vertical-align: middle; }
.gp-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--gp-muted); }
.gp-table-wrap { overflow-x: auto; border: 1px solid var(--gp-border); border-radius: var(--gp-radius); }
.gp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gp-border); margin-bottom: 16px; overflow-x: auto; }
.gp-tabs a { padding: 8px 14px; text-decoration: none; color: var(--gp-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.gp-tabs a.is-active { color: var(--gp-text); border-color: var(--gp-primary); font-weight: 600; }
.gp-empty { text-align: center; padding: 48px 16px; color: var(--gp-muted); }
.gp-empty strong { display: block; color: var(--gp-text); font-size: 17px; margin-bottom: 6px; }
.gp-alert { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--gp-border); margin-bottom: 12px; background: var(--gp-surface); }
.gp-alert--warning { border-color: var(--gp-warning); background: #FEF3C7; color: #78350F; }
.gp-alert--error { border-color: var(--gp-danger); background: #FEE2E2; color: #7F1D1D; }
.gp-alert--success { border-color: var(--gp-success); background: #DCFCE7; color: #14532D; }
.gp-alert--info { border-color: var(--gp-info); background: #DBEAFE; color: #1E3A8A; }

/* ---- status badges ---- */
.gp-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.gp-badge--queued, .gp-badge--skipped, .gp-badge--cancelled, .gp-badge--pending { background: #E5E7EB; color: #374151; }
.gp-badge--rendering, .gp-badge--publishing { background: #DBEAFE; color: #1D4ED8; }
.gp-badge--rendering::before, .gp-badge--publishing::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: gp-pulse 1s infinite;
}
.gp-badge--rendered, .gp-badge--approved, .gp-badge--downloaded { background: #E0F2FE; color: #075985; }
.gp-badge--awaiting_approval, .gp-badge--partial, .gp-badge--expired { background: #FEF3C7; color: #92400E; }
.gp-badge--published, .gp-badge--active { background: #DCFCE7; color: #166534; }
.gp-badge--failed, .gp-badge--error, .gp-badge--revoked { background: #FEE2E2; color: #991B1B; }
@keyframes gp-pulse { 50% { opacity: .3; } }

/* ---- library grid ---- */
.gp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.gp-post { position: relative; background: var(--gp-surface); border: 1px solid var(--gp-border); border-radius: var(--gp-radius); overflow: hidden; }
.gp-post__thumb { aspect-ratio: 4/5; background: #CBD5E1; display: block; width: 100%; object-fit: cover; }
.gp-post__body { padding: 8px 10px; font-size: 13px; }
.gp-post__check { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; }
.gp-post__type { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }

/* ---- toasts / modal ---- */
.gp-toasts { position: fixed; right: 16px; bottom: 64px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.gp-toast { background: var(--gp-text); color: var(--gp-bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 360px; }
.gp-modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.gp-modal__box { background: var(--gp-surface); border-radius: 14px; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px; }

/* ---- editor ---- */
.gp-editor { display: grid; grid-template-columns: 240px 1fr 280px; gap: 12px; min-height: 70vh; }
.gp-editor__canvas { background: repeating-conic-gradient(#e5e7eb 0% 25%, #f8fafc 0% 50%) 50% / 20px 20px; border-radius: var(--gp-radius); overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 16px; }
.gp-layer-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.gp-layer-item.is-selected { background: var(--gp-primary); color: #fff; }
.gp-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---- calendar ---- */
.gp-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.gp-cal__day { background: var(--gp-surface); border: 1px solid var(--gp-border); border-radius: 8px; min-height: 96px; padding: 6px; font-size: 12px; }
.gp-cal__day.is-other { opacity: .45; }
.gp-cal__day.is-today { border-color: var(--gp-primary); }
.gp-cal__ev { display: block; border-radius: 4px; padding: 1px 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }

/* ---- auth ---- */
.gp-auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.gp-auth__box { width: 100%; max-width: 400px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .gp-sidebar { display: none; }
  .gp-main { padding: 16px 16px 84px; }
  .gp-bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: var(--gp-surface);
    border-top: 1px solid var(--gp-border); z-index: 40; justify-content: space-around; align-items: center;
  }
  .gp-bottom-nav a { display: flex; flex-direction: column; align-items: center; font-size: 11px; text-decoration: none; color: var(--gp-muted); }
  .gp-bottom-nav a.is-active { color: var(--gp-primary); }
  .gp-bottom-nav svg { width: 22px; height: 22px; }
  .gp-footer { margin-bottom: 60px; height: auto; padding: 8px 16px; text-align: center; }
  .gp-editor { grid-template-columns: 1fr; }
}
@media print {
  .gp-sidebar, .gp-header, .gp-bottom-nav { display: none !important; }
}
[x-cloak] { display: none !important; }

/* grid/flex children must be allowed to shrink (prevents horizontal overflow on phones) */
.grid > *, .gp-main, .gp-card { min-width: 0; }
.gp-form input[type=color] { width: 72px !important; height: 40px; padding: 3px !important; cursor: pointer; }
.gp-field--check input, .gp-form input[type=checkbox] { width: 16px; height: 16px; }
.gp-field ul, .gp-field div[id^="id_"] > div { list-style: none; padding: 0; margin: 4px 0; }
/* long-form text (legal pages, help) */
.gp-prose h1 { font-size: 24px; margin: 0 0 12px; }
.gp-prose h2 { font-size: 17px; margin: 20px 0 6px; color: var(--gp-primary); }
.gp-prose p, .gp-prose li { line-height: 1.6; }
.gp-prose ul, .gp-prose ol { padding-left: 22px; margin: 6px 0 12px; }
.gp-prose ul { list-style: disc; }
.gp-prose ol { list-style: decimal; }
@media (max-width: 900px) {
  .gp-header { gap: 8px; }
  .gp-header > button:first-child, .gp-header__brand small { display: none; }
  .gp-header__brand .gp-logo--light, .gp-header__brand .gp-logo--dark { display: none !important; }
  .gp-header__brand .gp-logo--symbol { display: inline-block; height: 40px !important; }
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* GeraPost logo: colour version on light, inverse on dark theme, symbol on phones */
/* Explicit heights: Tailwind preflight (img { height: auto }) overrides the height attribute. */
.gp-logo { width: auto; display: inline-block; }
.gp-header__brand .gp-logo { height: 46px; }
.gp-logo--dark, .gp-logo--symbol { display: none; }
[data-theme="dark"] .gp-logo--light { display: none; }
[data-theme="dark"] .gp-logo--dark { display: inline-block; }
.gp-header__brand small { align-self: flex-end; margin-bottom: 4px; }
.gp-login-kstec img { height: 40px; width: auto; }
.gp-login-kstec span { white-space: nowrap; }
.gp-login-kstec { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--gp-border); color: var(--gp-muted); font-size: 13px; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gp-progress { height: 10px; border-radius: 999px; background: var(--gp-border); overflow: hidden; margin-top: 10px; }
.gp-progress > span { display: block; height: 100%; background: var(--gp-primary); border-radius: 999px; }
.gp-progress > span.is-warning { background: var(--gp-warning); }
.gp-progress > span.is-danger { background: var(--gp-danger); }
