body { font-family: 'Inter', sans-serif; background-color: var(--bs-body-bg); }

/* Cor de marca vem de PHP via --primary / --secondary */
.bg-alhandra { background: linear-gradient(135deg, var(--primary), var(--primary-hover-admin)) !important; color: white; }
.text-alhandra { color: var(--primary) !important; }
.bg-secondary-alhandra { background: linear-gradient(135deg, var(--secondary), var(--secondary-hover-admin)) !important; color: white; }

.admin-card { border: none; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.admin-card:hover { transform: translateY(-2px); box-shadow: 0 15px 40px rgba(0,0,0,0.08); }

.table-custom th { background-color: var(--primary-light-admin); font-weight: 600; color: var(--primary); border-bottom: 2px solid var(--primary); }
.stat-icon { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }

.page-link { color: var(--primary); }
.page-item.active .page-link { background-color: var(--primary); border-color: var(--primary); }

.modal-pdf-header { border-bottom: 2px solid var(--primary); padding-bottom: 15px; margin-bottom: 20px; text-align: center; }

.badge-tema { font-size: 0.85rem; padding: 6px 10px; font-weight: 600; background-color: var(--primary-light-admin); color: var(--primary); border: 1px solid var(--primary-light-admin); margin-right: 5px; border-radius: 6px; }

.badge-prio { font-size: 0.78rem; padding: 5px 10px; font-weight: 700; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-prio-alta   { background: rgba(220, 38, 38, 0.12); color: #b91c1c; border: 1px solid rgba(220, 38, 38, 0.3); }
.badge-prio-media  { background: rgba(245, 158, 11, 0.14); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-prio-baixa  { background: rgba(34, 197, 94, 0.14);  color: #15803d; border: 1px solid rgba(34, 197, 94, 0.3); }

/* === DASHBOARD: header === */
.dash-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}

/* === CHARTS: container com altura FIXA — evita o loop infinito do Chart.js === */
.chart-box {
    position: relative;
    width: 100%;
    height: 320px;
}
.chart-box-sm   { height: 260px; }
.chart-box-tall { height: 460px; }
.chart-box canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}
@media (max-width: 575.98px) {
    .chart-box      { height: 280px; }
    .chart-box-sm   { height: 240px; }
    .chart-box-tall { height: 420px; }
}

/* === KPIs === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}
.kpi-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover-admin));
    color: #fff; border-radius: 16px; padding: 18px 20px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden; position: relative;
}
.kpi-card::after {
    content: ''; position: absolute; top: -30px; right: -30px;
    width: 110px; height: 110px; border-radius: 50%;
    background: rgba(255,255,255,0.08);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0,0,0,0.12); }
.kpi-icon {
    width: 50px; height: 50px; border-radius: 12px;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0; z-index: 1;
}
.kpi-info { z-index: 1; min-width: 0; flex: 1; }
.kpi-label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px;
    opacity: 0.85; font-weight: 600; margin-bottom: 2px;
}
.kpi-value {
    font-size: 1.9rem; font-weight: 800; line-height: 1.1;
}

.kpi-grad-1 { background: linear-gradient(135deg, var(--primary), var(--primary-hover-admin)); }
.kpi-grad-2 { background: linear-gradient(135deg, #f97316, #c2410c); }
.kpi-grad-3 { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.kpi-grad-4 { background: linear-gradient(135deg, var(--secondary), var(--secondary-hover-admin)); }
.kpi-grad-5 { background: linear-gradient(135deg, #ec4899, #be185d); }
.kpi-grad-6 { background: linear-gradient(135deg, #f59e0b, #b45309); }
.kpi-grad-7 { background: linear-gradient(135deg, #dc2626, #991b1b); }
.kpi-grad-8 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }

@media (max-width: 1199.98px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575.98px)  { .kpi-grid { grid-template-columns: 1fr; } .kpi-value { font-size: 1.6rem; } }

/* === TOP APOIOS === */
.top-apoios { list-style: none; padding: 0; margin: 0; }
.top-apoios li {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 0; border-bottom: 1px dashed var(--bs-border-color);
}
.top-apoios li:last-child { border-bottom: 0; }
.top-apoios .rank {
    flex-shrink: 0; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light-admin); color: var(--primary);
    border-radius: 10px; font-weight: 800; font-size: 0.85rem;
}
.top-apoios .apoio-content { flex: 1; min-width: 0; }
.top-apoios .apoio-area {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--primary); font-weight: 700; margin-bottom: 4px;
}
.top-apoios .apoio-desc {
    color: var(--bs-body-color); font-size: 0.92rem;
    margin: 0 0 8px; line-height: 1.4;
}
.top-apoios .apoio-bar {
    width: 100%; height: 6px; background: rgba(0,0,0,0.06);
    border-radius: 3px; overflow: hidden;
}
.top-apoios .apoio-bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), #f59e0b);
    transition: width 0.6s ease;
}
.top-apoios .apoio-count {
    flex-shrink: 0; font-weight: 800; font-size: 1rem;
    color: var(--bs-body-color);
}

