:root {
    /* Light Theme Variables */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6e6e73;
    --accent-color: #007aff;
    --accent-hover: #0062cc;
    --success-color: #34c759;
    --error-color: #ff3b30;
    --border-color: rgba(0,0,0,0.08);
    --card-shadow: 0 8px 24px rgba(0,0,0,0.04);
    --nav-bg: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-primary: #0a0a0c;
    --bg-secondary: #161618;
    --text-primary: #ffffff;
    --text-secondary: #a1a1a6;
    --accent-color: #2997ff;
    --accent-hover: #147ce3;
    --success-color: #30d158;
    --error-color: #ff453a;
    --border-color: rgba(255,255,255,0.08);
    --card-shadow: 0 8px 24px rgba(0,0,0,0.2);
    --nav-bg: rgba(22, 22, 24, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    user-select: none;
}

.text-accent {
    color: var(--accent-color);
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background-color: var(--bg-primary);
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    position: sticky;
    top: 0;
    background-color: var(--bg-primary);
    z-index: 10;
    transition: background-color 0.3s;
}

.vehicle-info h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.vin-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.icon-button {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hero Section */
.hero-section {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.car-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
}
.status-dot.active {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.car-image-container {
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}
.car-hero-img {
    width: 100%;
    height: auto;
    display: block;
    mix-blend-mode: luminosity; /* Style effect for dark theme matching */
}
[data-theme="dark"] .car-hero-img {
    opacity: 0.85;
}

/* Quick Controls */
.quick-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 0 20px;
    margin-bottom: 32px;
}

.control-btn {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    color: var(--text-primary);
}

.control-btn .icon-wrapper {
    width: 56px;
    height: 56px;
    background-color: var(--bg-secondary);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.control-btn span {
    font-size: 0.8rem;
    font-weight: 500;
}

.control-btn:active .icon-wrapper {
    transform: scale(0.95);
}

.control-btn.active .icon-wrapper {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Loading Spinner */
.loader {
    display: none;
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

.control-btn[data-loading="true"] .icon-wrapper {
    color: transparent;
}
.control-btn[data-loading="true"] .loader {
    display: block;
}
.control-btn.active[data-loading="true"] .loader {
    border-top-color: white;
}

@keyframes spin {
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Status Cards */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 20px;
    margin-bottom: 32px;
}

.status-card {
    background-color: var(--bg-secondary);
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.card-body h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background-color: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #5ac8fa);
    border-radius: 3px;
    transition: width 1s ease-in-out;
}

.sub-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Telemetry Panel */
.telemetry-panel {
    padding: 0 20px;
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.car-top-view {
    background-color: var(--bg-secondary);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    position: relative;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tire-pressures {
    position: relative;
    width: 140px;
    height: 200px;
}

.car-chassis {
    position: absolute;
    top: 10%;
    left: 20%;
    width: 60%;
    height: 80%;
    border: 2px solid var(--border-color);
    border-radius: 20px;
}

.tire {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tire.fl { top: 15%; left: -30px; }
.tire.fr { top: 15%; right: -30px; }
.tire.rl { bottom: 15%; left: -30px; }
.tire.rr { bottom: 15%; right: -30px; }

/* Location Panel */
.location-panel {
    padding: 0 20px;
}
.map-placeholder {
    height: 200px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    background-color: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item.active {
    color: var(--accent-color);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 200;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}
