/* ============================================
   HomeDash — Style
   ============================================ */

:root {
    --bg: #f8f9fb;
    --bg2: #ffffff;
    --bg3: #f0f1f4;
    --text: #1a1a2e;
    --text2: #6b7280;
    --text3: #9ca3af;
    --border: #e5e7eb;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --blue: #3b82f6;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
    --bg: #0f0f1a;
    --bg2: #1a1a2e;
    --bg3: #252540;
    --text: #f1f1f6;
    --text2: #9ca3af;
    --text3: #6b7280;
    --border: #2d2d4a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 14px; font-weight: 500;
    cursor: pointer; border: none; transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon {
    background: none; border: none; font-size: 18px; cursor: pointer;
    padding: 6px; border-radius: 8px; transition: background 0.2s;
}
.btn-icon:hover { background: var(--bg3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Landing Page
   ============================================ */

.landing { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 0; gap: 24px;
}
.logo { font-size: 20px; font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); }

.hero {
    text-align: center; padding: 80px 0 60px;
}
.hero-badge {
    display: inline-block; padding: 6px 16px; border-radius: 20px;
    background: var(--bg3); color: var(--text2); font-size: 13px; font-weight: 500;
    margin-bottom: 24px;
}
.hero h1 {
    font-size: clamp(40px, 7vw, 72px); font-weight: 700;
    line-height: 1.05; letter-spacing: -2px; margin-bottom: 20px;
}
.hero-sub {
    font-size: 18px; color: var(--text2); max-width: 560px;
    margin: 0 auto 32px; line-height: 1.6;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero-preview {
    display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
    margin-top: 60px;
}
.preview-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px 32px; text-align: left; box-shadow: var(--shadow); min-width: 200px;
}
.preview-room { font-size: 13px; color: var(--text2); font-weight: 500; margin-bottom: 4px; }
.preview-temp { font-size: 42px; font-weight: 300; letter-spacing: -2px; }
.preview-meta { font-size: 12px; color: var(--text3); margin-top: 8px; display: flex; align-items: center; }

.dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px;
}
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }
.dot-off { background: var(--text3); }

/* Features */
.features-section { padding: 80px 0; text-align: center; }
.features-section h2 { font-size: 32px; font-weight: 700; margin-bottom: 48px; letter-spacing: -1px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 32px; text-align: left; }
.feature {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; box-shadow: var(--shadow);
}
.feature-icon { font-size: 28px; margin-bottom: 12px; }
.feature h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature p { font-size: 14px; color: var(--text2); line-height: 1.6; }

/* Pricing */
.pricing-section { padding: 80px 0; text-align: center; }
.pricing-section h2 { font-size: 32px; font-weight: 700; margin-bottom: 8px; letter-spacing: -1px; }
.pricing-sub { color: var(--text2); margin-bottom: 40px; }
.pricing-grid { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }
.pricing-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 36px; text-align: left; width: 300px; box-shadow: var(--shadow); position: relative;
}
.pricing-featured { border-color: var(--primary); }
.pricing-badge {
    position: absolute; top: -12px; right: 20px;
    background: var(--primary); color: #fff; padding: 4px 12px;
    border-radius: 12px; font-size: 11px; font-weight: 600;
}
.pricing-tier { font-size: 14px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }
.pricing-price { font-size: 48px; font-weight: 700; margin: 8px 0 20px; letter-spacing: -2px; }
.pricing-price span { font-size: 16px; font-weight: 400; color: var(--text2); }
.pricing-card ul { list-style: none; margin-bottom: 24px; }
.pricing-card li { padding: 6px 0; font-size: 14px; color: var(--text2); }

.landing-footer { text-align: center; padding: 40px 0; color: var(--text3); font-size: 13px; }
.landing-footer a { color: var(--text2); }

/* ============================================
   Dashboard App
   ============================================ */

.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; background: var(--bg2); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.app-logo { font-size: 18px; font-weight: 700; cursor: pointer; }
.app-controls { display: flex; align-items: center; gap: 8px; }
.app-controls select {
    background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 10px; font-family: var(--font); font-size: 13px; color: var(--text);
}

.dashboard { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* Room */
.room {
    margin-bottom: 32px;
}
.room-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.room-title { font-size: 20px; font-weight: 600; }
.room-actions { display: flex; gap: 4px; }

.widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* Widget */
.widget {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}
.widget:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.widget-name { font-size: 12px; color: var(--text2); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.widget-value {
    font-size: 36px; font-weight: 300; letter-spacing: -1.5px; line-height: 1.1;
}
.widget-unit { font-size: 16px; color: var(--text3); font-weight: 400; }
.widget-status { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text3); }
.widget-chart { margin-top: 12px; height: 40px; }
.widget-chart canvas { width: 100%; height: 100%; }

.widget-delete {
    position: absolute; top: 8px; right: 8px; opacity: 0;
    transition: opacity 0.2s; background: none; border: none;
    cursor: pointer; font-size: 14px; color: var(--text3);
}
.widget:hover .widget-delete { opacity: 1; }

/* Binary widget */
.widget-binary .widget-value { font-size: 14px; font-weight: 500; }
.widget-binary .widget-indicator {
    width: 48px; height: 48px; border-radius: 50%; margin: 8px 0;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.widget-binary .indicator-on { background: rgba(34,197,94,0.15); }
.widget-binary .indicator-off { background: var(--bg3); }

/* Status colors */
.status-good { color: var(--green); }
.status-warn { color: var(--yellow); }
.status-alert { color: var(--red); }

/* Empty state */
.empty-state {
    text-align: center; padding: 80px 24px; color: var(--text3);
}
.empty-state h2 { font-size: 24px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* Modal */
.modal {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.modal-content {
    background: var(--bg2); border-radius: var(--radius); width: 100%;
    max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-body label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin: 12px 0 4px; }
.modal-body input, .modal-body select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
    background: var(--bg); color: var(--text);
}
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.setting-group h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
#connStatus { margin-top: 8px; font-size: 13px; }

.room-config {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.room-config input { flex: 1; }

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .hero { padding: 40px 0 40px; }
    .hero h1 { font-size: 36px; letter-spacing: -1px; }
    .features-grid { grid-template-columns: 1fr; }
    .pricing-grid { flex-direction: column; align-items: center; }
    .widgets { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .dashboard { padding: 16px; }
    .widget { padding: 16px; }
    .widget-value { font-size: 28px; }
    .nav-links a:not(.btn) { display: none; }
}

@media (max-width: 480px) {
    .widgets { grid-template-columns: 1fr 1fr; }
}

/* Tablet/Kiosk mode — large screens, fullscreen */
@media (min-width: 1024px) and (display-mode: fullscreen) {
    .widget-value { font-size: 48px; }
    .widgets { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
}
