/* ===== AUTHENTICATED AREA - AGGRESSIVE RACING THEME ===== */
/* Professional dark theme with WCAG AA contrast compliance */

/* ===== HIGH CONTRAST TEXT FIXES ===== */
#app-content h1,
#app-content h2,
#app-content h3 {
    color: #F9FAFB !important;
}

#app-content h4,
#app-content h5,
#app-content h6 {
    color: #E5E7EB !important;
}

#app-content p,
#app-content li,
#app-content label,
#app-content td,
#app-content span {
    color: #E5E7EB !important;
}

#app-content .section-title,
#app-content .chart-title {
    color: #EA580C !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

#app-content .metadata,
#app-content .hint,
#app-content .timestamp,
#app-content small {
    color: #9CA3AF !important;
}

/* Setores Automáticos table - dark text on light background for readability */
#app-content .table-light.sectors-table th {
    color: #1F2937 !important;
}
#app-content .table-light.sectors-table th:first-child {
    color: #EA580C !important;
}
#app-content .table-light.sectors-table td {
    color: #374151 !important;
}
#app-content .table-light.sectors-table td:first-child {
    color: #111827 !important;
}

/* ===== BORDER VISIBILITY FIXES ===== */
#app-content .card {
    border: 1px solid #374151 !important;
    background: #0F0F0F !important;
}

#app-content hr {
    border-color: #4B5563 !important;
    border-width: 1px !important;
    opacity: 1 !important;
}

#app-content .card-header {
    border-bottom: 1px solid #374151 !important;
}

/* Scrollbar styling (dark theme) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0A0A0A;
}

::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #B91C1C;
}

/* Selection color */
::selection {
    background: #B91C1C;
    color: #FFFFFF;
}

/* Content area (apply to #app-content) */
#app-content {
    background: linear-gradient(180deg, #0A0A0A 0%, #111827 100%) !important;
}

/* Shared contact footer (main column, authenticated shell) */
#app-content .site-footer-authenticated {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #374151;
    text-align: center;
}

#app-content .site-footer-email-line {
    margin: 0;
    font-size: 14px;
    color: #9CA3AF !important;
}

#app-content .site-footer-email-link {
    color: #EA580C !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    word-break: break-word;
}

#app-content .site-footer-email-link:hover {
    color: #F97316 !important;
    text-decoration: underline !important;
}

.content-area {
    background: linear-gradient(180deg, #0A0A0A 0%, #111827 100%) !important;
}

/* Sidebar nav link hover/active (Dash NavLink) */
#app-sidebar .nav-link {
    color: #D1D5DB !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-radius: 6px !important;
    border-left: 3px solid transparent !important;
    padding: 12px 16px !important;
    margin-bottom: 6px !important;
    transition: all 0.2s ease !important;
}

#app-sidebar .nav-link:hover {
    background: #1C1C1C !important;
    border-left-color: #B91C1C !important;
    color: #F9FAFB !important;
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.2) !important;
}

#app-sidebar .nav-link.active {
    background: #1C1C1C !important;
    border-left-color: #EA580C !important;
    color: #EA580C !important;
    font-weight: 800 !important;
    box-shadow: 0 0 20px rgba(234, 88, 12, 0.3) !important;
}

#app-sidebar .sidebar-logout-btn:hover {
    background: #7F1D1D !important;
    border-color: #B91C1C !important;
    color: #F9FAFB !important;
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.4) !important;
}

#mobile-topbar .mobile-menu-btn:hover {
    color: #B91C1C !important;
}

/* Plotly chart overrides */
.js-plotly-plot .plotly .modebar {
    background: transparent !important;
}

.js-plotly-plot .plotly .modebar-btn path {
    fill: #9CA3AF !important;
}

.js-plotly-plot .plotly .modebar-btn:hover path {
    fill: #B91C1C !important;
}

/* Dash DataTable */
.dash-table-container {
    background: #0F0F0F !important;
    border: 1px solid #374151 !important;
    border-radius: 8px !important;
}

