/* style.css */

:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-panel-transparent: rgba(30, 30, 30, 0.7);
    --primary: #00d4ff;
    --primary-hover: #00a3cc;
    --secondary: #ff0055;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --border: #333333;
    --shadow-glow: 0 0 15px rgba(0, 212, 255, 0.3);
    --glass: blur(10px);
    --radius: 12px;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

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

/* SCREEN MANAGEMENT */
.screen {
    display: none;
    height: 100%;
    width: 100%;
}

.screen.active {
    display: flex;
}

/* SETUP SCREEN */
#setup-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
}

.setup-container {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid var(--border);
    backdrop-filter: var(--glass);
}

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-area i {
    font-size: 3rem;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary);
    margin-bottom: 0.5rem;
}

.logo-area h1 {
    font-weight: 800;
    letter-spacing: 2px;
}

.setup-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.3s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.setup-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.setup-panel.active {
    display: block;
}

.instruction {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

input[type="text"], select {
    width: 100%;
    padding: 10px;
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: white;
    font-family: var(--font-main);
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* BUTTONS */
.primary-btn, .action-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 15px var(--primary);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.danger-btn {
    background: var(--secondary);
    color: white;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.icon-btn:hover {
    color: var(--primary);
}

/* MAIN LAYOUT */
#app-screen {
    flex-direction: row;
}

/* SIDEBAR */
#sidebar {
    width: 250px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand i {
    color: var(--primary);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-links li.active a, .nav-links a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-links li.active a {
    border-left: 3px solid var(--primary);
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.connection-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.online { background: #00ff00; box-shadow: 0 0 5px #00ff00; }
.dot.offline { background: #ff0000; }

/* MAIN CONTENT */
#main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-dark);
    position: relative;
}

/* TOP BAR */
.top-bar {
    position: sticky;
    top: 0;
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.page-title h2 {
    font-weight: 600;
}

#last-sync {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* VIEWS */
.view {
    display: none;
    padding: 2rem;
    animation: slideUp 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* DASHBOARD */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-panel-transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: var(--glass);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.panel-header h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.action-btn {
    margin-bottom: 0.5rem;
}

/* LIGHTS GRID */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.light-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    transition: all 0.3s;
    cursor: pointer;
}

.light-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.light-card.on {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.1);
}

.light-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.light-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.light-toggle {
    width: 40px;
    height: 20px;
    background: #333;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
}

.light-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.light-card.on .light-toggle {
    background: var(--primary);
}

.light-card.on .light-toggle::after {
    transform: translateX(20px);
}

.light-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.light-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* ROOMS */
.room-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.room-header {
    padding: 1.5rem;
    background: rgba(255,255,255,0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.room-lights {
    display: none;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
}

.room-lights.show {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-panel);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* SWITCH */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* EFFECTS PANEL */
.effects-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.effects-controls .input-group {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* TOASTS */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
}

.toast {
    background: var(--bg-panel);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    margin-top: 10px;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -250px;
        height: 100%;
        z-index: 50;
        transition: left 0.3s;
    }
    
    #sidebar.open {
        left: 0;
    }

    .dashboard-grid, .effects-layout {
        grid-template-columns: 1fr;
    }
}
