/* ==============================================================================
   SMART HOME CLOUD DASHBOARD - MODERN DARK GLASSMORPHISM STYLESHEET
   Hosting: smart.home.pagitrpl.my.id
   ============================================================================== */

:root {
  --bg-main: #070a13;
  --bg-card: rgba(18, 24, 43, 0.75);
  --bg-card-hover: rgba(24, 32, 58, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(245, 158, 11, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --amber-primary: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.45);
  --amber-light: #fef08a;

  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);

  --rose: #ef4444;
  --rose-glow: rgba(239, 68, 68, 0.35);

  --sky: #38bdf8;
  --sky-glow: rgba(56, 189, 248, 0.3);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;

  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Dynamic Ambient Glow Backdrop */
.ambient-glow {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -20%);
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, var(--amber-glow) 0%, rgba(245, 158, 11, 0) 70%);
  opacity: 0.15;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  transition: var(--transition-smooth);
}

body.lamp-on .ambient-glow {
  opacity: 0.55;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.6) 0%, rgba(245, 158, 11, 0.25) 45%, rgba(0, 0, 0, 0) 70%);
  transform: translate(-50%, -15%) scale(1.15);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Header & Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(7, 10, 19, 0.75);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
}

.nav-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber-primary);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.status-pill.offline .status-dot {
  background: var(--rose);
  box-shadow: 0 0 8px var(--rose);
}

.status-pill.offline {
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.cloud-pill .status-dot {
  background: var(--sky);
  box-shadow: 0 0 8px var(--sky);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  transform: rotate(45deg);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Dashboard Content */
.dashboard-content {
  flex: 1;
  padding: 30px 0;
}

/* Hero Card */
.hero-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

body.lamp-on .hero-card {
  border-color: var(--border-active);
  box-shadow: 0 20px 50px rgba(245, 158, 11, 0.15);
}

.hero-top-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.room-tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sky);
  animation: pulseSync 2s infinite;
}

@keyframes pulseSync {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.3); }
}

/* Lamp Visualizer */
.lamp-visualizer {
  position: relative;
  margin: 10px auto 26px;
  width: 220px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bulb-wrapper {
  position: relative;
  z-index: 2;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.bulb-svg {
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.bulb-glass {
  fill: #1e293b;
  stroke: #475569;
  stroke-width: 2;
  transition: var(--transition-smooth);
}

.bulb-filament {
  fill: none;
  stroke: #475569;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: var(--transition-smooth);
}

.bulb-base {
  fill: #334155;
  stroke: #1e293b;
  stroke-width: 1.5;
}

.bulb-contact {
  fill: #1e293b;
}

/* Visualizer when Lamp is ON */
body.lamp-on .bulb-wrapper {
  transform: scale(1.05);
}

body.lamp-on .bulb-glass {
  fill: #fef08a;
  stroke: #f59e0b;
  filter: drop-shadow(0 0 35px rgba(245, 158, 11, 0.8));
}

body.lamp-on .bulb-filament {
  stroke: #b45309;
  stroke-width: 3;
}

.lamp-state-badge {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
}

body.lamp-on .lamp-state-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fef08a;
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.35);
}

.hero-meta {
  margin-bottom: 28px;
}

.updated-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.source-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Controls Wrapper */
.controls-wrapper {
  max-width: 440px;
  margin: 0 auto;
}

.primary-power-btn {
  width: 100%;
  height: 64px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.primary-power-btn svg {
  width: 24px;
  height: 24px;
}

.primary-power-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.primary-power-btn:active {
  transform: translateY(1px);
}

body.lamp-on .primary-power-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fde68a;
  color: #000;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.5);
}

body.lamp-on .primary-power-btn:hover {
  box-shadow: 0 12px 35px rgba(245, 158, 11, 0.7);
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.action-btn {
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-on:hover {
  border-color: var(--amber-primary);
  color: var(--amber-light);
}

.btn-off:hover {
  border-color: #64748b;
  color: #e2e8f0;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 16px;
  height: 16px;
}

.cloud-icon { background: rgba(56, 189, 248, 0.15); color: var(--sky); }
.esp-icon   { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.wifi-icon  { background: rgba(245, 158, 11, 0.15); color: var(--amber-primary); }
.timer-icon { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.stat-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Activity Section */
.activity-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.activity-title {
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.activity-title svg {
  width: 16px;
  height: 16px;
  color: var(--sky);
}

.clear-log-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
}

.clear-log-btn:hover {
  color: var(--text-main);
}

.activity-logs {
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-family: var(--font-mono);
}

.log-time {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.log-desc {
  color: var(--text-muted);
}

/* API Docs Section */
.api-doc-card {
  background: rgba(18, 24, 43, 0.4);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.api-doc-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.api-doc-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.api-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  background: rgba(7, 10, 19, 0.6);
  padding: 8px 12px;
  border-radius: 6px;
  overflow-x: auto;
}

.method {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 800;
}

.method.get { background: rgba(56, 189, 248, 0.2); color: var(--sky); }
.method.post { background: rgba(16, 185, 129, 0.2); color: var(--emerald); }

.api-item code {
  font-family: var(--font-mono);
  color: #e2e8f0;
}

.api-desc {
  color: var(--text-dim);
  margin-left: auto;
  font-size: 0.72rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 24px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.footer-sub {
  font-size: 0.72rem;
  margin-top: 4px;
  color: var(--text-dim);
}
