/* ==================== CSS Variables ==================== */
:root {
    /* Light mode colors */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-tertiary: #a0aec0;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --timeline-day: linear-gradient(90deg, #ffeaa7 0%, #fdcb6e 25%, #74b9ff 50%, #a29bfe 75%, #2d3436 100%);
    --clock-bg: #ffffff;
    --clock-border: #e2e8f0;
    --day-color: #fbbf24;
    --night-color: #6366f1;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --gradient-primary: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
    --timeline-day: linear-gradient(90deg, #fcd34d 0%, #f59e0b 25%, #3b82f6 50%, #8b5cf6 75%, #111827 100%);
    --clock-bg: #1e293b;
    --clock-border: #334155;
    --day-color: #fbbf24;
    --night-color: #818cf8;
}

/* ==================== Global Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle .sun-icon {
    display: block;
    color: var(--accent-primary);
}

.theme-toggle .moon-icon {
    display: none;
    color: var(--accent-primary);
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* ==================== Header ==================== */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ==================== Location Selectors ==================== */
.location-selectors {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 40px;
    align-items: center;
}

.location-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.location-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.location-card label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
}

.location-search {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.location-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.location-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.location-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.location-select:hover {
    border-color: var(--accent-primary);
}

.swap-button {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.swap-button:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: var(--shadow-lg);
}

.swap-button svg {
    color: white;
}

/* ==================== Time Display ==================== */
.time-display-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

.time-card {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.time-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.time-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.time-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.day-night-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.day-night-indicator.day {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.day-night-indicator.night {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.day-night-indicator .day-icon,
.day-night-indicator .night-icon {
    display: none;
    color: white;
}

.day-night-indicator.day .day-icon {
    display: block;
}

.day-night-indicator.night .night-icon {
    display: block;
}

/* ==================== Analog Clock ==================== */
.analog-clock {
    width: 200px;
    height: 200px;
    margin: 0 auto 24px;
}

.clock-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--clock-bg);
    border: 4px solid var(--clock-border);
    position: relative;
    box-shadow: inset var(--shadow-sm), var(--shadow-md);
}

.clock-face::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 50%;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.clock-face::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 50%;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.clock-hour-hand,
.clock-minute-hand,
.clock-second-hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    border-radius: 10px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.clock-hour-hand {
    width: 6px;
    height: 50px;
    background: var(--text-primary);
    margin-left: -3px;
}

.clock-minute-hand {
    width: 4px;
    height: 70px;
    background: var(--accent-primary);
    margin-left: -2px;
}

.clock-second-hand {
    width: 2px;
    height: 80px;
    background: #ef4444;
    margin-left: -1px;
}

.clock-center {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

/* ==================== Digital Time ==================== */
.digital-time {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-variant-numeric: tabular-nums;
}

.date-display {
    font-size: 1.1rem;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.timezone-offset {
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ==================== Slider Container ==================== */
.slider-container {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.slider-label span {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.reset-button {
    padding: 10px 20px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.reset-button:active {
    transform: translateY(0);
}

/* ==================== Timeline Bar ==================== */
.timeline-bar {
    position: relative;
    height: 60px;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
}

.timeline-gradient {
    width: 100%;
    height: 100%;
    background: var(--timeline-day);
    border-radius: 12px;
}

.timeline-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
}

.timeline-marker {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
}

.timeline-marker::before {
    content: '';
    width: 2px;
    height: 30px;
    background: rgba(255, 255, 255, 0.5);
    margin-bottom: 5px;
}

.timeline-marker span {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ==================== Time Slider ==================== */
.time-slider {
    width: 100%;
    height: 8px;
    border-radius: 10px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 20px;
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.time-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: none;
    transition: all 0.3s ease;
}

.time-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

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

.time-offset {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 968px) {
    .time-display-container {
        grid-template-columns: 1fr;
    }
    
    .location-selectors {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .swap-button {
        transform: rotate(90deg);
    }
    
    .swap-button:hover {
        transform: rotate(270deg) scale(1.1);
    }
}

@media (max-width: 640px) {
    body {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 0.95rem;
    }
    
    .location-card {
        padding: 16px;
    }
    
    .time-card {
        padding: 20px;
    }
    
    .analog-clock {
        width: 160px;
        height: 160px;
    }
    
    .digital-time {
        font-size: 2rem;
    }
    
    .slider-container {
        padding: 20px;
    }
    
    .slider-label {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.time-display-container,
.slider-container {
    animation: fadeIn 0.5s ease;
}

/* ==================== Loading State ==================== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ==================== Smooth Transitions ==================== */
* {
    transition-property: background, color, border-color, box-shadow, transform;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

button,
input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
    transition-property: all;
}
