@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== SKIP LINK (ACESSIBILIDADE) ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #0d47a1;
    color: #fff;
    padding: 8px 16px;
    z-index: 300;
    transition: top 0.3s;
    text-decoration: none;
    font-weight: bold;
}
.skip-link:focus { top: 0; }

/* ===== FOCUS VISIBLE (ACESSIBILIDADE) ===== */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid #42a5f5;
    outline-offset: 2px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== TODOS OS TÍTULOS EM MAIÚSCULO ===== */
h1, h2, h3, h4, h5, h6,
.page-header h2, .page-header p,
.accordion-header h3,
.nav-section-title,
.card .label,
th, legend, label,
.sidebar a, .sidebar-nav a {
    text-transform: uppercase;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    color: #1a1a2e;
    min-height: 100vh;
    display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px;
    height: 100vh;
    background: #0d47a1;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
    overflow: hidden;
}
.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    text-align: center;
}
.sidebar-logo {
    width: 80px;
    margin-bottom: 6px;
    filter: brightness(0) invert(1);
}
.sidebar-header h1 {
    font-size: 1.1em;
    letter-spacing: 0.5px;
}
.sidebar-header small {
    font-size: 0.75em;
    color: #bbdefb;
    display: block;
    margin-top: 4px;
}
.sidebar-selectors {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.ano-selector, .cargo-selector {
    padding: 6px 10px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    color: #fff;
    font-size: 0.82em;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.ano-selector {
    width: 42%;
}
.cargo-selector {
    width: 58%;
}
.ano-selector:hover, .cargo-selector:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}
.ano-selector:focus, .cargo-selector:focus {
    border-color: #42a5f5;
}
.ano-selector option, .cargo-selector option {
    background: #0d47a1;
    color: #fff;
}
.sidebar nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.sidebar nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}
.sidebar nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    color: #bbdefb;
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover,
.sidebar nav a:focus {
    background: rgba(255,255,255,0.1);
    color: #fff;
    outline: 2px solid #42a5f5;
    outline-offset: -2px;
}
.sidebar nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: #42a5f5;
    font-weight: bold;
}
.sidebar nav a .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar nav a .icon svg {
    width: 18px;
    height: 18px;
}
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    background: #0d47a1;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.sidebar-toggle svg {
    width: 22px;
    height: 22px;
}

/* ===== MAIN ===== */
.main {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
}
.page-header {
    background: linear-gradient(135deg, #0d47a1, #1565c0, #1976d2);
    padding: 22px 30px;
    color: #fff;
}
.page-header h2 {
    font-size: 1.4em;
    letter-spacing: 0.5px;
}
.page-header p {
    font-size: 0.9em;
    color: #bbdefb;
    margin-top: 3px;
}
.content {
    padding: 25px 30px;
    max-width: 1200px;
}

/* ===== CARDS ===== */
.cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}
.card {
    background: #e3f2fd;
    border-radius: 10px;
    padding: 16px 24px;
    text-align: center;
    min-width: 150px;
    flex: 1;
    border: 1px solid #bbdefb;
}
.card .number {
    font-size: 2em;
    font-weight: bold;
    color: #0d47a1;
}
.card .label {
    font-size: 0.8em;
    color: #546e7a;
    margin-top: 3px;
    letter-spacing: 0.3px;
}

/* ===== SELETOR ===== */
.selector {
    margin-bottom: 25px;
}
.selector label {
    display: block;
    font-size: 0.85em;
    color: #546e7a;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    font-weight: 500;
}
.selector select,
.selector input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    background: #f5f9ff;
    color: #1a1a2e;
    font-size: 1em;
    outline: none;
}
.selector select:focus,
.selector input:focus {
    border-color: #1976d2;
    outline: 2px solid #42a5f5;
    outline-offset: -1px;
}
.search-box:focus {
    border-color: #1976d2;
    outline: 2px solid #42a5f5;
    outline-offset: -1px;
}
.selector-row {
    display: flex;
    gap: 16px;
}
.selector-row .selector {
    flex: 1;
}

