/* ============================
   GLOBAL RESET
============================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

.dashboard-container {
    padding: 15px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================
   HEADER
============================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 90px;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-left img {
    height: 90px;
    width: auto;
    object-fit: contain;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-center h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ff6b35;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lap-counter-sleek {
    text-align: center;
    padding: 10px 20px;
    background: rgba(255, 107, 53, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 53, 0.3);
}

.lap-text {
    display: block;
    font-size: 0.75rem;
    color: #ff6b35;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.lap-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
}

/* AI Status Indicator */
.ai-status-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-status-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 100, 100, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.ai-status-circle.good {
    background: rgba(0, 255, 0, 0.2);
    border-color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5), 0 0 40px rgba(0, 255, 0, 0.3);
}

.ai-status-circle.bad {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5), 0 0 40px rgba(255, 0, 0, 0.3);
}

.ai-status-circle.neutral {
    background: rgba(150, 150, 150, 0.2);
    border-color: #999;
    box-shadow: 0 0 10px rgba(150, 150, 150, 0.3);
}

.ai-status-glow {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.ai-status-circle.good .ai-status-glow {
    background: radial-gradient(circle, rgba(0, 255, 0, 0.8) 0%, rgba(0, 255, 0, 0) 70%);
    animation: pulse-green 2s ease-in-out infinite;
}

.ai-status-circle.bad .ai-status-glow {
    background: radial-gradient(circle, rgba(255, 0, 0, 0.8) 0%, rgba(255, 0, 0, 0) 70%);
    animation: pulse-red 2s ease-in-out infinite;
}

.ai-status-circle.neutral .ai-status-glow {
    background: radial-gradient(circle, rgba(150, 150, 150, 0.5) 0%, rgba(150, 150, 150, 0) 70%);
}

@keyframes pulse-green {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

.ai-cue-display {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 80px;
    text-align: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-cue-display.cue-throttle {
    color: #00ff00;
    background: rgba(0, 255, 0, 0.1);
    border-color: rgba(0, 255, 0, 0.3);
}

.ai-cue-display.cue-coast {
    color: #ffff00;
    background: rgba(255, 255, 0, 0.1);
    border-color: rgba(255, 255, 0, 0.3);
}

.ai-cue-display.cue-stop {
    color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.3);
}

.ai-cue-display.cue-brake {
    color: #ff6600;
    background: rgba(255, 102, 0, 0.1);
    border-color: rgba(255, 102, 0, 0.3);
}

/* Buttons */
.start-btn,
.end-btn,
.reset-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 130px;
}

.start-btn {
    background: linear-gradient(135deg, #00ff00, #00cc00);
    box-shadow: 0 2px 8px rgba(0, 255, 0, 0.3);
}

.start-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #00cc00, #00ff00);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 0, 0.5);
}

.start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.end-btn {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
}

.end-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #cc0000, #ff4444);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.5);
}

.end-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.reset-btn {
    background: linear-gradient(135deg, #00ccff, #0066ff);
    box-shadow: 0 2px 8px rgba(0, 204, 255, 0.3);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #0066ff, #00ccff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 204, 255, 0.5);
}

/* ============================
   VIEW TOGGLE
============================ */
.view-toggle-section {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.toggle-container {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    gap: 6px;
}

.toggle-btn {
    padding: 12px 28px;
    border-radius: 8px;
    border: none;
    color: #bbb;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
}

/* ============================
   MAIN KPIs
============================ */
.main-data-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.main-data-item {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.main-data-item:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

.main-data-value {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
    color: #fff;
}

.main-data-label {
    text-transform: uppercase;
    color: #ff6b35;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.main-data-subtitle {
    color: #888;
    font-size: 0.8rem;
}

/* ============================
   TELEMETRY LAYOUT
============================ */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    min-height: 500px;
}

.telemetry-section {
    display: flex;
    flex-direction: column;
}

.location-section {
    display: flex;
    flex-direction: column;
}

/* ============================
   TELEMETRY CARD
============================ */
.telemetry-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 107, 53, 0.3);
}

.card-header h3 {
    text-align: center;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    color: #ff6b35;
}

.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

/* Metric Grid - Uniform Containers */
.metric-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 0;
}

.metric-row.metric-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.metric-row.metric-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.metric-row.metric-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.metric-row.metric-row-5 {
    grid-template-columns: repeat(5, 1fr);
}

.metric-row.gps-row {
    grid-template-columns: repeat(2, 1fr);
}

.metric-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    gap: 4px;
    transition: all 0.3s ease;
}

.metric-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    margin-bottom: 4px;
    margin-bottom: 6px;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-unit {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #888;
    font-weight: 500;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.metric-label {
    font-size: 0.7rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* ============================
   MAP
============================ */
.location-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.map-container {
    flex: 1;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    min-height: 400px;
}

.track-map {
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

/* Overlay (Loading / controls) */
.track-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 10px;
    transition: opacity 0.3s ease;
}

.track-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 20px;
}

.overlay-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #ff6b35;
}

.overlay-content p {
    color: #ccc;
    font-size: 1rem;
}

/* ============================
   ANALYTICS SECTION
============================ */
.graphs-section {
    margin-top: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
}

.graphs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 107, 53, 0.3);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.graphs-header h2 {
    font-size: 1.8rem;
    letter-spacing: 2px;
    color: #ff6b35;
    text-transform: uppercase;
    font-weight: 600;
}

.graph-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.graph-btn {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.graph-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.5);
}

.graph-btn.export-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.graph-btn.export-btn:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

.lap-selector {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lap-selector:hover {
    background: rgba(255, 255, 255, 0.15);
}

.graphs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.graph-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.graph-container:hover {
    border-color: rgba(255, 107, 53, 0.3);
    background: rgba(0, 0, 0, 0.4);
}

.graph-title {
    text-align: center;
    color: #ff6b35;
    text-transform: uppercase;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 107, 53, 0.2);
}

.plotly-graph {
    height: 320px;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
}

/* ============================
   FOOTER
============================ */
.footer {
    text-align: center;
    padding: 25px;
    color: #666;
    font-size: 0.9rem;
    margin-top: 20px;
}

/* ============================
   RESPONSIVE
============================ */
@media (max-width: 1200px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    
    .main-data-section {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .metric-row.metric-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .metric-row.metric-row-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-right {
        flex-direction: column;
        width: 100%;
    }
    
    .header-buttons {
        width: 100%;
    }
    
    .test-btn,
    .reset-btn,
    .log-btn {
        width: 100%;
    }
    
    .main-data-section {
        grid-template-columns: 1fr;
    }
    
    .metric-row,
    .metric-row.metric-row-4,
    .metric-row.metric-row-5 {
        grid-template-columns: 1fr;
    }
    
    .graphs-grid {
        grid-template-columns: 1fr;
    }
}