.dash-spreadsheet-container .dash-spreadsheet-inner table {
    background: #0F0F0F !important;
    color: #D1D5DB !important;
}

.dash-spreadsheet-container .dash-spreadsheet-inner th {
    background: #1C1C1C !important;
    color: #EA580C !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-bottom: 2px solid #B91C1C !important;
}

.dash-spreadsheet-container .dash-spreadsheet-inner td {
    background: #0F0F0F !important;
    color: #E5E7EB !important;
    border-bottom: 1px solid #374151 !important;
}

.dash-spreadsheet-container .dash-spreadsheet-inner tr:hover td {
    background: #1C1C1C !important;
}

.dash-table-container {
    border: 1px solid #374151 !important;
}

/* Plotly chart text overrides for readability */
.js-plotly-plot text {
    fill: #E5E7EB !important;
}

.js-plotly-plot .xtick text,
.js-plotly-plot .ytick text {
    fill: #D1D5DB !important;
}

/* Lap Analysis (analise): light in-card content — global Plotly text rules above use gray fills; this page is not under .telemetry-page[data-theme="light"], so override locally only */
#app-content #analise-laps-content .js-plotly-plot text {
    fill: #000000 !important;
}

#app-content #analise-laps-content .js-plotly-plot .xtick text,
#app-content #analise-laps-content .js-plotly-plot .ytick text {
    fill: #000000 !important;
}

#app-content #analise-laps-content .table,
#app-content #analise-laps-content .table th,
#app-content #analise-laps-content .table td {
    color: #000000 !important;
    --bs-table-color: #000000;
    --bs-table-striped-color: #000000;
    --bs-table-hover-color: #000000;
}

/* Page header (authenticated pages) */
.page-header-auth {
    margin-bottom: 32px !important;
    padding-bottom: 16px !important;
    border-bottom: 2px solid #4B5563 !important;
}

.page-title-auth {
    font-size: clamp(28px, 4vw, 42px) !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    letter-spacing: -0.02em !important;
    color: #F9FAFB !important;
    margin-bottom: 8px !important;
    text-shadow: 0 0 30px rgba(185, 28, 28, 0.3) !important;
}

.page-subtitle-auth {
    font-size: 16px !important;
    font-weight: 500 !important;
    color: #9CA3AF !important;
    line-height: 1.5 !important;
}

/* Card dark theme */
.card-auth {
    background: #0F0F0F !important;
    border: 1px solid #374151 !important;
    border-radius: 12px !important;
    padding: 24px !important;
    margin-bottom: 24px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.card-auth-accent {
    border-left: 4px solid #B91C1C !important;
}

/* Bootstrap Card overrides in authenticated area */
#app-content .card {
    background: #0F0F0F !important;
    border: 1px solid #374151 !important;
    border-radius: 12px !important;
}

#app-content .card-header,
#app-content .card-body {
    background: #0F0F0F !important;
    border-color: #374151 !important;
    color: #E5E7EB !important;
}

#app-content .card-header {
    color: #EA580C !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-bottom: 1px solid #374151 !important;
}

/* Button overrides in authenticated area */
#app-content .btn-primary,
#app-content .btn-danger {
    background: #B91C1C !important;
    border-color: #B91C1C !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.4) !important;
}

#app-content .btn-primary:hover,
#app-content .btn-danger:hover {
    background: #7F1D1D !important;
    border-color: #7F1D1D !important;
    box-shadow: 0 0 30px rgba(185, 28, 28, 0.6) !important;
    transform: translateY(-2px);
}

/* Checklist and form elements in dark theme */
#app-content .form-check label,
#app-content .form-check .form-check-label,
#app-content .dash-checklist-container label {
    color: #E5E7EB !important;
}

/* Override any Bootstrap/form light backgrounds that slip through */
#app-content .card .card-header[style*="f8f9fa"],
#app-content .card .card-header[style*="f3f4f6"] {
    background: #1C1C1C !important;
    color: #EA580C !important;
}

