/*
 * Personalizacao do fundo, independente das cores funcionais do sistema.
 * Indicadores, alertas e botoes mantem a paleta original.
 */
body[data-theme] {
    --primary: #0f9a8f;
    --primary-dark: #08756d;
    --primary-rgb: 15, 154, 143;
    --primary-light: #86d9c9;
    --primary-soft: #e7f8f5;
    --surface-subtle: #f3fbf9;
    --surface-selected: #dff6ef;
    --surface-icon: #c7f0e4;
}

body[data-theme="mint"] {
    --theme-canvas-start: #f4faf9;
    --theme-canvas-end: #e8f4f2;
    --theme-panel: #fcfffe;
    --theme-chrome: #f9fdfc;
    --theme-choice-accent: #0f9a8f;
    --theme-choice-tint: #e7f8f5;
    --theme-card: #ffffff;
    --theme-card-line: #d8e8e5;
    --theme-menu-row: #f2fbf9;
    --theme-menu-line: #cce9e4;
    --theme-selected: #dff6ef;
    --theme-bubble: #c7f0e4;
    --theme-ink-accent: #08756d;
}

body[data-theme="blue"] {
    --theme-canvas-start: #edf5ff;
    --theme-canvas-end: #dceaff;
    --theme-panel: #f9fcff;
    --theme-chrome: #f5faff;
    --theme-choice-accent: #2478d4;
    --theme-choice-tint: #eaf4ff;
    --theme-card: #ffffff;
    --theme-card-line: #cfdef0;
    --theme-menu-row: #f0f7ff;
    --theme-menu-line: #cbdff5;
    --theme-selected: #deedff;
    --theme-bubble: #c8e2ff;
    --theme-ink-accent: #155799;
}

body[data-theme="rose"] {
    --theme-canvas-start: #fff1f6;
    --theme-canvas-end: #fbe4ee;
    --theme-panel: #fffbfd;
    --theme-chrome: #fff7fa;
    --theme-choice-accent: #df5f8f;
    --theme-choice-tint: #fff0f6;
    --theme-card: #fffefd;
    --theme-card-line: #efd0dc;
    --theme-menu-row: #fff2f7;
    --theme-menu-line: #f2d3df;
    --theme-selected: #ffe5ef;
    --theme-bubble: #ffd6e4;
    --theme-ink-accent: #9c315d;
}

body[data-theme="lilac"] {
    --theme-canvas-start: #f5f0ff;
    --theme-canvas-end: #e9e3fa;
    --theme-panel: #fcfaff;
    --theme-chrome: #faf7ff;
    --theme-choice-accent: #7b61d8;
    --theme-choice-tint: #f1eeff;
    --theme-card: #fffefe;
    --theme-card-line: #dfd6f2;
    --theme-menu-row: #f6f2ff;
    --theme-menu-line: #e1d8f5;
    --theme-selected: #eee7ff;
    --theme-bubble: #ddd2fb;
    --theme-ink-accent: #5740a0;
}

body[data-theme="sunny"] {
    --theme-canvas-start: #fff7e8;
    --theme-canvas-end: #f9ebcf;
    --theme-panel: #fffdf8;
    --theme-chrome: #fffbf2;
    --theme-choice-accent: #d98919;
    --theme-choice-tint: #fff6dd;
    --theme-card: #fffefa;
    --theme-card-line: #eadbb9;
    --theme-menu-row: #fff9e9;
    --theme-menu-line: #f1e2bf;
    --theme-selected: #fff0cb;
    --theme-bubble: #ffe2a5;
    --theme-ink-accent: #875412;
}

body[data-theme] {
    background: linear-gradient(160deg, var(--theme-canvas-start), var(--theme-canvas-end)) fixed !important;
}

:is(.panel, .table-card, .timeline, .auth-card) {
    background-color: var(--theme-panel);
}

:is(.sidebar, .mobile-topbar) {
    background-color: var(--theme-chrome);
}

/* Vacinas usa cores de estado clinico; seus paineis nao herdam a paleta pessoal. */
body[data-theme] :is(.vaccine-toolbar, .vaccine-source-note, .vaccine-filter-panel, .vaccine-card) {
    background-color: #fff;
}

.theme-choice:has(input:checked) {
    background: var(--theme-choice-tint);
    border-color: var(--theme-choice-accent);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-choice-accent) 12%, transparent);
}

