/* Arquivo: estilos_local.css (v. Padronizada - AJUSTADA PARA COMPACTAÇÃO VERTICAL) */

:root {
    /* -- PALETA TEMA CLARO (REVISADA E APROVADA) -- */
    --page-bg: #f0f2f5;
    --container-bg: #ffffff;
    --container-bg-rgb: 255, 255, 255;
    --section-bg: #f8f9fa;
    --section-bg-alt: #ffffff;

    /* -- TEXTO -- */
    --text-color: #212529;
    --heading-color: #0d6efd;
    --footer-text-color: #052744;
    --text-dark: #212529;

    /* -- AÇÃO E MARCA -- */
    --primary-color: #76a1e0;
    --primary-color-rgb: 13, 110, 253;
    --primary-hover: #354c6e;
    --secondary-color: #6c757d;
    --secondary-hover: #545b62;
    --success-color: #0e422a;
    --success-color-rgb: 25, 135, 84;
    --success-hover: #0c3b25;
    --danger-color: #dc3545;
    --danger-hover: #bb2d3b;
    --danger-color-rgb: 220, 53, 69;
    --info-color: #6c757d;
    --info-hover: #545b62;
    --warning-color: #ffc107;
    --warning-hover: #e0a800;
    --warning-text: #212529;
    --queima-color: var(--danger-color);

    /* -- STATUS (WS, TABELAS, ETC) -- */
    --status-ok-color: #0c3d26;
    --status-error-color: #842029;
    --status-warn-color: #664d03;
    --status-info-color: #0c2b31;
    --status-ok-bg: #d1e7dd;
    --status-error-bg: #f8d7da;
    --status-warn-bg: #fff3cd;
    --status-info-bg: #cff4fc;

    /* -- UI E COMPONENTES -- */
    --border-color: #dee2e6;
    --section-border-color: #d3d9df;
    --table-header-bg: #e9ecef;
    --table-border-color: #dee2e6;
    --table-row-odd-bg: #f8f9fa;
    --table-row-even-bg: #ffffff;
    --disabled-bg: #e9ecef;
    --disabled-text: #6c757d;
    --border-radius-main: 0.5rem;
    --border-radius-inner: 0.3rem;
    --box-shadow-main: 0 0.4rem 1.5rem rgba(0, 0, 0, 0.08);

    /* -- FONTE PADRÃO PARA TODO O SITE -- */
    --font-principal: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

body.dark-theme {
    /* -- PALETA TEMA ESCURO (REVISADA E APROVADA) -- */
    --page-bg: #0a0a0c;
    --container-bg: #1a1d21;
    --container-bg-rgb: 26, 29, 33;
    --section-bg: #010911;
    --section-bg-alt: #1a1d21;

    /* -- TEXTO -- */
    --text-color: #dee2e6;
    --heading-color: #58a6ff;
    --footer-text-color: #adb5bd;
    --text-dark: #dee2e6;

    /* -- AÇÃO E MARCA -- */
    --primary-color: #58a6ff;
    --primary-color-rgb: 88, 166, 255;
    --primary-hover: #79b8ff;
    --secondary-color: #8b949e;
    --secondary-hover: #a0aab3;
    --success-color: #28a745;
    --success-hover: #3fb950;
    --danger-color: #f85149;
    --danger-hover: #ff7b72;
    --info-color: #3dd5f3;
    --info-hover: #6be4ff;
    --warning-color: #f0b429;
    --warning-hover: #ffce57;
    --warning-text: #121212;

    /* -- STATUS (WS, TABELAS, ETC) -- */
    --status-ok-color: var(--success-hover);
    --status-error-color: var(--danger-hover);
    --status-warn-color: var(--warning-hover);
    --status-info-color: var(--info-hover);
    --status-ok-bg: rgba(40, 167, 69, 0.15);
    --status-error-bg: rgba(248, 81, 73, 0.15);
    --status-warn-bg: rgba(240, 180, 41, 0.15);
    --status-info-bg: rgba(13, 202, 240, 0.15);

    /* -- UI E COMPONENTES -- */
    --border-color: #495057;
    --section-border-color: #495057;
    --table-header-bg: #343a40;
    --table-border-color: #495057;
    --table-row-odd-bg: #212529;
    --table-row-even-bg: #2c3034;
    --disabled-bg: #343a40;
    --disabled-text: #6c757d;
    --box-shadow-main: 0 0.4rem 1.5rem rgba(0, 0, 0, 0.25);
}

html {
    scroll-behavior: smooth;
    font-size: 20px; /* Base original do seu novo CSS */
}
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-principal);
    background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.3)), url('../img/sr_app_background6.png') center/cover no-repeat fixed;
    background-color: var(--page-bg);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0.5rem; /* Reduzido de 1rem */
    padding-bottom: 0.5rem; /* Reduzido de 1rem */
    padding-left: 1rem; /* Horizontal mantido */
    padding-right: 1rem; /* Horizontal mantido */
    box-sizing: border-box;
    line-height: 1.5; /* Reduzido de 1.6 para compactar texto */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- BOTÃO DE TEMA MOVIDO PARA BAIXO --- */