/* Formando o Grid - conversation list items hover */
#app-content .grid-conv-item:hover {
    background: #1F2937 !important;
    cursor: pointer;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #app-content {
        margin-left: 0 !important;
        padding-top: 72px !important;
    }

    .page-title-auth {
        font-size: clamp(24px, 6vw, 32px) !important;
    }
}

/* ── Grid input contrast fix ─────────────────────────────────── */
#grid-input-pilot-id,
#grid-input-message,
#grid-modal-add-pilot-input,
#grid-modal-rename-group-input {
    color: #F9FAFB !important;
    background-color: #111827 !important;
    -webkit-text-fill-color: #F9FAFB !important;
    caret-color: #F9FAFB !important;
}

#grid-input-pilot-id::placeholder,
#grid-input-message::placeholder,
#grid-modal-add-pilot-input::placeholder,
#grid-modal-rename-group-input::placeholder {
    color: #6B7280 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #6B7280 !important;
}

#grid-input-pilot-id:-webkit-autofill,
#grid-modal-add-pilot-input:-webkit-autofill,
#grid-modal-rename-group-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px #111827 inset !important;
    -webkit-text-fill-color: #F9FAFB !important;
    caret-color: #F9FAFB !important;
}

#grid-input-pilot-id:focus,
#grid-input-message:focus,
#grid-modal-add-pilot-input:focus,
#grid-modal-rename-group-input:focus {
    color: #F9FAFB !important;
    background-color: #111827 !important;
    -webkit-text-fill-color: #F9FAFB !important;
    border-color: #EA580C !important;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.25) !important;
}

/* ===== TELEMETRY PAGE: LOCAL LIGHT/DARK THEMES ===== */
#app-content .telemetry-page {
    border-radius: 12px;
}

#app-content .telemetry-page .btn-check + .btn {
    min-width: 86px;
    font-weight: 700;
}

#app-content .telemetry-page[data-theme="dark"] {
    --tel-page-bg: #0F1115;
    --tel-panel: #1C1C1C;
    --tel-panel-alt: #0F0F0F;
    --tel-border: #374151;
    --tel-text: #F9FAFB;
    --tel-text-secondary: #D1D5DB;
    --tel-muted: #9CA3AF;
    --tel-accent: #EA580C;
    --tel-success: #10B981;
    --tel-warning: #F59E0B;
    --tel-danger: #EF4444;
    --tel-info: #3B82F6;
}

#app-content .telemetry-page[data-theme="light"] {
    --tel-page-bg: #F4F7FB;
    --tel-panel: #FFFFFF;
    --tel-panel-alt: #F8FAFC;
    --tel-border: #CBD5E1;
    --tel-text: #0F172A;
    --tel-text-secondary: #1E293B;
    --tel-muted: #475569;
    --tel-accent: #C2410C;
    --tel-success: #047857;
    --tel-warning: #B45309;
    --tel-danger: #B91C1C;
    --tel-info: #1D4ED8;
}

#app-content .telemetry-page[data-theme] {
    background: var(--tel-page-bg) !important;
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] .page-title-auth,
#app-content .telemetry-page[data-theme] .page-subtitle-auth,
#app-content .telemetry-page[data-theme] h1,
#app-content .telemetry-page[data-theme] h2,
#app-content .telemetry-page[data-theme] h3,
#app-content .telemetry-page[data-theme] h4,
#app-content .telemetry-page[data-theme] h5,
#app-content .telemetry-page[data-theme] h6,
#app-content .telemetry-page[data-theme] p,
#app-content .telemetry-page[data-theme] span,
#app-content .telemetry-page[data-theme] label {
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] .page-subtitle-auth {
    color: var(--tel-muted) !important;
}

#app-content .telemetry-page[data-theme] .page-header-auth {
    border-bottom-color: var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme] .card,
