/* ═══════════════════════════════════════════════════════════════════
   BASE CSS — typography, reset, scrollbar.
   Depends on tokens.css being loaded first.
   Class prefix: .ia-  (avoids Bootstrap conflicts).

   Sessão 5 split: componentes mudaram para arquivos próprios em
   static/shared/* (buttons, tables, forms, filters, nav, layout, tabs,
   badges, pagination, cards, banners, kpi, messages, impersonation,
   home-modules) e static/modules/* (agenda, doc-modules).
   Cascade preservado pela ordem dos <link> em templates/base_master.html
   (tokens primeiro, base por último).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Box-sizing reset ── */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ── Typography ── */
body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* ── Scrollbar theming ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

dialog { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Editor mestre–detalhe de regras municipais ── */
.ia-rule-workspace {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.ia-rule-index {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 20px;
}

.ia-rule-index-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 65vh;
    overflow-y: auto;
}

.ia-rule-index-item {
    appearance: none;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 11px 12px;
    text-align: left;
    cursor: pointer;
}

.ia-rule-index-item:hover,
.ia-rule-index-item.is-active {
    border-color: var(--accent);
}

.ia-rule-index-item.is-active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.ia-rule-index-label,
.ia-rule-index-item small {
    display: block;
}

.ia-rule-index-label {
    font-weight: 600;
}

.ia-rule-index-item small {
    color: var(--text-secondary);
    margin-top: 4px;
}

.ia-rule-index .ia-rule-index-mobile {
    display: none;
}

.ia-rule-detail,
.ia-rule-editor-row {
    min-width: 0;
}

.ia-rule-cargo-search {
    max-width: 440px;
    margin: 16px 0;
}

@media (max-width: 900px) {
    .ia-rule-workspace {
        grid-template-columns: 1fr;
    }

    .ia-rule-index {
        position: static;
    }

    .ia-rule-index-list {
        display: none;
    }

    .ia-rule-index .ia-rule-index-mobile {
        display: block;
    }
}
