:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.hidden { display: none !important; }

/* Setup Screen Styling */
.setup-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
}

.setup-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.setup-card h1 { margin-bottom: 1rem; font-weight: 700; color: var(--accent); }
.setup-card p { color: var(--text-dim); margin-bottom: 2rem; }

.input-group { text-align: left; margin-bottom: 1.5rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-dim); }
.input-group input {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    padding: 0.8rem;
    border-radius: 0.5rem;
    color: white;
    font-size: 1rem;
}

.divider {
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    color: var(--text-dim);
}
.divider::before, .divider::after {
    content: ""; flex: 1; height: 1px; background: #334155; margin: 0 1rem;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 0.8rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: #334155; color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 20px var(--accent-glow); }

/* Main Layout */
#main-screen {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 3rem;
}

.nav-links { list-style: none; flex: 1; }
.nav-links li {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-dim);
    transition: var(--transition);
}

.nav-links li.active, .nav-links li:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #0b0f1a;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Dashboard Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Light Cards */
.card {
    background: var(--bg-card);
    border-radius: 1.25rem;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card.on {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.icon-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.card.on .icon-circle {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px var(--accent);
}

/* Controls */
.slider-container { margin-top: 1rem; }
.slider-label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 5px; display: block;}

input[type=range] {
    width: 100%;
    appearance: none;
    background: #334155;
    height: 6px;
    border-radius: 3px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}
.slider-toggle:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider-toggle { background-color: var(--accent); }
input:checked + .slider-toggle:before { transform: translateX(24px); }

/* Room Groups */
.room-section { margin-bottom: 3rem; }
.room-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #1e293b;
}

/* Sensor Display */
.sensor-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 20px;
    background: #0f172a;
    font-size: 0.8rem;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.pulse-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 2rem;
    animation: pulse 2s infinite ease-in-out;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #main-screen { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 0.5rem;
        order: 2;
        justify-content: space-around;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }
    .nav-logo, .nav-links span, .nav-footer { display: none; }
    .nav-links { display: flex; width: 100%; justify-content: space-around; margin: 0; }
    .nav-links li { margin: 0; padding: 1rem; }
    .content-area { order: 1; height: calc(100vh - 70px); padding: 1rem; }
}