#toggleDarkModeButton {
    position: fixed; 
    bottom: 15px; /* Distância da base da tela */
    right: 15px;  /* Distância da lateral direita */
    z-index: 1001;
    background-color: rgba(var(--container-bg-rgb), 0.7); 
    color: var(--text-color);
    border: 1px solid var(--border-color); 
    border-radius: 50%;
    width: 40px;  /* Tamanho ajustado */
    height: 40px;
    font-size: 1.2rem; /* Ícone ajustado */
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.25);
}
body.dark-theme #toggleDarkModeButton { 
    box-shadow: 0 2px 5px rgba(0,0,0,0.6); 
}
.container {
    background-color: rgba(var(--container-bg-rgb, 255, 255, 255), 0.75);
    padding-top: 1rem; /* Reduzido de 1.5rem */
    padding-bottom: 1rem; /* Reduzido de 1.5rem */
    padding-left: 1.5rem; /* Horizontal mantido */
    padding-right: 1.5rem; /* Horizontal mantido */
    border-radius: var(--border-radius-main);
    box-shadow: var(--box-shadow-main);
    width: 100%;
    max-width: 1200px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    margin-bottom: auto;
}
body.dark-theme .container {
    background-color: rgba(var(--container-bg-rgb, 26, 29, 33), 0.75);
}

/* STATUS SECTION */
.status-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem; /* Reduzido de 0.8rem */
    background-color: var(--section-bg-alt); /* Mantido */
    font-size: 0.9em; /* Reduzido de 1.0em para compactar */
    line-height: 1.3; /* Reduzido de 1.4 */
    margin-bottom: 1rem; /* Reduzido de 1.5rem */
    padding: 0.5rem; /* Reduzido de 1rem (afeta todos os lados) */
    border-radius: var(--border-radius-inner);
    border: 1px solid var(--section-border-color);
}
/* Títulos H2 dentro de seções como .status-section, .piloto-section, etc. */
.status-section h2, .piloto-section h2, .results-section h2, .command-section h2, .last-run-summary-section h2,
.admin-section-card h2 { /* Incluindo .admin-section-card h2 das outras páginas para consistência */
    font-size: 1.0em; /* Mantido de 1.0em (era 1.15em ou 1.2em antes) */
    color: var(--heading-color);
    margin-top: 0;
    margin-bottom: 0.5rem; /* Reduzido de 1rem ou 0.8rem */
    padding-bottom: 0.25rem; /* Reduzido de 0.5rem */
    border-bottom: 1px solid var(--section-border-color);
}

.status-item {
    padding: 0.4rem 0.6rem; /* Vertical de 0.8rem para 0.4rem, horizontal de 0.8rem para 0.6rem */
    border-radius: var(--border-radius-inner);
    border: 1px solid var(--border-color);
    text-align: center;
    background-color: var(--container-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.9em; /* Reduzido de 1.0em */
}
.status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
body:not(.dark-theme) .status-item {
    background-color: #fdfdfd;
    border: 1px solid #ced4da;
}
body.dark-theme .status-item {
    background-color: var(--section-bg);
    border: 1px solid var(--border-color);
}
.status-label {
    font-weight: 600;
    color: var(--heading-color);
    display: block;
    margin-bottom: 0.15rem; /* Reduzido de 0.3rem */
    font-size: 0.85em; /* Reduzido de 0.90em */
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.status-item span[id^="data-"] { /* Valores dentro do status-item */
    font-weight: 500;
    color: var(--primary-color);
    font-family: var(--font-principal);
    font-size: 1em; /* Relativo ao font-size do .status-item (que já foi reduzido) */
    line-height: 1.3; /* Reduzido de 1.4 */
}

/* Estilos para diferentes estados (wsStatus) */
#wsStatus {
    padding: 0.4rem 0.6rem; /* Ajustado para consistência com .status-item */
    margin-bottom: 0.5rem; /* Adicionado para separar um pouco se estiver acima de outros elementos */
    border-radius: var(--border-radius-inner); /* Adicionado para consistência */
}
#wsStatus.status-ok, #wsStatus.status-error, #wsStatus.status-warn, #wsStatus.status-info {
    font-weight: 600;
}
#wsStatus.status-ok { background-color: var(--status-ok-bg); border: 1px solid var(--success-color); color: var(--status-ok-color); }
#wsStatus.status-error { background-color: var(--status-error-bg); border: 1px solid var(--danger-color); color: var(--status-error-color); }
#wsStatus.status-warn { background-color: var(--status-warn-bg); border: 1px solid var(--warning-color); color: var(--status-warn-color); }
#wsStatus.status-info { background-color: var(--status-info-bg); border: 1px solid var(--info-color); color: var(--status-info-color); }