#app-content .telemetry-page[data-theme] .card-body,
#app-content .telemetry-page[data-theme] .card-header {
    background: var(--tel-panel) !important;
    border-color: var(--tel-border) !important;
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-layout,
#app-content .telemetry-page[data-theme] #tel-speed-time-graph,
#app-content .telemetry-page[data-theme] #tel-laps-panel,
#app-content .telemetry-page[data-theme] #tel-sec-panel,
#app-content .telemetry-page[data-theme] #tel-status,
#app-content .telemetry-page[data-theme] #tel-session-status,
#app-content .telemetry-page[data-theme] #tel-lap-debug-phase1,
#app-content .telemetry-page[data-theme] #tel-lap-debug-phase2,
#app-content .telemetry-page[data-theme] #tel-background-instructions > div,
#app-content .telemetry-page[data-theme] #tel-saved-sessions-list > div {
    border-color: var(--tel-border) !important;
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] #tel-events-title,
#app-content .telemetry-page[data-theme] #tel-chart-title,
#app-content .telemetry-page[data-theme] #tel-laps-title {
    color: var(--tel-accent) !important;
}

#app-content .telemetry-page[data-theme] #tel-speed-bins-text,
#app-content .telemetry-page[data-theme] #tel-quali-summary,
#app-content .telemetry-page[data-theme] #tel-race-summary,
#app-content .telemetry-page[data-theme] #tel-gps-quality {
    color: var(--tel-text-secondary) !important;
}

#app-content .telemetry-page[data-theme] #tel-events-panel,
#app-content .telemetry-page[data-theme] #tel-chart-panel,
#app-content .telemetry-page[data-theme] #tel-race-sessions-panel,
#app-content .telemetry-page[data-theme] #tel-saved-sessions-panel,
#app-content .telemetry-page[data-theme] #tel-laps-panel,
#app-content .telemetry-page[data-theme] #tel-sec-panel,
#app-content .telemetry-page[data-theme] #tel-lap-debug-phase1,
#app-content .telemetry-page[data-theme] #tel-lap-debug-phase2,
#app-content .telemetry-page[data-theme] #tel-session-status,
#app-content .telemetry-page[data-theme] #tel-status {
    background: var(--tel-panel) !important;
    border: 1px solid var(--tel-border) !important;
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] #tel-events-panel span,
#app-content .telemetry-page[data-theme] #tel-race-sessions-panel span,
#app-content .telemetry-page[data-theme] #tel-speed-bins-text,
#app-content .telemetry-page[data-theme] #tel-session-status,
#app-content .telemetry-page[data-theme] #tel-status,
#app-content .telemetry-page[data-theme] #tel-gps-quality {
    color: var(--tel-text-secondary) !important;
}

#app-content .telemetry-page[data-theme] #tel-event-sprints {
    color: var(--tel-success) !important;
}

#app-content .telemetry-page[data-theme] #tel-event-brakes {
    color: var(--tel-danger) !important;
}

#app-content .telemetry-page[data-theme] #tel-direction-changes-rate {
    color: var(--tel-info) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-layout {
    background: var(--tel-panel) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-layout > div:first-child > .tel-racing-lap-card div:first-child {
    color: var(--tel-text-secondary) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-current-lap,
#app-content .telemetry-page[data-theme] #tel-racing-previous-lap {
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-speed-unit {
    color: var(--tel-text-secondary) !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-speed-label {
    color: var(--tel-muted) !important;
}

#app-content .telemetry-page[data-theme] #tel-normal-kpi-grid .card {
    border: 1px solid var(--tel-border) !important;
    background: var(--tel-panel) !important;
    box-shadow: none !important;
}

#app-content .telemetry-page[data-theme] #tel-normal-kpi-grid .card-body > div:first-child {
    color: var(--tel-accent) !important;
}

#app-content .telemetry-page[data-theme] #tel-normal-kpi-grid .card-body > div:nth-child(2) {
    color: var(--tel-text-secondary) !important;
    font-weight: 600 !important;
}