/* Fundos de organizacao acompanham o tema; checks e alertas mantem suas cores. */
body[data-theme] .menu-order-item:not(.is-hidden) {
    background: var(--theme-menu-row);
    border-color: var(--theme-menu-line);
}
body[data-theme] .menu-order-position {
    background: var(--theme-bubble);
    color: var(--theme-ink-accent);
}
body[data-theme] .sidebar .sidebar-account-toggle {
    background: var(--theme-panel);
    border-color: var(--theme-menu-line);
}
body[data-theme] .sidebar .sidebar-account.is-open .sidebar-account-toggle {
    background: var(--theme-menu-row);
    border-color: var(--theme-menu-line);
}
body[data-theme] .sidebar nav a:is(:hover, .is-active),
body[data-theme] .sidebar-account-menu a:is(:hover, .is-active),
body[data-theme] .account-menu-cell:is(:hover, :focus-visible, .is-active) {
    background: var(--theme-selected);
    color: var(--theme-ink-accent);
}
body[data-theme] .sidebar nav a.is-active :is(.nav-svg, .mini-svg) {
    background: var(--theme-bubble);
    border-color: var(--theme-bubble);
    color: var(--theme-ink-accent);
}
body[data-theme] .sidebar nav a.is-active::before {
    background: var(--theme-bubble);
    border-color: var(--theme-bubble);
}
body[data-theme] .sidebar .mobile-sidebar-close {
    background: #f1f4f7 !important;
    border-color: #d7e0e7;
    color: #617187;
}
body.menu-open .mobile-menu-icon::before {
    color: #617187;
}

/* Os cartoes brancos se destacam do fundo pastel sem alterar seus selos. */
.public-guide-catalog .catalog-card {
    background: var(--theme-card);
    border-color: var(--theme-card-line);
    box-shadow: 0 7px 20px color-mix(in srgb, var(--theme-ink-accent) 9%, transparent);
}

/* A listagem de primeiros socorros usa o mesmo controle compacto de ajuda. */
.first-aid-catalog-shell .catalog-panel-heading {
    padding-right: 258px;
}
.first-aid-catalog-shell .first-aid-urgent-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.first-aid-urgent-panel .care-urgent-links span {
    font-size: 12px;
}
.first-aid-urgent-panel .care-urgent-links small {
    font-size: 10px;
}
.public-guide-detail .first-aid-urgent-panel {
    background: transparent;
    border: 0;
    box-shadow: none;
    display: block;
    margin: 0 0 12px;
    padding: 0;
}
.public-guide-detail .first-aid-urgent-panel .care-urgent-toggle {
    display: grid;
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
    width: min(280px, 100%);
}
.public-guide-detail .first-aid-urgent-panel .care-urgent-contacts {
    background: var(--theme-card);
    border: 1px solid #efd0cb;
    border-radius: 10px;
    margin-top: 8px;
    padding: 5px;
}
.public-guide-detail .first-aid-urgent-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Menos espaco morto nos filtros, sem reduzir os alvos de toque. */
.public-guide-catalog .catalog-search-panel {
    padding: 16px 18px;
}
.public-guide-catalog .catalog-filter-form {
    gap: 8px;
    margin-top: 9px;
    padding-top: 9px;
}
.public-guide-catalog .catalog-filter-form label {
    gap: 3px;
}

@media (max-width: 720px) {
    .public-guide-catalog .catalog-search-panel {
        padding: 12px;
    }
    .public-guide-catalog .catalog-panel-heading h2 {
        font-size: 19px;
        line-height: 1.2;
        margin-bottom: 0;
    }
    .public-guide-catalog .catalog-panel-heading p {
        font-size: 13px;
        margin-top: 3px;
    }
    .public-guide-catalog .catalog-filter-form {
        gap: 7px;
        margin-top: 8px;
        padding-top: 9px;
    }
    .public-guide-catalog .catalog-filter-form :is(input, select, button) {
        min-height: 44px;
    }
    .first-aid-catalog-shell .catalog-panel-heading {
        padding-right: 0;
    }
    .public-guide-catalog .first-aid-filter-form.catalog-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .public-guide-catalog .first-aid-filter-form.catalog-filter-form > button {
        grid-column: 3;
        padding-inline: 5px;
    }
    .first-aid-catalog-shell .first-aid-urgent-links,
    .public-guide-detail .first-aid-urgent-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .first-aid-urgent-links a:last-child {
        grid-column: 1 / -1;
    }
}
