/* ==========================================================================
   KIẾN TRÚC NHÀ PHỐ 3D PARAMETRIC - STYLESHEET
   Phong cách Architectural Minimalist / Dark & Glassmorphism UI
   ========================================================================== */

:root {
  --bg-primary: #0f141c;
  --bg-panel: rgba(18, 24, 38, 0.85);
  --bg-panel-border: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(30, 41, 59, 0.7);
  --accent-blue: #38bdf8;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-panel: 0 12px 36px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
}

#canvas-container {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   TOP BAR HEADER
   ========================================================================== */
.top-bar {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.brand-badge {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-tag {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 7px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 20px;
}

.top-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.btn-icon-text {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  padding: 9px 15px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-panel);
}

.btn-icon-text:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-icon-text:active {
  transform: translateY(1px);
}

/* ==========================================================================
   FLOATING HUD (TẦNG & CHẾ ĐỘ XEM)
   ========================================================================== */
.center-hud-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: auto;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: flex;
  gap: 6px;
  box-shadow: var(--shadow-panel);
}

.hud-group {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.hud-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
  user-select: none;
}

.hud-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.hud-btn:active {
  transform: scale(0.96);
}

.hud-btn.active {
  background: var(--accent-blue);
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.4);
}

/* ==========================================================================
   SIDEBAR ĐIỀU KHIỂN THAM SỐ (PARAMETRIC DRAWER)
   ========================================================================== */
.param-sidebar {
  position: absolute;
  top: 80px;
  left: 20px;
  bottom: 20px;
  width: 350px;
  max-width: calc(100vw - 40px);
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.param-sidebar.collapsed {
  transform: translateX(-375px);
  opacity: 0.2;
  pointer-events: none;
}

.sidebar-toggle-btn {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 9;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-panel-border);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-panel);
}

.param-sidebar.collapsed ~ .sidebar-toggle-btn {
  display: flex;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-sidebar-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-sidebar-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-content::-webkit-scrollbar {
  width: 5px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* THẺ THỐNG KÊ TỔNG QUAN */
.metrics-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.metric-value {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-top: 3px;
}

.metric-value.highlight {
  color: var(--accent-blue);
}

/* SECTION SLIDERS */
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.zone-slider-group {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.zone-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.zone-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(15, 23, 42, 0.8);
}

.zone-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.zone-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
}

.zone-dim {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-blue);
  font-family: monospace;
}

.zone-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(51, 65, 85, 0.8);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* TOGGLE LAUNDRY */
.laundry-toggle-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px;
}

.laundry-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.laundry-opt-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.laundry-opt-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

.laundry-opt-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
}

/* ==========================================================================
   BOTTOM FLOATING TOOLBAR (MẶT TRỜI & ĐIỀU KHIỂN NHANH)
   ========================================================================== */
.bottom-floating-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--shadow-panel);
}

.sun-control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 14px;
  border-right: 1px solid var(--bg-panel-border);
}

.sun-icon {
  font-size: 18px;
  color: #fbbf24;
}

.sun-slider-wrapper {
  display: flex;
  flex-direction: column;
  width: 140px;
}

.sun-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sun-time-display {
  color: #fef08a;
  font-family: monospace;
}

.quick-toggles {
  display: flex;
  gap: 8px;
}

.toggle-chip {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.toggle-chip:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.toggle-chip.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* Style riêng cho chip Đèn & chip Ban Đêm */
#toggle-light-btn.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: #fbbf24;
  color: #fde047;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

#toggle-night-btn.active {
  background: rgba(147, 51, 234, 0.22);
  border-color: #c084fc;
  color: #e9d5ff;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.35);
}

/* Color Temperature Selector Buttons */
.color-temp-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-temp-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

.color-temp-btn.active {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
  color: #fbbf24;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.35);
}

/* ==========================================================================
   WALKTHROUGH HUD OVERLAY
   ========================================================================== */
.walk-instructions {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(15, 23, 42, 0.90);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 30px;
  padding: 6px 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-size: 12px;
  color: #e2e8f0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  max-width: 95vw;
}

.walk-instructions.visible {
  display: flex;
}

.walk-info-text {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.walk-floor-badge {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

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

.walk-floor-switcher {
  display: flex;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 2px;
  gap: 2px;
}

.walk-floor-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.walk-floor-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.walk-floor-btn.active {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.key-badge {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}

.walk-exit-btn {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 5px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  transition: all 0.2s ease;
}

.walk-exit-btn:hover {
  background: rgba(239, 68, 68, 0.5);
  color: #fff;
}

/* ==========================================================================
   3D ROOM LABELS (CSS2D / Canvas Badges)
   ========================================================================== */
.room-3d-badge {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  color: #fff;
  font-size: 11px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  text-align: center;
  transition: opacity 0.2s ease;
}

.room-3d-badge .room-title {
  font-weight: 700;
  color: var(--accent-blue);
  font-size: 11px;
}

.room-3d-badge .room-area {
  font-size: 10px;
  color: #cbd5e1;
  font-weight: 600;
}

/* ==========================================================================
   MODAL DIALOG (JSON EXPORT / ROOM DETAILS)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.json-preview {
  background: #090d14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px;
  color: #38bdf8;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 350px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--bg-panel-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1024px) {
  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .center-hud-bar {
    top: 76px;
    max-width: 95vw;
    overflow-x: auto;
    padding: 4px;
  }
  .hud-btn {
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
  }
  .param-sidebar {
    width: 310px;
    top: 135px;
  }
  .bottom-floating-bar {
    width: calc(100vw - 30px);
    padding: 8px 12px;
  }
}

@media (max-width: 640px) {
  .brand-badge {
    padding: 6px 12px;
  }
  .brand-text h1 {
    font-size: 13px;
  }
  .brand-text p {
    display: none;
  }
  .center-hud-bar {
    top: 58px;
  }
  .param-sidebar {
    width: calc(100vw - 30px);
    left: 15px;
    top: 115px;
  }
}
