/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 1rem 2rem;
    text-align: center;
    max-width: 1920px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 300;
}

.app-header p {
    opacity: 0.8;
    font-size: 1rem;
}

.mode-indicator {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: inline-block;
    font-weight: 500;
}

/* Main Content Layout */
.app-main {
    display: flex;
    justify-content: center;
    grid-template-columns: 320px 1fr 500px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    overflow: hidden;
    max-width: 1920px;
}

/* Panel Styles */
.left-panel,
.center-panel,
.right-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    min-height: 0;
    width: fit-content;
    overflow: auto;
}

.left-panel {
    padding: 1rem;
    width: 320px;
}

.center-panel {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.right-panel {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

/* Section Styles */
section {
    margin-bottom: 1rem;
}

section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 0.5rem;
}

/* Form Controls */
.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ecf0f1;
    outline: none;
    -webkit-appearance: none;
    margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.control-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.clear-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.clear-btn:hover {
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.control-buttons,
.playback-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* File Upload */
.file-upload {
    margin-bottom: 1rem;
}

.upload-btn {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-block;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
}

.upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

input[type="file"] {
    display: none;
}

/* Timeline */
.timeline-group {
    margin-bottom: 1rem;
}

.timeline-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

#timeline-slider {
    background: linear-gradient(to right, #3498db 0%, #ecf0f1 0%);
}

/* Speed Control */
select {
    padding: 0.4rem 0.8rem;
    border: 2px solid #ecf0f1;
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #3498db;
}

/* Checkboxes */
input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: #3498db;
}

label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Rover Container */
.rover-container {
    position: relative;
    display: flex;
    background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 400px;
    justify-content: center;
    align-items: center;
}

#rover-canvas {
    border-radius: 6px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Rover HUD */
.rover-hud {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 0.6rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    height: 100px;
}

.hud-item {
    border-radius: 4px;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 60px;
}

.hud-item:last-child {
    border-bottom: none;
}

.hud-item h4 {
    margin: 0 0 0.3rem 0;
    color: #2c3e50;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.hud-value {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    gap: 0.2rem;
    flex-shrink: 0;
}

.hud-value span {
    font-size: 0.9rem;
    font-weight: 700;
    color: #3498db;
}

.hud-value .unit {
    font-size: 0.65rem;
    font-weight: 500;
}

/* HUD Gauge styling */
.hud-gauge {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.gauge-svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.gauge-svg circle {
    transition: stroke-dashoffset 0.3s ease;
}

#steering-wheel {
    transition: transform 0.3s ease;
}

/* Compass specific styling */
.compass-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.compass-svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

#compass-needle {
    transition: transform 0.3s ease;
}

.rover-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.status-item {
    background: #f8f9fa;
    padding: 0.8rem;
    border-radius: 6px;
    text-align: center;
    border: 2px solid #ecf0f1;
}

.status-item span:first-child {
    display: block;
    font-weight: 500;
    color: #2c3e50;
}

.status-item span:last-child {
    color: #3498db;
    font-weight: 600;
}

/* Footer */
.app-footer {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-top: 1px solid #34495e;
    max-width: 1920px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-self: start;
}

.footer-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-logo .logo {
    height: 32px;
    width: auto;
    opacity: 0.9;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #27ae60;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.stats {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    justify-self: end;
}

.stats span {
    opacity: 0.8;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

#loading-progress {
    font-size: 0.9rem;
    color: #7f8c8d;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .app-main {
        grid-template-columns: 300px 1fr 450px;
    }
}

@media (max-width: 1200px) {
    .app-main {
        grid-template-columns: 280px 1fr 420px;
    }
}

@media (max-width: 1000px) {
    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-panel,
    .right-panel {
        max-height: 400px;
    }
    
    .center-panel {
        order: -1;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .app-main {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .control-buttons,
    .playback-buttons {
        justify-content: center;
    }
    
    .rover-status {
        grid-template-columns: 1fr;
    }
    
    .rover-hud {
        position: static;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
        background: rgba(255, 255, 255, 0.95);
    }
    
    .hud-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-width: auto;
    }
    
    .hud-item h4 {
        margin: 0;
    }
    
    .app-footer {
        padding: 1rem;
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }
    
    .connection-status,
    .stats {
        justify-self: center;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #7f8c8d;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
