/* ==========================================================================
   Portal da Transparência - Prefeitura de Ecoporanga/ES
   Design System central (parte pública)
   Paleta oficial: ecoporanga.es.gov.br
   -------------------------------------------------------------------------
   Este arquivo centraliza cores, tipografia, botões, cards, tabelas e
   responsividade. Para mudar a identidade visual, altere apenas as
   variáveis em :root abaixo.
   ========================================================================== */

:root {
    /* Paleta institucional */
    --c-primary:        #0B3D91; /* Azul principal (confiança) */
    --c-primary-dark:   #082B63; /* Azul escuro (cabeçalhos/rodapé) */
    --c-primary-darker: #061F49; /* Azul mais escuro (barra inferior) */
    --c-secondary:      #2563EB; /* Azul médio (links/realces) */
    --c-accent:         #16A34A; /* Verde transparência (sucesso/destaque) */
    --c-warning:        #F59E0B; /* Amarelo ouro (alerta/ação) */
    --c-danger:         #DC2626; /* Vermelho (erros) */

    --c-bg:             #F5F7FA; /* Fundo claro (cinza gelo) */
    --c-surface:        #FFFFFF; /* Superfície de cards */
    --c-surface-soft:   #F8FAFD; /* Superfície levemente azulada */
    --c-text:           #1F2937; /* Texto (grafite) */
    --c-muted:          #6B7280; /* Texto secundário */
    --c-border:         #E5E7EB; /* Bordas */
    --c-primary-soft:   #E8EEF9; /* Azul bem claro (ícones/badges) */

    /* Tipografia */
    --font-base: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Layout */
    --sidebar-width: 270px;
    --header-height: 92px;

    /* Formas */
    --radius-sm: 10px;
    --radius:    16px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow:    0 10px 28px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 18px 42px rgba(11, 61, 145, 0.14);

    --transition: 0.2s ease;
}

/* ===== Base ============================================================== */
* { box-sizing: border-box; }

body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font-base);
    font-size: 16px;
    line-height: 1.6;
}

a { text-decoration: none; color: var(--c-secondary); transition: color var(--transition); }
a:hover { color: var(--c-primary); }

h1, h2, h3, h4, h5 { color: var(--c-primary-dark); }

:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== Cabeçalho ======================================================== */
.top-header {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 55%, var(--c-secondary) 130%);
    color: #fff;
    padding: 16px 0;
    box-shadow: 0 4px 14px rgba(8, 43, 99, 0.25);
    position: sticky;
    top: 0;
    z-index: 1200;
}

.top-header .brand-area { display: flex; align-items: center; gap: 14px; }