/* === ATIVIDADE FEED === */
.atividade-feed { list-style: none; padding: 0; margin: 0; }
.atividade-item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px; border-radius: 12px;
    border: 1px solid var(--bs-border-color);
    margin-bottom: 8px; background: var(--bs-body-bg);
    transition: background 0.3s;
}
.atividade-icon {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0; font-size: 0.95rem;
    background: var(--primary);
}
.atividade-icon.prio-alta  { background: #dc2626; }
.atividade-icon.prio-media { background: #f59e0b; }
.atividade-icon.prio-baixa { background: #22c55e; }
.atividade-info { flex: 1; min-width: 0; }
.atividade-areas { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge-tema-mini {
    background: var(--primary-light-admin); color: var(--primary);
    font-size: 0.72rem; padding: 2px 8px; border-radius: 6px; font-weight: 600;
}
.atividade-tempo {
    font-size: 0.85rem; color: var(--bs-secondary-color);
    flex-shrink: 0; font-weight: 600;
}

@media (max-width: 575.98px) {
    .atividade-item { gap: 10px; padding: 10px; }
    .atividade-icon { width: 34px; height: 34px; }
    .top-apoios li { gap: 10px; }
    .top-apoios .rank { width: 30px; height: 30px; font-size: 0.78rem; }
}

/* === ADMIN SHELL: sidebar + main === */
.admin-shell { display: flex; min-height: 100vh; background: var(--bs-body-bg); }
.admin-main  { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-content { flex: 1; padding: 32px 36px; }

/* === Sidebar === */
.admin-sidebar {
    width: 260px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary), var(--primary-hover-admin));
    color: #fff;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1.25rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-header img {
    height: 56px; width: auto; max-width: 100%;
    background: rgba(255,255,255,0.95);
    padding: 8px 12px; border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}
.sidebar-titulo { color: #fff; font-weight: 700; margin: 0; font-size: 1rem; }
.sidebar-subtitulo { color: rgba(255,255,255,0.7); font-size: 0.78rem; }

.sidebar-nav {
    padding: 1rem 0.75rem; flex: 1;
    display: flex; flex-direction: column; gap: 4px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; border-radius: 10px;
    color: rgba(255,255,255,0.85) !important;
    text-decoration: none; font-weight: 600; font-size: 0.95rem;
    transition: all 0.2s ease;
    position: relative;
}
.sidebar-link i { width: 22px; text-align: center; font-size: 1.05rem; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,0.12); color: #fff !important; transform: translateX(2px); }
.sidebar-link.active {
    background: rgba(255,255,255,0.18);
    color: #fff !important;
    box-shadow: inset 4px 0 0 #fff;
}
.sidebar-link-danger:hover    { background: rgba(220,38,38,0.4); color: #fff !important; }
.sidebar-link-secondary:hover { background: rgba(255,255,255,0.1); }

.sidebar-footer {
    padding: 0.75rem 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    display: flex; flex-direction: column; gap: 4px;
}

/* === Topbar (mobile) === */
.admin-topbar { display: none; }
.topbar-burger {
    background: var(--primary-light-admin); color: var(--primary);
    border: none; width: 42px; height: 42px; border-radius: 10px;
    font-size: 1.1rem; cursor: pointer; transition: all 0.2s;
}
.topbar-burger:hover { background: var(--primary); color: #fff; }
.topbar-brand { text-decoration: none; font-size: 1.1rem; }

/* === Overlay (mobile) === */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1040;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* === Mobile (< 992px) === */
@media (max-width: 991.98px) {
    .admin-sidebar {
        position: fixed; left: 0; top: 0;
        height: 100vh;
        transform: translateX(-105%);
        box-shadow: 6px 0 30px rgba(0,0,0,0.25);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content { padding: 20px 16px; }
    .admin-topbar {
        display: flex; align-items: center; gap: 12px;
        padding: 12px 16px;
        background: var(--bs-body-bg);
        border-bottom: 1px solid var(--bs-border-color);
        position: sticky; top: 0; z-index: 1030;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
}

.color-preview { width: 100%; height: 90px; border-radius: 12px; border: 2px solid rgba(0,0,0,0.05); }

/* === Modal de Detalhes === */
.modal-detalhes .modal-content { border-radius: 18px; overflow: hidden; }
.modal-detalhes .modal-header { padding: 1.25rem 1.5rem; }
.modal-detalhes .dado-item { background: var(--bs-light); border-radius: 12px; padding: 14px 16px; height: 100%; border: 1px solid rgba(0,0,0,0.04); }
.modal-detalhes .dado-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--bs-secondary-color); font-weight: 700; margin-bottom: 4px; }
.modal-detalhes .dado-valor { font-size: 1rem; font-weight: 600; color: var(--bs-body-color); word-break: break-word; }
.modal-detalhes .mini-mapa { width: 100%; height: 220px; border-radius: 12px; overflow: hidden; border: 2px solid rgba(0,0,0,0.05); }
.modal-detalhes .proposta-item { margin-bottom: 18px; padding: 16px; background: var(--bs-light); border-left: 4px solid var(--primary); border-radius: 10px; }
.modal-detalhes .proposta-item .badge-tema { margin-bottom: 10px; display: inline-block; }
.modal-detalhes .proposta-texto { color: var(--bs-body-color); line-height: 1.55; }

/* === Tabela de Registos: faixa colorida por prioridade === */
.table-registos tr.prio-row { border-left: 4px solid transparent; }
.table-registos tr.prio-alta  { border-left-color: #dc2626; }
.table-registos tr.prio-media { border-left-color: #f59e0b; }
.table-registos tr.prio-baixa { border-left-color: #22c55e; }
.table-registos td { vertical-align: middle; }

/* === Mobile: tabela vira cards (até 991px) === */
@media (max-width: 991.98px) {
    .table-registos { border: 0; }
    .table-registos thead { display: none; }
    .table-registos, .table-registos tbody, .table-registos tr, .table-registos td {
        display: block; width: 100%;
    }
    .table-registos tr {
        background: var(--bs-body-bg);
        border: 1px solid var(--bs-border-color) !important;
        border-left-width: 4px !important;
        border-radius: 12px;
        padding: 14px 16px;
        margin-bottom: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    }
    .table-registos td {
        padding: 8px 0 !important;
        border: 0 !important;
        display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    }
    .table-registos td::before {
        content: attr(data-label);
        font-weight: 700; color: var(--bs-secondary-color);
        font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px;
        flex-shrink: 0; min-width: 80px; padding-top: 2px;
    }
    .table-registos td > * { text-align: right; flex: 1; min-width: 0; }
    .table-registos td .d-flex.flex-wrap { justify-content: flex-end; }
    .table-registos td.text-center { justify-content: center; }
    .table-registos td.text-center::before { display: none; }
    .table-registos .btn-group { width: 100%; justify-content: center; }
}

/* Responsive admin extras */
@media (max-width: 767px) {
    .stat-icon { width: 48px; height: 48px; font-size: 1.2rem; }
    .display-5 { font-size: 1.8rem; }
    .modal-detalhes .modal-header { flex-wrap: wrap; gap: 8px; }
    .admin-content { padding: 16px 12px; }
}
