/* ==========================================================================
   1. RESET E VARIÁVEIS (DESIGN SYSTEM)
   ========================================================================== */
:root {
    --primary-color: #4a90e2;
    --bg-body: #f4f4f4;
    --bg-card: #ffffff;
    --text-main: #222222;
    --text-muted: #666666;
    --border-color: #dddddd;
    --transition: 0.3s ease;
}

/* Modo Escuro */
body.dark {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-main: #eeeeee;
    --text-muted: #aaaaaa;
    --border-color: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: var(--bg-body);
    color: var(--text-main);
    transition: var(--transition);
    line-height: 1.6;
}

/* ==========================================================================
   2. HEADER & FILTROS
   ========================================================================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark header {
    background: #1e1e1e;
    border-bottom: 1px solid var(--border-color);
}

header button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: var(--transition);
}

header button:hover {
    background: rgba(255,255,255,0.3);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 5%;
    background: var(--bg-card);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.filters label {
    font-size: 0.9rem;
    font-weight: bold;
    flex: 1;
    min-width: 200px;
}

.filters select {
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
}

/* ==========================================================================
   3. CONTEÚDO PRINCIPAL (GRID)
   ========================================================================== */
main {
    padding: 2rem 5%;
}

/* Cards de KPI */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
    transition: transform var(--transition);
}

.card:hover {
    transform: translateY(-5px);
}

.card h2 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Gráficos */
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    min-height: 300px;
}

/* ==========================================================================
   4. TABELA RESPONSIVA (ESTILO CARDS NO MOBILE)
   ========================================================================== */
.table-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.table-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

#searchInput {
    width: 100%;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    outline: none;
}

#searchInput:focus {
    border-color: var(--primary-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: rgba(0,0,0,0.02);
    color: var(--primary-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.dark th {
    background: rgba(255,255,255,0.05);
}

/* Mágica da Responsividade para Dispositivos Móveis */
@media (max-width: 768px) {
    /* Ajustes Gerais */
    main { padding: 1rem; }
    .charts { grid-template-columns: 1fr; }
    header { padding: 1rem; }

    /* Transformação da Tabela em Cards */
    table thead {
        display: none; /* Esconde o cabeçalho original */
    }

    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 0.5rem 1rem;
        background: var(--bg-card);
        box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    }

    table td {
        text-align: right;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        position: relative;
    }

    body.dark table td {
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    table td:last-child {
        border-bottom: none;
    }

    /* Insere o label da coluna usando o atributo data-label do HTML */
    table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        font-weight: 800;
        text-transform: uppercase;
        font-size: 0.7rem;
        color: var(--primary-color);
    }

    /* Destaque para o primeiro campo (Nome) */
    table td[data-label="Nome"] {
        text-align: left;
        font-size: 1.1rem;
        font-weight: bold;
        color: var(--text-main);
        padding-top: 1rem;
        border-bottom: 2px solid var(--primary-color);
        margin-bottom: 0.5rem;
    }

    table td[data-label="Nome"]::before {
        display: none;
    }
}
