/* Painel administrativo — foco em clareza e áreas de toque grandes. */
:root {
  --c-primary: #d97706;
  --c-primary-dark: #b45309;
  --c-primary-soft: #fef3c7;
  --c-ink: #18181b;
  --c-muted: #57534e;
  --c-line: #e8e2d5;
  --c-bg: #fbf9f4;
  --c-danger: #dc2626;
  --c-warn: #d97706;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body.admin { margin: 0; font-family: var(--font); color: var(--c-ink); background: var(--c-bg); line-height: 1.5; font-size: 1rem; }
a { color: var(--c-primary-dark); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 1.6em 0 0.6em; }
code { background: #eceee8; padding: 2px 6px; border-radius: 6px; font-size: 0.85em; overflow-wrap: anywhere; }
.muted { color: var(--c-muted); }
:focus-visible { outline: 3px solid #d97706; outline-offset: 2px; }

/* Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--c-line); background: #fff; color: var(--c-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--c-primary-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1e18; }
.btn-danger-outline { color: var(--c-danger); border-color: #e4b8b5; }
.btn-danger-outline:hover:not(:disabled) { background: #fdecea; }
.btn-sm { padding: 5px 10px; font-size: 0.875rem; }
.btn-block { width: 100%; padding: 12px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer; color: inherit; }
.icon-btn:hover:not(:disabled) { background: var(--c-primary-soft); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--c-primary-dark); text-decoration: underline; cursor: pointer; text-align: left; }
.input, .form input:not([type=checkbox]):not([type=file]), .form select, .form textarea { width: 100%; padding: 9px 12px; font: inherit; border: 1px solid #b9beb4; border-radius: 8px; background: #fff; color: inherit; }
.input { width: auto; min-width: 200px; }
.form input:focus, .form select:focus, .form textarea:focus, .input:focus { border-color: var(--c-primary); outline: 2px solid var(--c-primary-soft); }

/* Formulários (gerados pelo form-renderer.js) */
.form { display: grid; gap: 14px; max-width: 720px; }
.form-field { display: grid; gap: 4px; }
.form-field > label { font-weight: 700; }
.form-field.type-boolean, .form-field.type-consent { display: flex; align-items: center; gap: 8px; }
.form-group-title { margin: 12px 0 0; font-size: 1rem; font-weight: 700; border-bottom: 2px solid var(--c-primary-soft); padding-bottom: 4px; }
.form-help { color: var(--c-muted); }
.form-error { color: var(--c-danger); font-weight: 600; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.repeat-list { display: grid; gap: 12px; margin: 6px 0; }
.repeat-row { border: 1px solid var(--c-line); border-radius: var(--radius); padding: 12px; background: #fafbf8; display: grid; gap: 10px; }
.repeat-add, .repeat-remove { justify-self: start; font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px dashed #9aa394; background: #fff; cursor: pointer; }
.repeat-remove { color: var(--c-danger); border-style: solid; border-color: #e4b8b5; }
.richtext-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.richtext-toolbar button { min-width: 34px; height: 34px; border: 1px solid #b9beb4; background: #fff; border-radius: 6px; cursor: pointer; font-weight: 700; }
.richtext-editor { min-height: 140px; padding: 10px 12px; border: 1px solid #b9beb4; border-radius: 8px; background: #fff; }
.richtext-editor:focus { outline: 2px solid var(--c-primary-soft); border-color: var(--c-primary); }
.media-preview { max-width: 160px; max-height: 120px; border-radius: 8px; border: 1px solid var(--c-line); }
.media-status { color: var(--c-muted); }
.media-clear { justify-self: start; font: inherit; padding: 4px 10px; border-radius: 8px; border: 1px solid #e4b8b5; background: #fff; color: var(--c-danger); cursor: pointer; }

/* Tela de login */
.auth-card { max-width: 420px; margin: 8vh auto; background: #fff; padding: 28px; border-radius: 16px; box-shadow: 0 10px 40px rgba(20, 40, 25, 0.12); }
.auth-card h1 { margin-bottom: 16px; }
.auth-links { text-align: center; color: var(--c-muted); margin-bottom: 0; }
.alert { padding: 12px 16px; border-radius: 10px; margin: 8px 0; }
.alert--success { background: #e6f4ea; border: 1px solid #a8d5b2; color: #17421f; }

/* Casca do painel */
.app-loading { padding: 2rem; color: var(--c-muted); }
.admin-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--c-line); position: sticky; top: 0; z-index: 20; }
.admin-brand { font-weight: 800; text-decoration: none; margin-right: auto; }
.admin-user { color: var(--c-muted); font-size: 0.9rem; }
.admin-menu-btn { display: none; }
.admin-body { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 57px); }
.admin-nav { background: #fff; border-right: 1px solid var(--c-line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--c-ink); font-weight: 600; }
.admin-nav a:hover { background: var(--c-primary-soft); }
.admin-nav a.is-active { background: var(--c-primary); color: #fff; }
.nav-badge { background: #d9731a; color: #fff; border-radius: 999px; padding: 0 8px; font-size: 0.8rem; }
.admin-main { padding: 20px; min-width: 0; outline: none; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h2 { margin: 0; }
.view-head__actions, .row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.panel { background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); padding: 18px; }
.empty { padding: 32px; text-align: center; color: var(--c-muted); background: #fff; border: 1px dashed var(--c-line); border-radius: var(--radius); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card-link { display: grid; gap: 4px; padding: 16px; background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--c-primary); box-shadow: 0 4px 16px rgba(20, 40, 25, 0.08); }
.card-link span { color: var(--c-muted); font-size: 0.9rem; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.table th { background: #f7f8f4; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-muted); }
.table tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.badge--ok { background: #e6f4ea; color: #17421f; }
.badge--warn { background: #fff3cd; color: var(--c-warn); }
.badge--neutral { background: #eceee8; color: var(--c-muted); }
.badge--danger { background: #fbe9e7; color: var(--c-danger); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

.section-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.section-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); flex-wrap: wrap; }
.section-item__info { display: grid; min-width: 0; }
.section-item__type { font-size: 0.8rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px; align-content: start; }
.media-item__thumb { border: 0; padding: 0; background: #eceee8; border-radius: 8px; cursor: pointer; aspect-ratio: 4 / 3; overflow: hidden; display: grid; place-items: center; }
.media-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item__doc { font-weight: 800; color: var(--c-muted); }
.media-item__meta { display: grid; gap: 4px; font-size: 0.85rem; min-width: 0; }
.media-item__meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-detail { max-width: 100%; max-height: 320px; border-radius: 8px; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.meta-list dt { font-weight: 700; }
.meta-list dd { margin: 0; }
.message__text { white-space: pre-wrap; background: #f7f8f4; padding: 14px; border-radius: 8px; }

/* Diálogos e avisos */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.modal--wide { width: min(760px, 94vw); }
.modal::backdrop { background: rgba(10, 20, 12, 0.5); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--c-line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal__head h2 { margin: 0; font-size: 1.1rem; }
.modal__body { padding: 18px; overflow-y: auto; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 1000; }
.toast { background: #1d2a21; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); max-width: 340px; }
.toast--error { background: var(--c-danger); }

@media (max-width: 860px) {
  .admin-menu-btn { display: inline-block; }
  .admin-user { display: none; }
  .admin-body { grid-template-columns: 1fr; }
  .admin-nav { display: none; position: sticky; top: 57px; z-index: 15; border-right: 0; border-bottom: 1px solid var(--c-line); }
  .admin-nav.is-open { display: flex; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { border-bottom: 1px solid var(--c-line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; }
  .table td::before { content: attr(data-label) ": "; font-weight: 700; color: var(--c-muted); }
}

/* Eventos e inscrições */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--c-line); margin-bottom: 16px; }
.tab { font: inherit; padding: 10px 16px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; margin-bottom: -2px; color: var(--c-muted); font-weight: 600; }
.tab:hover { color: var(--c-text, #1d2a21); }
.tab.is-active { color: var(--c-primary, #2f6b3a); border-bottom-color: var(--c-primary, #2f6b3a); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters input[type="search"] { font: inherit; padding: 8px 10px; border: 1px solid var(--c-line); border-radius: 8px; background: #fff; min-width: 0; }
.filters input[type="search"] { flex: 1 1 220px; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; }
.field-error { color: var(--c-danger); font-weight: 600; }
.modal__body h3, .modal__body h4 { margin: 16px 0 6px; }
.modal__body textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--c-line); border-radius: 8px; }

.modal__body .contact-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.modal__body .contact-list dd { margin: 0; overflow-wrap: anywhere; }
