/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --success-color: #27ae60;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--light-bg);
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    padding: 2.5rem 0;
    box-shadow: var(--shadow-md);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Seções */
section {
    margin: 2.5rem 0;
}

section h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-weight: 600;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

section h3 {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Seção Informativa */
.info-section {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-top: 2rem;
}

.info-content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.info-content ul {
    margin-left: 2rem;
    margin-top: 1rem;
}

.info-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Indicadores */
.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    max-width: 100%;
}

@media (min-width: 769px) {
    .indicators-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, calc(33.333% - 1rem)));
    }
}

.indicator-card {
    min-width: 220px;
    background: var(--white);
    padding: 2rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.indicator-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

/* Active row highlight */
.row-active {
    background-color: var(--accent-color) !important;
    color: var(--white);
}
.row-active td:first-child {
    background-color: var(--accent-color) !important;
}

/* Reset button */
.reset-btn {
    padding: 0.55rem 0.9rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.reset-btn:hover {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}
.global-search-wrapper {
    display: flex;
    justify-content: left;
    margin: 0 0 1.5rem 0;
}

.global-search-wrapper input {
    max-width: 300px;
}

.indicator-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.indicator-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Gráficos */
.charts-section {
    margin: 3rem 0;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .chart-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.chart-container {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.chart-container.chart-full-width {
    grid-column: 1 / -1;
}

.chart-container h3 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.chart-container canvas {
    max-height: 350px;
    width: 100% !important;
    height: auto !important;
}

/* Tabelas */
.tables-section {
    margin: 3rem 0;
}

.table-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    overflow: hidden;
}

.table-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--light-bg) 0%, #e8eef2 100%);
    border-bottom: 1px solid var(--border-color);
}

.table-header h3 {
    margin-bottom: 1rem;
}

/* Filtros */
.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-input,
.filter-select {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--white);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.filter-input {
    flex: 1;
    min-width: 200px;
}

.filter-select {
    min-width: 180px;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Tabela */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--primary-color);
    color: var(--white);
}

thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

thead th:hover {
    background-color: var(--secondary-color);
}

thead th .sort-icon {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

thead th:hover .sort-icon {
    opacity: 1;
}

thead th.sort-asc .sort-icon::before {
    content: '↑';
    opacity: 1;
    font-weight: bold;
}

thead th.sort-desc .sort-icon::before {
    content: '↓';
    opacity: 1;
    font-weight: bold;
}

thead th.sort-asc .sort-icon,
thead th.sort-desc .sort-icon {
    opacity: 1;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: var(--light-bg);
}

tbody td {
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

tbody tr:last-child {
    border-bottom: none;
}

/* Paginação */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    padding: 0.5rem 0.75rem;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-page {
    margin: 0 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pagination-page span {
    font-weight: 600;
    color: var(--text-primary);
}

.per-page-select {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--white);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.per-page-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Valores monetários */
.valor-monetario {
    font-weight: 600;
    color: var(--success-color);
}

/* Footer */
footer {
    background: var(--primary-color);
    color: var(--white);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

footer p {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

footer a {
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    display: inline-block;
}

footer a:hover {
    background-color: var(--accent-color);
    opacity: 1;
}

/* Responsividade */
@media (max-width: 1200px) {
    .chart-row {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 0;
    }

    header h1 {
        font-size: 1.75rem;
    }

    header .subtitle {
        font-size: 1rem;
    }

    .container {
        padding: 0 1rem;
    }

    section {
        margin: 1.5rem 0;
    }

    section h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .indicators-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .indicator-card {
        min-width: unset;
        padding: 1.5rem 1rem;
    }

    .indicator-value {
        font-size: 1.75rem;
    }

    .indicator-label {
        font-size: 0.85rem;
    }

    .chart-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .chart-container {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .chart-container h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .chart-container canvas {
        max-height: 280px !important;
        width: 100% !important;
        height: auto !important;
    }

    .chart-container.chart-full-width {
        grid-column: 1;
    }

    .table-card {
        border-radius: 8px;
        margin-bottom: 1.5rem;
    }

    .table-header {
        padding: 1rem 1.25rem;
    }

    .filters {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-input,
    .filter-select {
        width: 100%;
        min-width: unset;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        border-radius: 0;
    }

    table {
        font-size: 0.8rem;
        min-width: 100%;
        width: max-content;
    }

    thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
        white-space: nowrap;
        min-width: 80px;
    }

    tbody td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        min-width: 80px;
    }

    /* Tornar primeira coluna sticky em mobile */
    thead th:first-child,
    tbody td:first-child {
        position: sticky;
        left: 0;
        background: inherit;
        z-index: 2;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    thead th:first-child {
        background: var(--primary-color);
        z-index: 3;
    }

    tbody td:first-child {
        background: var(--white);
        font-weight: 500;
    }

    tbody tr:hover td:first-child {
        background: var(--light-bg);
    }

    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .pagination-info {
        text-align: center;
        font-size: 0.85rem;
    }

    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .pagination-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.9rem;
    }

    .pagination-page {
        margin: 0 0.25rem;
        font-size: 0.85rem;
    }

    .per-page-select {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .info-section {
        padding: 1.5rem;
        border-radius: 8px;
    }

    .info-content p {
        font-size: 0.95rem;
    }

    footer {
        padding: 1.5rem 0;
        margin-top: 3rem;
    }

    footer p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    .container {
        padding: 0 0.75rem;
    }

    section h2 {
        font-size: 1.3rem;
    }

    .indicator-value {
        font-size: 1.5rem;
    }

    .chart-container {
        padding: 0.75rem;
    }

    .chart-container h3 {
        font-size: 0.95rem;
    }

    .chart-container canvas {
        max-height: 220px !important;
    }

    table {
        font-size: 0.7rem;
    }

    thead th,
    tbody td {
        padding: 0.5rem 0.35rem;
        font-size: 0.7rem;
        min-width: 70px;
    }
    
    thead th:first-child,
    tbody td:first-child {
        min-width: 60px;
    }

    .pagination-btn {
        padding: 0.5rem 0.65rem;
        font-size: 0.8rem;
        min-width: 36px;
        min-height: 36px;
    }

    .pagination-page {
        font-size: 0.75rem;
    }

    .filter-input,
    .filter-select {
        font-size: 0.95rem;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.indicator-card,
.chart-container,
.table-card {
    animation: fadeIn 0.5s ease;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ícones de informação dos gráficos */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    background: var(--accent-color);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: background-color .2s ease, transform .2s ease;
}
.info-icon:hover, .info-icon:focus {
    background: var(--secondary-color);
    outline: none;
}
.chart-info-tooltip {
    position: absolute;
    top: 115%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--primary-color);
    color: var(--white);
    padding: 0.55rem 0.75rem;
    font-size: 0.7rem;
    line-height: 1.25;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    width: min(260px, 80vw);
    transition: opacity .18s ease, transform .18s ease;
    z-index: 20;
    white-space: pre-line;
}
.chart-info-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.info-icon .chart-info-tooltip:after {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent var(--primary-color) transparent;
}
@media (max-width: 768px) {
    .chart-info-tooltip { font-size: 0.65rem; }
}
@media (max-width: 480px) {
    .chart-info-tooltip { font-size: 0.6rem; }
}