#app-content .telemetry-page[data-theme] #tel-normal-kpi-grid .card-body > div:nth-child(3) {
    color: var(--tel-text) !important;
    font-weight: 700 !important;
}

#app-content .telemetry-page[data-theme] #tel-race-sessions-panel #tel-quali-laps-list,
#app-content .telemetry-page[data-theme] #tel-race-sessions-panel #tel-race-laps-list {
    background: var(--tel-panel-alt) !important;
    border-radius: 6px !important;
    padding: 8px !important;
}

#app-content .telemetry-page[data-theme] #tel-chart-panel .js-plotly-plot,
#app-content .telemetry-page[data-theme] #tel-chart-panel .plot-container,
#app-content .telemetry-page[data-theme] #tel-chart-panel .svg-container {
    background: var(--tel-panel-alt) !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-chart-panel {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
}

#app-content .telemetry-page[data-theme] #tel-saved-sessions-list .tel-session-history-card {
    background: var(--tel-panel-alt) !important;
    border: 1px solid var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme] #tel-saved-sessions-list .tel-session-meta-primary {
    color: var(--tel-accent) !important;
}

#app-content .telemetry-page[data-theme] #tel-saved-sessions-list .tel-session-meta-secondary {
    color: var(--tel-text-secondary) !important;
}

#app-content .telemetry-page[data-theme] #tel-saved-sessions-list a {
    color: var(--tel-info) !important;
}

#app-content .telemetry-page[data-theme] #tel-saved-sessions-list > div,
#app-content .telemetry-page[data-theme] #tel-saved-sessions-list p,
#app-content .telemetry-page[data-theme] #tel-saved-sessions-list span {
    color: var(--tel-text) !important;
}

#app-content .telemetry-page[data-theme] .tooltip-inner {
    background: var(--tel-panel-alt) !important;
    color: var(--tel-text) !important;
    border: 1px solid var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme] .modal-content {
    background: var(--tel-panel) !important;
    color: var(--tel-text) !important;
    border-color: var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme] .modal-header,
#app-content .telemetry-page[data-theme] .modal-footer {
    border-color: var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme="light"] .spinner-border {
    border-color: #94A3B8 !important;
    border-right-color: transparent !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-lap-debug-phase1,
#app-content .telemetry-page[data-theme="light"] #tel-lap-debug-phase2 {
    color: #1E293B !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-no-sessions,
#app-content .telemetry-page[data-theme="light"] #tel-speed-bins-text {
    color: #334155 !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-racing-layout {
    background: #FFFFFF !important;
}

#app-content .telemetry-page[data-theme="light"] .tel-racing-lap-card {
    background: #E2E8F0 !important;
    border: 1px solid #CBD5E1 !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-racing-speed-display {
    color: #0F172A !important;
    text-shadow: 0 0 12px rgba(15, 23, 42, 0.12) !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-racing-speed-unit {
    color: #1E293B !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-racing-speed-label {
    color: #334155 !important;
}

#app-content .telemetry-page[data-theme] #tel-racing-exit-btn {
    border: 1px solid var(--tel-border) !important;
}

#app-content .telemetry-page[data-theme="dark"] #tel-racing-exit-btn {
    background: rgba(0, 0, 0, 0.55) !important;
    color: rgba(255, 255, 255, 0.92) !important;
}

#app-content .telemetry-page[data-theme="light"] #tel-racing-exit-btn {
    background: rgba(255, 255, 255, 0.98) !important;
    color: #0F172A !important;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.2) !important;
}

#app-content .telemetry-page[data-theme="light"] .js-plotly-plot text {
    fill: #0F172A !important;
}

#app-content .telemetry-page[data-theme="light"] .js-plotly-plot .xtick text,
#app-content .telemetry-page[data-theme="light"] .js-plotly-plot .ytick text {
    fill: #1E293B !important;
}
