/* ============================================================
   compat.css — ponte para nomes de classe herdados das telas
   antigas que o design "Ink & Teal" não cobre. Complementa o
   app-extra.css. Ao migrar uma tela para as classes novas
   (.btn-ghost, .field, .input), remova a regra correspondente.
   ============================================================ */

/* Botão secundário → equivalente ao .btn-ghost do design novo */
.btn-secondary {
    background: var(--card);
    color: var(--t2);
    border: 1.5px solid var(--line-2);
}
.btn-secondary:hover { border-color: var(--t4); color: var(--t1); }

/* Botão de alternar tema (topbar/sidebar/menu mobile) */
.topbar-theme {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line-2);
    background: var(--card);
    color: var(--t2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.topbar-theme:hover { color: var(--t1); border-color: var(--t4); }
.topbar-theme .ico-sun { display: none; }
:root[data-theme="dark"] .topbar-theme .ico-moon { display: none; }
:root[data-theme="dark"] .topbar-theme .ico-sun  { display: block; }

/* Marca textual na topbar mobile (o boilerplate não tem logotipo) */
.topbar-brand-txt {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--heading);
    text-decoration: none;
}

/* Utilitários herdados */
.container { width: 100%; }
.hidden { display: none !important; }
.text-center { text-align: center; }

/* Detalhe da rastreabilidade: grade de metadados */
.log-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.log-meta-item {
    padding: 11px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.log-meta-item strong {
    display: block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--t3);
    margin-bottom: 3px;
}
.log-meta-item span { font-size: .85rem; color: var(--t1); word-break: break-word; }

/* Diff antes/depois */
.diff-before { background: var(--err-bg); color: var(--err-tx); }
.diff-after  { background: var(--ok-bg);  color: var(--ok-tx); }

/* ---------- Painel colapsável (filtros de listagem) ---------- */
.app-panel-header { cursor: pointer; user-select: none; }
.app-panel-toggle svg { transition: transform .15s; }
.app-panel--collapsed .app-panel-toggle svg { transform: rotate(-90deg); }
.app-panel--collapsed .app-panel-collapsible-body { display: none; }

/* ---------- Linha de tabela clicável (abre um drawer de detalhe) ---------- */
.app-row-clickable { cursor: pointer; }
.app-row-clickable:hover { background: var(--surface-2); }

/* ---------- Fileira de ações inline (ex.: select + botão num drawer) ---------- */
.app-action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-action-row .select { width: auto; flex: 1; min-width: 140px; }

/* ---------- Diálogo de confirmação/alerta (substitui window.confirm/alert) ---------- */
.app-confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(7, 24, 41, .5);
    display: none; align-items: center; justify-content: center;
    padding: 16px; z-index: 1030;
}
.app-confirm-overlay.open { display: flex; }
.app-confirm {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    width: 100%; max-width: 400px;
    padding: 26px; text-align: center;
}
.app-confirm-icon {
    width: 48px; height: 48px; margin: 0 auto 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.app-confirm-icon svg { width: 24px; height: 24px; }
.app-confirm-icon-danger  { background: var(--err-bg);  color: var(--err-tx); }
.app-confirm-icon-warning { background: var(--warn-bg); color: var(--warn-tx); }
.app-confirm-icon-info    { background: var(--info-bg); color: var(--info-tx); }
.app-confirm-title { font-size: 1.05rem; font-weight: 700; color: var(--heading); margin-bottom: 8px; }
.app-confirm-message { font-size: .9rem; color: var(--t2); line-height: 1.5; white-space: pre-line; }
/* Destaque opcional (appConfirm({ destaque })), ex.: o e-mail que vai receber o envio. */
.app-confirm-destaque { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--teal-50); border: 1.5px solid var(--teal-400); text-align: center; }
.app-confirm-destaque-rotulo { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--t2); }
.app-confirm-destaque-texto { display: block; margin-top: 2px; font-size: 1rem; font-weight: 700; color: var(--teal-700); word-break: break-all; }
.app-confirm-campo { margin-top: 16px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.app-confirm-campo label { font-size: .8rem; font-weight: 600; color: var(--t2); }
.app-confirm-campo textarea { width: 100%; resize: vertical; min-height: 72px; }
.app-confirm-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.app-confirm-actions .btn { flex: 1; justify-content: center; }

@media (max-width: 480px) {
    .app-confirm { padding: 20px; }
}

/* Variante larga do .auth-wrapper — usada pelas páginas de texto longo
   (Termos de Uso, Política de Privacidade) que reaproveitam o layout de
   autenticação mas não cabem no card estreito de 430px. */
.auth-wrapper--wide { max-width: 760px; }
.auth-wrapper--wide .auth-card { text-align: left; }

/* Checkbox + rótulo lado a lado (ex.: aceite de termos no cadastro) */
.form-check-label {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: .85rem; font-weight: 400; color: var(--t2); cursor: pointer;
}
.form-check-label input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }

/* Widget Cloudflare Turnstile: data-size="flexible" já ocupa a largura do
   form; aqui só arredondamos as bordas pra combinar com os demais campos
   (overflow:hidden é a única forma de "arredondar" um iframe de fora). */
.cf-turnstile { border-radius: var(--radius-sm); overflow: hidden; }
.cf-turnstile iframe, .cf-turnstile > div { border-radius: var(--radius-sm) !important; }

/* Estado de carregamento genérico para botões (.btn-loading) — usado em
   submits AJAX pra dar feedback imediato de que a ação está em andamento
   (ex.: login). Esconde o texto e mostra um spinner central; a cor do
   spinner assume texto branco (botões .btn-primary/.btn-danger/.btn-accent). */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
    content: "";
    position: absolute; top: 50%; left: 50%;
    width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border: 2.5px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-loading-spin .6s linear infinite;
}
@keyframes btn-loading-spin { to { transform: rotate(360deg); } }