.brand-logo {
    width: 58px; height: 58px;
    border-radius: 14px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.brand-logo i { font-size: 28px; color: var(--c-primary); }

.brand-text h1 { margin: 0; font-size: 1.3rem; font-weight: 700; color: #fff; line-height: 1.15; }
.brand-text p  { margin: 0; font-size: 0.86rem; opacity: 0.92; }

.header-search form { display: flex; gap: 8px; }
.header-search input {
    min-width: 260px;
    border-radius: var(--radius-pill);
    border: none;
    padding: 10px 18px;
    font-size: 0.95rem;
}
.header-search .btn {
    border-radius: var(--radius-pill);
    padding: 10px 20px;
    font-weight: 600;
    white-space: nowrap;
}

/* ===== Layout: sidebar + conteúdo ====================================== */
.portal-wrapper {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--c-primary-dark);
    color: #fff;
    padding: 22px 16px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    box-shadow: 4px 0 18px rgba(8, 43, 99, 0.10);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.65);
    margin-bottom: 16px;
    padding: 0 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-title i { color: #fff; }

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar-nav a {
    color: rgba(255,255,255,0.90);
    padding: 12px 14px;
    border-radius: 12px;
    display: flex; align-items: center; gap: 12px;
    font-weight: 500;
    font-size: 0.97rem;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a i { font-size: 1.1rem; opacity: 0.9; }
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.10);
    color: #fff;
}
.sidebar-nav a.active {
    background: rgba(37, 99, 235, 0.28);
    color: #fff;
    border-left-color: var(--c-warning);
    font-weight: 600;
}

.content-area { flex: 1; padding: 26px; min-width: 0; }

/* ===== Botões ========================================================== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 9px 18px;
    transition: all var(--transition);
    border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--c-primary); border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }

.btn-secondary { background: var(--c-secondary); border-color: var(--c-secondary); color:#fff; }
.btn-secondary:hover { background: #1d4fd0; border-color: #1d4fd0; }

.btn-success, .btn-accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn-success:hover, .btn-accent:hover { background: #12833c; border-color: #12833c; color:#fff; }

.btn-warning {
    background: var(--c-warning); border-color: var(--c-warning); color: #3d2b00;
}
.btn-warning:hover { background: #e08d06; border-color: #e08d06; color:#3d2b00; }

.btn-outline-primary { color: var(--c-primary); border-color: var(--c-primary); background:#fff; }
.btn-outline-primary:hover { background: var(--c-primary); color: #fff; }

.btn-light { background:#fff; border-color:#fff; color: var(--c-primary); }
.btn-light:hover { background:#eef2f7; color: var(--c-primary-dark); }

/* Botão "Voltar" padronizado */
.btn-voltar {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff; color: var(--c-primary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-pill);
    padding: 8px 16px; font-weight: 600; font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}
.btn-voltar:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); }

/* ===== Cabeçalho de página interna ===================================== */
.page-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}
.page-head .page-title {
    font-size: 1.55rem; font-weight: 800; color: var(--c-primary-dark);
    margin: 0; display: flex; align-items: center; gap: 10px;
}
.page-head .page-title i { color: var(--c-primary); }
.page-head .page-subtitle { color: var(--c-muted); margin: 4px 0 0; font-size: 0.95rem; }

.data-atualizacao {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: var(--c-muted);
    background: var(--c-surface); border: 1px solid var(--c-border);
    padding: 5px 12px; border-radius: var(--radius-pill);
}
.data-atualizacao i { color: var(--c-accent); }

/* ===== Cards genéricos ================================================= */
.card, .content-card, .summary-card, .quick-link-card, .chart-box,
.search-box, .welcome-simple, .info-banner {
    border-radius: var(--radius-lg);
}