/* TEMPOS EM ANDAMENTO (live_view.php) */
.tempo-real-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Mantido para duas colunas */
    gap: 10px; /* Era 15px, reduzido para aproximar colunas */
    font-size: 1em; /* Base para esta seção */
}
/* Seções .piloto-section e .results-section podem usar .tempo-real-grid para layout de colunas */
.piloto-section.tempo-real-grid, 
.results-section .tracks-container.tempo-real-grid,
.last-run-summary-section .tracks-container.tempo-real-grid {
    margin-top: 0.5rem; /* Reduzido de 15px/10px */
}

.tempos-linha-horizontal { /* Container para os .tempo-item */
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem; /* Reduzido de 0.8rem, espaço entre os tempo-item */
    margin-top: 0.4rem; /* Reduzido de 0.8rem, espaço acima da linha de tempos */
}
.tempo-item {
    background-color: var(--section-bg-alt);
    padding: 0.3rem 0.8rem; /* Padding vertical reduzido de 0.6rem */
    border-radius: var(--border-radius-inner);
    border: 1px solid var(--border-color);
    font-size: 0.9em; /* Reduzido de 1em */
    flex: 1 1 auto;
    min-width: 110px; /* Reduzido de 120px */
    text-align: center;
}
.tempo-item span { /* O valor do tempo */
    display: block;
    font-size: 1em; /* Relativo ao font-size do .tempo-item */
    font-weight: 500;
    color: var(--primary-color);
    font-family: var(--font-principal);
    margin-top: 0.1em; /* Reduzido de 0.2em */
}
body.dark-theme .tempo-item span { color: var(--primary-hover); }
.tempo-item .tempo-final { color: var(--success-color); }
body.dark-theme .tempo-item .tempo-final { color: var(--success-hover); }
.tempo-item .tempo-queima, .tempo-item .tempo-reacao.queima-ativa { color: var(--danger-color); font-weight: bold; }
body.dark-theme .tempo-item .tempo-queima, body.dark-theme .tempo-item .tempo-reacao.queima-ativa { color: var(--danger-hover); }


/* Mensagens de Erro PHP */
.error-message-php {
    color: var(--danger-color) !important;
    background-color: white !important;
    padding: 0.2rem 0.4rem;
    border-radius: var(--border-radius-inner);
    display: inline-block;
    margin-top: 0.2rem; /* Reduzido de 0.3rem */
    font-size: 0.9em; /* Reduzido de 1em */
    border: 1px solid var(--danger-color);
}
body.dark-theme .error-message-php {
    color: #ffcdd2 !important;
    background-color: var(--danger-color) !important;
    border-color: #ff7b72;
}

/* Estrutura Geral das Páginas (Top Bar e Main Title) */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem; /* Reduzido de 0.5rem */
    padding-bottom: 0.4rem; /* Reduzido de 0.8rem */
    border-bottom: 1px solid var(--border-color);
}
.main-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--heading-color);
    margin: 0;
}

/* Seções de Conteúdo (comum a várias páginas) */
.status-section, .piloto-section, .results-section, .command-section, .last-run-summary-section,
.admin-section-card { /* Adicionado .admin-section-card para abranger outras páginas */
    margin-bottom: 1rem; /* Reduzido de 1.5rem */
    background-color: var(--section-bg);
    padding: 0.5rem; /* Reduzido de 1rem ou 1.2rem */
    border-radius: var(--border-radius-inner); /* Mantido */
    border: 1px solid var(--section-border-color);
}
/* Títulos h2 já definidos acima para .status-section h2, etc. */

