:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #222222;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#clock {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn .icon {
    font-size: 1.8rem;
}

.action-btn.home {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.action-btn.away {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}

.action-btn.postpone {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-btn:active {
    transform: translateY(0);
}

/* Schedule Panel */
.schedule-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.schedule-panel h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.schedule-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.schedule-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.schedule-item label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.schedule-item input[type="time"] {
    padding: 12px 16px;
    border: 2px solid #333;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

.schedule-item input[type="time"]:focus {
    border-color: var(--accent);
}

.schedule-status {
    margin-top: 16px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.schedule-status.active {
    color: var(--success);
}

/* Devices Section */
.devices-section h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.devices-grid {
    display: grid;
    gap: 16px;
}

.device-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.device-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.device-status {
    font-size: 1.5rem;
}

.device-status.connected {
    color: var(--success);
}

.device-status.disconnected {
    color: var(--danger);
}

/* Toggle Switch */
.toggle-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.switch {
    position: relative;
    width: 56px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #333;
    border-radius: 28px;
    transition: 0.3s;
}

.switch .slider:before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.switch input:checked+.slider {
    background: var(--accent);
}

.switch input:checked+.slider:before {
    transform: translateX(28px);
}

/* Temperature Display */
.temp-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #1e3a5f, #2d4a6f);
    border-radius: 12px;
    margin-bottom: 16px;
}

.room-temp {
    font-size: 2.5rem;
    font-weight: 700;
    color: #60a5fa;
}

.temp-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Range Control */
.range-control {
    margin-top: 12px;
}

.range-control label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.temp-input {
    width: 60px;
    padding: 10px;
    border: 2px solid #333;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    outline: none;
}

.temp-input:focus {
    border-color: var(--accent);
}

.temp-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.temp-btn:hover {
    background: var(--accent-hover);
}

/* Brightness Control */
.brightness-control {
    margin-top: 16px;
}

.brightness-control label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.brightness-control input[type="range"] {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, #333, #fff);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.brightness-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Color Control */
.color-control {
    margin-top: 16px;
}

.color-control label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.color-control input[type="color"] {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
}

/* Presets */
.presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.preset-btn {
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.preset-btn:active {
    transform: scale(0.98);
}

.preset-btn.morning {
    background: linear-gradient(135deg, #ff9a56, #ffcc80);
    color: #333;
}

.preset-btn.day {
    background: linear-gradient(135deg, #4fc3f7, #81d4fa);
    color: #333;
}

.preset-btn.evening {
    background: linear-gradient(135deg, #7c4dff, #b388ff);
    color: white;
}

.preset-btn.red {
    background: linear-gradient(135deg, #ff1744, #ff5252);
    color: white;
}

/* Red Palette */
.red-palette {
    margin-top: 16px;
}

.red-palette label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.red-shades {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.shade-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.shade-btn:hover {
    transform: scale(1.1);
    border-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.shade-btn:active {
    transform: scale(0.95);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 14px 28px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 16px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    #clock {
        font-size: 1.5rem;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .action-btn {
        flex-direction: row;
        justify-content: center;
        padding: 16px;
    }

    .schedule-grid {
        grid-template-columns: 1fr;
    }
}