/* ===== Tabelas modernas =============================================== */
.portal-table-wrap {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.portal-table-wrap .table-responsive { border-radius: var(--radius-lg); }

table.portal-table, .portal-table-wrap table.table {
    margin: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.94rem;
}
.portal-table thead th, .portal-table-wrap thead th {
    background: var(--c-primary);
    color: #fff;
    font-weight: 600;
    padding: 14px 16px;
    border: none;
    white-space: nowrap;
    vertical-align: middle;
    font-size: 0.9rem;
}
.portal-table tbody td, .portal-table-wrap tbody td {
    padding: 12px 16px;
    border-top: 1px solid var(--c-border);
    vertical-align: middle;
    color: var(--c-text);
}
.portal-table tbody tr:nth-child(even) td,
.portal-table-wrap tbody tr:nth-child(even) td { background: var(--c-surface-soft); }
.portal-table tbody tr:hover td,
.portal-table-wrap tbody tr:hover td { background: var(--c-primary-soft); }

/* Badges de status */
.badge-status {
    display: inline-block; padding: 4px 12px; border-radius: var(--radius-pill);
    font-size: 0.78rem; font-weight: 600;
}
.badge-status.is-ok    { background: #dcfce7; color: #14683a; }
.badge-status.is-wait  { background: #fef3c7; color: #92600a; }
.badge-status.is-off   { background: #fee2e2; color: #991b1b; }
.badge-status.is-info  { background: var(--c-primary-soft); color: var(--c-primary); }

/* ===== Estado vazio (sem dados) ======================================= */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--c-muted);
    background: var(--c-surface);
    border: 1px dashed var(--c-border);
    border-radius: var(--radius-lg);
}
.empty-state .empty-icon {
    width: 72px; height: 72px; margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--c-primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--c-primary);
}
.empty-state h3 { color: var(--c-text); font-size: 1.1rem; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 0.95rem; }

/* Estado vazio compacto (dentro de card pequeno) */
.empty-inline {
    text-align: center; color: var(--c-muted); padding: 18px 6px;
}
.empty-inline i { font-size: 1.6rem; color: var(--c-primary-soft); display:block; margin-bottom: 6px; }

/* ===== Paginação ====================================================== */
.pagination .page-link { color: var(--c-primary); border-radius: 8px; margin: 0 3px; border-color: var(--c-border); }
.pagination .page-item.active .page-link { background: var(--c-primary); border-color: var(--c-primary); color:#fff; }

/* ===== Formulários / filtros ========================================= */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--c-border);
    padding: 9px 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--c-secondary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.filtro-bar {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

/* ===== Acessibilidade (botão flutuante) ============================== */
.accessibility-floating-btn { right: 20px; bottom: 20px; z-index: 1300; border-radius: var(--radius-pill); box-shadow: var(--shadow); }
.accessibility-menu { right: 20px; bottom: 80px; z-index: 1300; width: 280px; box-shadow: var(--shadow); border-radius: var(--radius); }

/* Alto contraste */
.high-contrast, .high-contrast body { background: #000 !important; color: #fff !important; }
.high-contrast .card, .high-contrast .chart-card, .high-contrast .chart-box,
.high-contrast .content-card, .high-contrast .summary-card, .high-contrast .welcome-box,
.high-contrast .table, .high-contrast .portal-table-wrap, .high-contrast .sidebar,
.high-contrast .top-header, .high-contrast footer {
    background: #111 !important; color: #fff !important; border-color: #fff !important;
}
.high-contrast .portal-table thead th { background:#000 !important; }
.high-contrast a, .high-contrast h1, .high-contrast h2, .high-contrast h3,
.high-contrast p, .high-contrast td, .high-contrast th, .high-contrast li,
.high-contrast span, .high-contrast label { color: #fff !important; }

/* ===== Rodapé ========================================================= */
.portal-footer { background: var(--c-primary-dark); color: #fff; margin-top: 48px; }
.portal-footer h5 { color: #fff; font-size: 1.05rem; margin-bottom: 14px; display:flex; align-items:center; gap:8px; }
.portal-footer a { color: rgba(255,255,255,0.88); }
.portal-footer a:hover { color: #fff; text-decoration: underline; }
.portal-footer p { color: rgba(255,255,255,0.82); }
.portal-footer .footer-links { list-style: none; padding: 0; margin: 0; line-height: 2; }
.portal-footer .footer-bottom {
    background: var(--c-primary-darker);
    text-align: center; padding: 14px; font-size: 0.88rem;
    color: rgba(255,255,255,0.85);
}

/* ===== Responsivo ===================================================== */
@media (max-width: 991.98px) {
    .portal-wrapper { flex-direction: column; }
    .sidebar {
        position: fixed;
        left: -100%; top: var(--header-height);
        width: 84%; max-width: 300px;
        height: calc(100vh - var(--header-height));
        z-index: 1250;
        transition: left 0.3s ease;
    }
    .sidebar.show { left: 0; }
    .content-area { padding: 18px; }
    .header-search input { min-width: 0; width: 100%; }
    .header-search form { flex-direction: row; }
}

@media (max-width: 767.98px) {
    body { font-size: 15px; }
    .brand-text h1 { font-size: 1.05rem; }
    .brand-text p { font-size: 0.76rem; }
    .brand-logo { width: 48px; height: 48px; }
    .page-head .page-title { font-size: 1.25rem; }
    /* Tabelas roláveis no celular */
    .portal-table-wrap .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* Overlay para sidebar mobile */
.sidebar-overlay {
    display: none;
    position: fixed; inset: var(--header-height) 0 0 0;
    background: rgba(6, 31, 73, 0.45);
    z-index: 1240;
}
.sidebar-overlay.show { display: block; }