/* ===== ACCORDION ===== */
.accordion {
    background: #fff;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}
.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    cursor: pointer;
    user-select: none;
    background: #f5f9ff;
    border-bottom: 2px solid #e3f2fd;
    transition: background 0.2s;
}
.accordion-header:hover { background: #e3f2fd; }
.accordion-header h3 {
    font-size: 0.95em;
    color: #0d47a1;
    letter-spacing: 0.3px;
}
.accordion-arrow {
    color: #0d47a1;
    transition: transform 0.3s;
    display: flex;
    align-items: center;
}
.accordion-arrow svg {
    width: 18px;
    height: 18px;
}
.accordion.open .accordion-arrow {
    transform: rotate(180deg);
}
.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}
.accordion.open .accordion-body {
    max-height: 5000px;
}
.accordion-content {
    padding: 20px;
}

/* ===== TABLE ===== */
.search-box {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    background: #f5f9ff;
    color: #1a1a2e;
    font-size: 0.95em;
    margin-bottom: 12px;
    outline: none;
}
.search-box:focus { border-color: #1976d2; }

.table-wrap {
    max-height: 500px;
    overflow-y: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    background: #0d47a1;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.78em;
    letter-spacing: 0.3px;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}
th:hover { background: #1565c0; }
th .sort-arrow { font-size: 0.7em; margin-left: 4px; opacity: 0.5; }
th.sort-asc .sort-arrow::after { content: '▲'; opacity: 1; }
th.sort-desc .sort-arrow::after { content: '▼'; opacity: 1; }
th:not(.sort-asc):not(.sort-desc) .sort-arrow::after { content: '⇅'; }
td {
    padding: 8px 12px;
    border-bottom: 1px solid #e3f2fd;
    font-size: 0.9em;
}
tr:nth-child(even) td { background: #f5f9ff; }
tr:hover td { background: #e3f2fd; }
.rank { color: #90a4ae; font-weight: bold; }
.votos-cell { color: #0d47a1; font-weight: bold; }
.pct-bar {
    background: #e3f2fd;
    border-radius: 4px;
    height: 7px;
    width: 100%;
}
.pct-fill {
    background: linear-gradient(90deg, #1976d2, #42a5f5);
    height: 100%;
    border-radius: 4px;
}

/* ===== CHART ===== */
.chart-container {
    position: relative;
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: #90a4ae;
    font-size: 1.1em;
}
.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #bbdefb;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BADGE ===== */
.badge {
    display: inline-block;
    background: #e3f2fd;
    color: #0d47a1;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}
.badge.green { background: #e8f5e9; color: #2e7d32; }
.badge.red { background: #ffebee; color: #c62828; }
.badge.orange { background: #fff3e0; color: #e65100; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main { margin-left: 0; }
    .cards { flex-direction: column; }
    .selector-row { flex-direction: column; }
    .content { padding: 15px; }
    .page-header { padding: 15px; }
    .page-header h2 { font-size: 1.1em; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
    .page-header h2 { font-size: 1em; }
    th { font-size: 0.7em; padding: 6px 8px; }
    td { font-size: 0.8em; padding: 6px 8px; }
    .card .number { font-size: 1.5em; }
    .card { padding: 12px 16px; min-width: 100px; }
    table { font-size: 0.85em; }
    .votos-cell { min-width: 60px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .content { padding: 20px; }
    .cards { gap: 12px; }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    body { background: #121212; color: #e0e0e0; }
    .sidebar { background: #0a3270; }
    .card { background: #1e3a5f; border-color: #2a4a6f; }
    .card .number { color: #64b5f6; }
    .card .label { color: #90a4ae; }
    .page-header { background: linear-gradient(135deg, #0a3270, #0d47a1); }
    .content { background: #121212; }
    .accordion { background: #1a1a2e; border-color: #2a2a3e; }
    .accordion-header { background: #1e2a3a; border-bottom-color: #2a3a4a; }
    .accordion-header h3 { color: #64b5f6; }
    .search-box, .selector select, .selector input[type="text"] { background: #1a2a3a; color: #e0e0e0; border-color: #2a4a6f; }
    th { background: #0a3270; }
    td { border-bottom-color: #2a3a4a; }
    tr:nth-child(even) td { background: #1a2a3a; }
    tr:hover td { background: #1e3a5f; }
    .badge { background: #1e3a5f; color: #64b5f6; }
}