body:not(.dark-theme) .status-section,
body:not(.dark-theme) .piloto-section,
body:not(.dark-theme) .results-section,
body:not(.dark-theme) .last-run-summary-section,
body:not(.dark-theme) .command-section,
body:not(.dark-theme) .admin-section-card {
    background-color: var(--section-bg);
    border-color: var(--section-border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Pistas e Displays (como .piloto-lane, .track-display em live_view.php) */
.piloto-lane, .track-display {
    background-color: var(--section-bg-alt);
    padding: 0.5rem; /* Reduzido de 1rem */
    border-radius: var(--border-radius-inner);
    border: 1px solid var(--border-color);
}
body:not(.dark-theme) .piloto-lane,
body:not(.dark-theme) .track-display {
    background-color: var(--section-bg-alt);
    border-color: var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.piloto-lane h3, .track-display h3 { /* Títulos dentro de .piloto-lane ou .track-display */
    margin-top: 0;
    color: var(--heading-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem; /* Reduzido de 0.5rem */
    margin-bottom: 0.4rem; /* Reduzido de 0.8rem */
    font-size: 0.95em; /* Reduzido de 1.0em */
}
.piloto-lane > div, /* Para divs diretas dentro de .piloto-lane, como as de info do piloto */
.piloto-lane .info-item { /* Para a classe .info-item usada em live_view */
    font-size: 0.9em; /* Reduzido */
    margin-bottom: 0.2rem; /* Adicionado/Ajustado */
    line-height: 1.3;
}
.piloto-lane > div:last-child,
.piloto-lane .info-item:last-child { margin-bottom: 0; }

.piloto-id, .piloto-nome-display, .piloto-cat-nome, .piloto-recorde-display { font-size: 1em; /* Relativo ao pai (.piloto-lane > div ou .info-item) */ }
.piloto-id { font-weight: bold; background-color: var(--table-header-bg); padding: 0.1rem 0.3rem; border-radius: 3px; }
.piloto-nome-display { font-style: italic; font-weight: 500; }
.piloto-cat-nome { color: var(--text-color); }
.piloto-recorde-display { color: var(--success-color); font-weight: bold; display: inline-block; margin-top: 0.1rem; /* Reduzido de 0.15rem ou 0.3rem */ }
body.dark-theme .piloto-recorde-display { color: var(--success-hover); }


/* TABELAS */
.results-table, .tabela-resultados table, .provas-table /* Adicionado .provas-table para abranger outras páginas */ {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.25rem; /* Reduzido de 0.5rem */
    font-size: .8em; /* Mantido (já reduzido antes) */
    border: 1px solid var(--table-border-color);
}
.results-table th, .results-table td,
.tabela-resultados th, .tabela-resultados td,
.last-run-table th, .last-run-table td,
.provas-table th, .provas-table td { /* Adicionado .provas-table */
    border: 1px solid var(--table-border-color);
    padding: 0.2rem 0.4rem; /* Mantido (já reduzido antes) */
    text-align: left;
    font-family: var(--font-principal);
    vertical-align: middle;
}
.results-table thead th,
.tabela-resultados thead th,
.last-run-table thead th,
.provas-table thead th { /* Adicionado .provas-table */
    background-color: var(--table-header-bg);
    font-weight: 600;
    text-align: center;
}
.results-table tbody th, 
.last-run-table tbody th {
    background-color: var(--section-bg-alt);
    font-weight: 600;
    text-align: left;
    padding-right: 8px;
}
.last-run-table td {
    font-weight: normal;
    text-align: left;
}
.last-run-table td.tempo-queima {
    color: var(--queima-color);
    font-weight: bold;
    white-space: nowrap;
}

.tabela-resultados td.tempo-valor-especial {
    font-weight: bold;
    font-size: 1em;
    min-width: 50px;
    text-align: right;
}

.tabela-resultados tbody tr:nth-child(even),
.provas-table tbody tr:nth-child(even) { background-color: var(--table-row-even-bg); }
.tabela-resultados tbody tr:nth-child(odd),
.provas-table tbody tr:nth-child(odd) { background-color: var(--table-row-odd-bg); }
.tabela-resultados tbody tr:hover,
.provas-table tbody tr:hover { background-color: var(--primary-hover); color: var(--container-bg); }
body.dark-theme .tabela-resultados tbody tr:hover,
body.dark-theme .provas-table tbody tr:hover { color: var(--text-color); }


.table-wrapper {
    overflow-x: auto;
    max-height: 2800px; /* Avaliar se ainda é necessário tão alto com fontes menores */
    overflow-y: auto;
    border: 1px solid var(--table-border-color);
    border-radius: var(--border-radius-inner);
    margin-top: 0.25rem; /* Reduzido de 0.5rem */
    padding: 0;
}
.table-wrapper > table { margin-top: 0; border: none; border-radius: 0; }

/* Última Corrida Salva (h4 específico para live_view.php) */
.last-run-summary-section .track-display h4 {
    margin-top: 0;
    margin-bottom: 0.3rem; /* Reduzido de 0.6rem */
    font-size: 0.95em; /* Reduzido de 1em */
    color: var(--heading-color);
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.15rem; /* Reduzido de 0.3rem */
}

/* BOTÕES */
.command-button {
    padding: 0.3rem 0.8rem; /* Vertical mantido, era 0.4rem antes de eu reduzir antes */
    font-size: 0.9em;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius-inner);
    color: white !important; /* Adicionado !important para garantir cor do texto em botões com outras classes */
    background: linear-gradient(to bottom, var(--primary-color), color-mix(in srgb, var(--primary-color) 80%, black));
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    min-height: 30px; /* Reduzido de 32px */
}
/* ... (demais estilos de botão :hover, :active, :disabled, e .btn-nav, .btn-secondary, etc. mantidos) ... */
.command-button:hover:not(:disabled) {
    background: linear-gradient(to bottom, var(--primary-hover), color-mix(in srgb, var(--primary-hover) 80%, black));
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}
.command-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}
.command-button:disabled {
    cursor: not-allowed; opacity: 0.6; background: var(--disabled-bg);
    color: var(--disabled-text) !important; box-shadow: none; transform: none;
}
/* Estilos para .btn-nav etc. */
.command-button.btn-nav, .command-button.btn-secondary { background: linear-gradient(to bottom, var(--secondary-color), color-mix(in srgb, var(--secondary-color) 80%, black)) !important; }
.command-button.btn-nav:hover:not(:disabled), .command-button.btn-secondary:hover:not(:disabled) { background: linear-gradient(to bottom, var(--secondary-hover), color-mix(in srgb, var(--secondary-hover) 80%, black)) !important; }
.command-button.btn-success { background: linear-gradient(to bottom, var(--success-color), color-mix(in srgb, var(--success-color) 80%, black)) !important; }
.command-button.btn-success:hover:not(:disabled) { background: linear-gradient(to bottom, var(--success-hover), color-mix(in srgb, var(--success-hover) 80%, black)) !important; }
.command-button.btn-danger, .command-button.delete { background: linear-gradient(to bottom, var(--danger-color), color-mix(in srgb, var(--danger-color) 80%, black)) !important; }
.command-button.btn-danger:hover:not(:disabled), .command-button.delete:hover:not(:disabled) { background: linear-gradient(to bottom, var(--danger-hover), color-mix(in srgb, var(--danger-hover) 80%, black)) !important; }
.command-button.edit { background: linear-gradient(to bottom, var(--primary-color), color-mix(in srgb, var(--primary-color) 80%, black)) !important; }
.command-button.edit:hover:not(:disabled) { background: linear-gradient(to bottom, var(--primary-hover), color-mix(in srgb, var(--primary-hover) 80%, black)) !important; }


/* Botões de Navegação no Menu Principal (como em gerenciar_usuarios.php) */
.main-index-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem; /* Reduzido de 0.5rem */
    margin-bottom: 1rem; /* Reduzido de 1.5rem */
    padding-bottom: 0.5rem; /* Reduzido de 1rem */
    border-bottom: 1px solid var(--border-color);
}
/* ... (estilos específicos para .main-index-menu .command-button.btn-nav mantidos) ... */
.main-index-menu .command-button.btn-nav {
    background: transparent !important; border: 1px solid var(--primary-color) !important; color: var(--primary-color) !important;
    box-shadow: inset 0 0 4px rgba(var(--primary-color-rgb), 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    padding: 0.4rem 0.8rem; font-size: 1em;
    min-height: 32px;
    flex-grow: 1;
    flex-basis: 150px;
}
.main-index-menu .command-button.btn-nav:hover:not(:disabled) {
    background: linear-gradient(to bottom, var(--primary-color), color-mix(in srgb, var(--primary-color) 80%, black)) !important;
    color: var(--container-bg) !important;
    border-color: var(--primary-color) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(var(--primary-color-rgb), 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}
body.dark-theme .main-index-menu .command-button.btn-nav { border-color: var(--primary-color) !important; color: var(--primary-color) !important; box-shadow: inset 0 0 4px rgba(var(--primary-color-rgb),0.25), inset 0 1px 1px rgba(0,0,0,.07); }
body.dark-theme .main-index-menu .command-button.btn-nav:hover:not(:disabled) { background: linear-gradient(to bottom,var(--primary-hover),color-mix(in srgb,var(--primary-hover) 80%,#000)) !important; color: var(--page-bg) !important; border-color: var(--primary-hover) !important; box-shadow: 0 4px 8px rgba(0,0,0,.2), inset 0 1px 1px rgba(255,255,255,.3); }
.main-index-menu .command-button.btn-nav.active { background: linear-gradient(to bottom,var(--primary-hover),color-mix(in srgb,var(--primary-hover) 80%,#000)) !important; font-weight: 600; box-shadow: inset 0 2px 4px rgba(0,0,0,.1); color: #fff !important; }
body.dark-theme .main-index-menu .command-button.btn-nav.active { background: linear-gradient(to bottom,var(--primary-color),color-mix(in srgb,var(--primary-color) 80%,#000)) !important; color: var(--text-dark) !important; }


/* FILTROS (como em historico.php) */
.filtros-container { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; margin-bottom: 1rem; }
.filtro-item { display: flex; flex-direction: column; flex-grow: 1; flex-basis: 180px; min-width: 150px; }
.filtro-item label { margin-bottom: 0.2rem; font-weight: 500; font-size: 0.9em; }
.filtro-item select, .filtro-item input[type="text"], .filtro-item input[type="number"], .filtro-item input[type="date"] {
    width: 100%; padding: 0.4rem; border: 1px solid var(--border-color);
    border-radius: var(--border-radius-inner); background-color: var(--container-bg);
    color: var(--text-color); font-size: 0.85em;
}
body.dark-theme .filtro-item select, body.dark-theme .filtro-item input[type="text"], body.dark-theme .filtro-item input[type="number"], body.dark-theme .filtro-item input[type="date"] {
    background-color: var(--section-bg-alt);
}
/* ... (estilos do btn-print em filtros-container mantidos) ... */
.filtros-container .btn-print { 
    background: linear-gradient(to bottom, var(--info-color), color-mix(in srgb, var(--info-color) 80%, black));
    padding: 0.4rem 0.8rem; font-size: 1.0em; min-height: 32px;
}
.filtros-container .btn-print:hover:not(:disabled) { background: linear-gradient(to bottom,var(--info-hover),color-mix(in srgb,var(--info-hover) 80%,#000)); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,.2); }
.filtros-container .btn-print:active:not(:disabled) { transform: translateY(0); box-shadow: inset 0 2px 4px rgba(0,0,0,.2); }


.tabela-resultados > p { /* Mensagem de "Nenhum resultado" */
    padding: 0.8rem; background-color: var(--section-bg-alt); border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-inner); text-align: center;
}

/* RODAPÉ */
.footer {
    text-align: center; margin-top: 1rem; padding-top: 0.5rem; /* Margem e padding reduzidos */
    border-top: 1px solid var(--border-color); font-size: 0.8em; /* Fonte reduzida */
    color: var(--footer-text-color);
}

/* FORMULÁRIOS (baseado em estilos_cadastrar_piloto/categorias/usuarios) */
.form-group {
    margin-bottom: 0.4rem; /* Reduzido para compactar formulários */
}
.form-group:last-of-type { margin-bottom: 0; }
.form-group label {
    display: block;
    margin-bottom: 0.15rem; /* Reduzido */
    font-weight: 500; font-size: 0.85em; /* Consistente */
    color: var(--text-color);
}
body.dark-theme .form-group label { color: var(--text-color); }

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.3rem 0.5rem; /* Padding interno dos campos reduzido */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-inner);
    box-sizing: border-box; font-family: var(--font-principal);
    font-size: 0.9em; background-color: var(--container-bg);
    color: var(--text-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group textarea { min-height: 60px; resize: vertical; } /* Altura mínima reduzida */

body.dark-theme .form-group input[type="text"],
body.dark-theme .form-group input[type="password"],
body.dark-theme .form-group select,
body.dark-theme .form-group textarea {
    background-color: var(--section-bg); /* Consistente com outros CSS */
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
body.dark-theme .form-group select option {
    background-color: var(--section-bg);
    color: var(--text-color);
}
.form-group input:focus,
.form-group input[type="password"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.15rem rgba(var(--primary-color-rgb), 0.2);
    outline: none;
}
.form-control-disabled { /* Estilo para input desabilitado */
    background-color: var(--disabled-bg) !important;
    color: var(--disabled-text) !important;
    cursor: not-allowed;
    border-color: var(--border-color) !important;
}
.form-group.checkbox { /* Estilo para checkbox */
    display: flex;
    align-items: center;
    gap: 0.4rem; /* Reduzido */
    padding-top: 0.2rem; padding-bottom: 0.2rem; /* Reduzido */
}
.form-group.checkbox input[type="checkbox"] {
    width: auto; margin: 0; transform: scale(1.15);
}
.form-group.checkbox label {
    margin-bottom: 0; font-weight: normal; display: inline;
}


/* RESPONSIVIDADE */
@media (max-width: 768px) {
    .colunas-wrapper {
                flex-direction: column; /* Empilha as colunas */
            }
    html { font-size: 18px; } /* Base mobile original deste CSS era 19px, ajustei para 18px */

    body {
        padding-top: 0.25rem; padding-bottom: 0.25rem;
        padding-left: 0.5rem; padding-right: 0.5rem;
        line-height: 1.4; /* Linha um pouco mais compacta no mobile */
    }
    .container {
        padding-top: 0.5rem; padding-bottom: 0.5rem;
        padding-left: 0.8rem; padding-right: 0.8rem;
    }
    .top-bar { margin-bottom: 0.3rem; padding-bottom: 0.3rem; }
    .main-title { font-size: 1em; }

    .status-section { gap: 0.3rem; padding: 0.4rem; font-size: 0.85em; margin-bottom: 0.8rem; }
    .status-section h2, .piloto-section h2, .results-section h2, .command-section h2, .last-run-summary-section h2,
    .admin-section-card h2 { font-size: 0.95em; margin-bottom: 0.4rem; padding-bottom: 0.2rem; }
    .status-item { padding: 0.3rem 0.5rem; font-size: 0.85em; }
    .status-label { font-size: 0.8em; margin-bottom: 0.1rem; }

    .piloto-section, .results-section, .command-section, .last-run-summary-section,
    .admin-section-card {
        margin-bottom: 0.8rem; padding: 0.4rem;
    }
    .tempo-real-grid { gap: 8px; } /* Reduzido de 10px */
    .piloto-section.tempo-real-grid, 
    .results-section .tracks-container.tempo-real-grid,
    .last-run-summary-section .tracks-container.tempo-real-grid {
        margin-top: 0.4rem; /* Reduzido */
        gap: 0.5rem; /* Sobrescreve o gap geral do tempo-real-grid se este for o container das colunas */
    }

    .piloto-lane, .track-display {
        margin-bottom: 0.5rem;
        padding: 0.4rem;
    }
    .piloto-lane h3, .track-display h3 { font-size: 0.9em; margin-bottom: 0.3rem; padding-bottom: 0.2rem; }
    .piloto-lane > div, .piloto-lane .info-item { font-size: 0.85em; margin-bottom: 0.1rem; line-height: 1.2; }

    .tempos-linha-horizontal { gap: 0.3rem; margin-top: 0.2rem; }
    .tempo-item { padding: 0.2rem 0.5rem; font-size: 0.85em; min-width: 90px; } /* Reduzido min-width */
    
    .last-run-summary-section .track-display h4 { font-size: 0.9em; margin-bottom: 0.2rem; padding-bottom: 0.1rem; }
    .results-table, .tabela-resultados table, .provas-table { font-size: .75em; } /* Reduzido */
    .results-table th, .results-table td,
    .tabela-resultados th, .tabela-resultados td,
    .last-run-table th, .last-run-table td,
    .provas-table th, .provas-table td {
        padding: 0.15rem 0.3rem; /* Reduzido */
    }
    .last-run-table th { width: auto; padding-right: 3px; font-weight: 600; } /* Rótulo mais forte no mobile, largura auto */
    .last-run-table td { font-weight: normal; } /* Valores normais */
    
    .command-button { padding: 0.25rem 0.6rem; font-size: 0.85em; min-height: 28px; }
    .main-index-menu { gap: 0.3rem; margin-bottom: 0.8rem; padding-bottom: 0.4rem; }
    .main-index-menu .command-button.btn-nav { font-size: 0.9em; flex-basis: 120px; }
    
    .filtros-container { gap: 0.5rem; }
    .filtro-item label { font-size: 0.85em; }
    .filtro-item select, .filtro-item input[type="text"], .filtro-item input[type="number"], .filtro-item input[type="date"] { padding: 0.3rem; font-size: 0.8em; }

    .footer { font-size: 0.75em; margin-top: 0.8rem; padding-top: 0.4rem; }

    /* Ajustes específicos de live_view.php para @media (max-width: 768px) */
    .last-run-table th, .last-run-table td {
        border: 1px solid var(--section-bg-alt);
        padding: 2px 4px; 
        font-size: 0.8em; 
    }
    /* Re-aplicando o que já estava no seu CSS original para .last-run-table no mobile, mas ajustando */
    .last-run-table th { /* Coluna dos RÓTULOS no mobile */
        width: auto; /* Deixando auto para melhor ajuste, antes era 30% */
        font-weight: 600; /* Deixando os rótulos mais fortes no mobile também */
        padding-right: 5px;
    }
    .last-run-table td { /* Coluna dos VALORES no mobile */
        font-weight: normal; /* Valores com peso normal */
    }
    .last-run-table td.tempo-queima { 
        white-space: normal; 
    }
   /* Esconde a coluna do piloto esquerdo */
    table.tabela-resultados td:nth-child(3), 
    table.tabela-resultados th:nth-child(3) {
        display: none;
    }
    
    /* Esconde a coluna do piloto direito */
    table.tabela-resultados td:nth-child(6), 
    table.tabela-resultados th:nth-child(6) {
        display: none;
    }
}

/* IMPRESSÃO */
@media print {
    /* ... (Estilos de impressão mantidos como no original, com a correção da coluna piloto) ... */
    body, .container {
        background: white !important; color: black !important;
        box-shadow: none !important; border: none !important;
        padding: 0 !important; margin: 0 !important;
        width: 100% !important; font-size: 10pt; /* Reduzido de 16pt para caber mais */
    }
    #toggleDarkModeButton, .main-index-menu, .command-section, .filtros-section, .footer { display: none !important; }
    .top-bar { border-bottom: 1px solid #ccc !important; padding-bottom: 5px; margin-bottom: 10px; } /* Reduzido */
    .main-title { font-size: 12pt; color: black !important; } /* Reduzido */
    h2, h3, h4 { color: black !important; font-size: 10pt; margin-bottom: 0.3rem;} /* Reduzido */
    .top-info-bar, .status-section, .piloto-section, .results-section, .last-run-summary-section,
    .tabela-resultados, .admin-section-card {
        background-color: transparent !important; border: 1px solid #ccc !important;
        margin-bottom: 8px; padding: 3px; /* Reduzido */
    }
    .results-table, .tabela-resultados table, .provas-table {
        margin-top: 3px; border: 1px solid #333;
        width: 100%; border-collapse: collapse;
    }
    .results-table th, .results-table td, .tabela-resultados th, .tabela-resultados td,
    .provas-table th, .provas-table td {
        border: 1px solid #333; padding: 2px; font-size: 9pt; /* Reduzido */
        color: black; text-align: left;
    }
    .results-table thead th, .tabela-resultados thead th, .provas-table thead th {
        background-color: #eee; font-weight: bold; text-align: center;
    }
    .table-wrapper { max-height: none !important; overflow-y: visible !important; border: none !important; }
    body.dark-theme { /* Resetar cores do dark theme para impressão */
        --page-bg: white; --container-bg: white; --section-bg: white; --section-bg-alt: white;
        --text-color: black; --heading-color: black; --footer-text-color: black;
        --primary-color: black; --primary-hover: black; --success-color: black; --success-hover: black;
        --secondary-color: black; --secondary-hover: black; --info-color: black; --info-hover: black;
        --warning-color: black; --warning-text: black; --warning-hover: black;
        --danger-color: black; --danger-hover: black; --queima-color: black;
        --status-ok-color: black; --status-error-color: black; --status-warn-color: black; --status-info-color: black;
        --status-ok-bg: #eee; --status-error-bg: #eee; --status-warn-bg: #eee; --status-info-bg: #eee;
        --table-header-bg: #eee; --table-border-color: #ccc; --table-row-odd-bg: #f9f9f9; --table-row-even-bg: white;
        --disabled-bg: #eee; --disabled-text: #555; --border-color: #ccc; --section-border-color: #ccc;
    }
    .tempo-item { display:none !important; }
    .tabela-resultados th.piloto-column, .tabela-resultados td.piloto-column { display: table-cell !important; }
}
