/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme (default) */
    --bg-color: #f5f5f5;
    --text-color: #333333;
    --section-bg: #f8f8f8;
    --border-color: #dddddd;
    --label-color: #666666;
    --driver-color: #333333;
    --button-bg: #fff;
    --button-hover: #f9f9f9;
    --button-border: #ddd;
    --button-shadow: rgba(0, 0, 0, 0.2);
    --button-shadow-hover: rgba(0, 0, 0, 0.3);
    --display-title: #333333;
    --display-selector-bg: #f8f8f8;
    --last-sync-color: #666;
    --button-accent: #FF4500;
}

/* Dark theme */
body.dark-theme {
    --bg-color: #121212;
    --text-color: #f0f0f0;
    --section-bg: #202020;
    --border-color: #333333;
    --label-color: #aaaaaa;
    --driver-color: #f0f0f0;
    --button-bg: #2a2a2a;
    --button-hover: #333333;
    --button-border: #444444;
    --button-shadow: rgba(0, 0, 0, 0.5);
    --button-shadow-hover: rgba(0, 0, 0, 0.7);
    --display-title: #f0f0f0;
    --display-selector-bg: #181818;
    --last-sync-color: #aaa;
    --button-accent: #FF6347;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Time section (1/5 height) */
.time-section {
    height: 24vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--section-bg);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.section-label {
    font-size: 3vh;
    margin-bottom: 1vh;
    color: var(--label-color);
    transition: color 0.3s ease;
}

.official-time {
    font-size: 12vh;
    font-weight: bold;
    color: var(--text-color);
    transition: color 0.3s ease;
}

/* Driver section (3/5 height) */
.driver-section {
    height: 62vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2vh;
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

.driver-name {
    font-size: 14vh;
    margin-bottom: 3vh;
    font-style: italic;
    text-transform: uppercase;
    color: var(--driver-color);
    transition: color 0.3s ease;
}

.countdown {
    font-size: 34vh;
    font-weight: bold;
    color: var(--text-color);
    transition: color 0.3s ease;
}

/* IN/OUT section (1/5 height) */
.in-out-section {
    height: 14vh;
    padding: 2vh;
    background-color: var(--section-bg);
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.labels, .times {
    display: flex;
    justify-content: space-between;
    padding: 0 5vw;
}

.in-label, .out-label {
    font-size: 3vh;
    font-weight: bold;
    color: var(--label-color);
    transition: color 0.3s ease;
}

.in-time, .out-time {
    font-size: 6vh;
    color: var(--text-color);
    transition: color 0.3s ease;
}

/* State-specific styles */
.countdown.service {
    color: #ff0000;
}

.countdown.warning {
    animation: blink 1s infinite;
}

.countdown.overtime {
    color: #ff0000;
}

/* Service time styles for top and bottom sections */
.service-time .time-section,
.service-time .in-out-section {
    background-color: rgba(40, 180, 69, 0.35); /* Green with transparency, more saturated */
}

body.dark-theme .service-time .time-section,
body.dark-theme .service-time .in-out-section {
    background-color: rgba(40, 190, 69, 0.25); /* Darker green with transparency, more saturated */
}

/* Warning time styles for top and bottom sections */
.warning-time .time-section,
.warning-time .in-out-section {
    background-color: rgba(255, 87, 34, 0.35); /* Orange-red with transparency, more saturated */
}

body.dark-theme .warning-time .time-section,
body.dark-theme .warning-time .in-out-section {
    background-color: rgba(255, 87, 34, 0.25); /* Darker orange-red with transparency, more saturated */
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.1; }
    100% { opacity: 1; }
}

/* Connection status indicator */
.status-container {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    z-index: 100;
}

.status-indicator {
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: bold;
}

.status-connected {
    background-color: rgba(0, 200, 0, 0.2);
    color: #00aa00;
}

body.dark-theme .status-connected {
    background-color: rgba(0, 200, 0, 0.3);
    color: #00ff00;
}

.status-disconnected {
    background-color: rgba(255, 0, 0, 0.2);
    color: #cc0000;
    animation: pulse 1.5s infinite;
}

body.dark-theme .status-disconnected {
    background-color: rgba(255, 0, 0, 0.3);
    color: #ff3333;
}

#last-sync {
    position: absolute;
    top: 40px;
    right: 10px;
    font-size: 12px;
    color: var(--last-sync-color);
    z-index: 100;
    transition: color 0.3s ease;
}

/* Theme toggle */
.theme-toggle {
    width: 30px;
    height: 30px;
    background-color: rgba(128, 128, 128, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-left: 8px;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background-color: rgba(128, 128, 128, 0.3);
}

.theme-icon {
    font-size: 16px;
}

/* Offline mode indicator */
body.offline-mode {
    box-shadow: inset 0 0 0 3px rgba(255, 0, 0, 0.5);
}

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

/* Display Selector */
.display-selector {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    text-align: center;
    background-color: var(--display-selector-bg);
    transition: background-color 0.3s ease;
    position: relative; /* Ensure absolute positioned children are relative to this */
}

.display-selector h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--display-title);
    transition: color 0.3s ease;
}

.display-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    max-width: 800px;
}

.display-button {
    padding: 1.5rem 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    border: 1px solid var(--button-border);
    border-radius: 5px;
    background-color: var(--button-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px var(--button-shadow);
    border-left: 4px solid var(--button-accent);
}

.display-button:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--button-shadow-hover);
}

.display-button:active {
    transform: scale(0.98);
}

.display-info {
    font-size: 1rem;
    margin-top: 0.8rem;
    font-style: italic;
    font-weight: normal;
    transition: color 0.3s ease;
}

.display-info.loading {
    opacity: 0.7;
}
