/* ====================================================
   HUE KONTROL — Premium Dark Ambient UI
   Font: Syne (display) + DM Sans (body)
   Mood: Luxury smart home · warm amber · glass depth
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* ====== Tema Değişkenleri ====== */
:root {
  --bg: #080c12;
  --bg-2: #0c1118;
  --panel: rgba(14, 20, 32, 0.85);
  --panel-solid: #0e1420;
  --surface: rgba(18, 26, 42, 0.7);
  --surface-solid: #121a2a;
  --glass: rgba(255, 255, 255, 0.035);
  --glass-border: rgba(255, 255, 255, 0.07);

  --ink: #f0f4fc;
  --ink-2: #c8d4e8;
  --muted: #6b7a94;
  --muted-2: #4a5568;

  /* Brand: amber/gold (ışık teması) */
  --brand: #f59e0b;
  --brand-2: #fb923c;
  --brand-dim: rgba(245, 158, 11, 0.15);
  --brand-glow: rgba(245, 158, 11, 0.25);
  --brand-ring: rgba(245, 158, 11, 0.3);

  /* Aksan: soğuk mavi */
  --accent: #38bdf8;
  --accent-dim: rgba(56, 189, 248, 0.1);

  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

  --ok: #34d399;
  --warn: #f59e0b;
  --err: #f87171;

  /* CT track */
  --ct-cool: #b8d4ff;
  --ct-neutral: #fff9f0;
  --ct-warm: #ffb347;

  /* Dim track */
  --dim-track: rgba(255, 255, 255, 0.08);

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
  --shadow-btn: 0 4px 16px rgba(0,0,0,.3);
  --shadow-brand: 0 4px 20px var(--brand-glow);

  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-input: 12px;

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

:root[data-theme="light"] {
  --bg: #f5f0e8;
  --panel: rgba(255, 252, 246, 0.92);
  --surface: rgba(250, 246, 238, 0.8);
  --glass: rgba(0, 0, 0, 0.02);
  --glass-border: rgba(0, 0, 0, 0.06);
  --ink: #1a1410;
  --ink-2: #4a3f30;
  --muted: #8c7b68;
  --muted-2: #b5a898;
  --brand: #d97706;
  --brand-2: #ea580c;
  --brand-dim: rgba(217, 119, 6, 0.1);
  --brand-glow: rgba(217, 119, 6, 0.2);
  --brand-ring: rgba(217, 119, 6, 0.25);
  --accent: #0284c7;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --ct-cool: #6aacf5;
  --ct-warm: #f97316;
  --dim-track: rgba(0, 0, 0, 0.1);
  --shadow-card: 0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.06);
  --shadow-btn: 0 2px 12px rgba(0,0,0,.1);
  --shadow-brand: 0 4px 16px var(--brand-glow);
}

/* ====== Reset & Base ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80vw 60vh at 15% 10%, rgba(245,158,11,.05) 0%, transparent 60%),
    radial-gradient(ellipse 60vw 50vh at 85% 85%, rgba(56,189,248,.04) 0%, transparent 55%),
    radial-gradient(ellipse 100vw 80vh at 50% 50%, rgba(251,146,60,.02) 0%, transparent 70%);
}
body > * { position: relative; z-index: 1; }

/* ====== Topbar ====== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  position: sticky;
  top: 0;
  z-index: 100;
}
:root[data-theme="light"] .topbar {
  background: rgba(255, 252, 246, 0.88);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.3px;
  min-width: 0;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 12px var(--brand-glow), 0 0 24px var(--brand-glow);
  animation: pulse-dot 3s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 10px var(--brand-glow), 0 0 20px var(--brand-glow); }
  50%       { box-shadow: 0 0 20px var(--brand-glow), 0 0 40px var(--brand-glow); }
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ====== Buttons ====== */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  letter-spacing: -0.1px;
}
.btn:hover {
  background: var(--glass-border);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn);
}
.btn:active { transform: translateY(0); box-shadow: none; }

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #1a0f00;
  font-weight: 700;
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover {
  opacity: 0.9;
  box-shadow: 0 6px 28px var(--brand-glow);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover { color: var(--ink); background: var(--glass); border-color: var(--border); }

.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }

/* ====== Layout ====== */
.container {
  max-width: 1180px;
  margin: 28px auto;
  padding: 0 16px;
  display: grid;
  gap: 24px;
  width: 100%;
}
.rooms {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
@media (max-width: 480px) {
  .container { padding: 0 12px; margin: 16px auto; }
  .rooms { grid-template-columns: 1fr; }
}

/* ====== Cards ====== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--glass-border);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.room-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  word-break: break-word;
}
.room-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card-body { padding: 12px; display: grid; gap: 10px; }

/* ====== Room Controls ====== */
.room-controls {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--glass);
  border-bottom: 1px solid var(--border);
}
.scene-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scene-select {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 9px 12px;
  min-width: 160px;
  max-width: 100%;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.scene-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* ====== Section Title ====== */
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}
.section-title small {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

/* ====== Lights ====== */
.light {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.2s, background 0.2s;
}
.light.on {
  border-color: rgba(245, 158, 11, 0.22);
  background: rgba(245, 158, 11, 0.04);
}
.light-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.light-name { font-weight: 600; font-size: 14px; min-width: 0; word-break: break-word; }

/* ====== Sliders ====== */
.slider-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  align-items: center;
}
.sl-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
}
.sl-val {
  font-size: 12px;
  color: var(--muted);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sl-chip { display: flex; gap: 6px; align-items: center; }
.sl-chip .chip { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); }
.sl-chip .cool { background: var(--ct-cool); }
.sl-chip .warm { background: var(--ct-warm); }

@media (max-width: 560px) { .slider-row { grid-template-columns: 1fr; } }

/* ====== Range inputs ====== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]:focus { outline: none; }

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  background: #fff;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.95);
  box-shadow: 0 2px 10px rgba(0,0,0,.35), 0 0 0 3px var(--brand-ring);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.1);
  box-shadow: 0 3px 14px rgba(0,0,0,.4), 0 0 0 5px var(--brand-ring);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid rgba(255,255,255,.95);
  box-shadow: 0 2px 10px rgba(0,0,0,.35), 0 0 0 3px var(--brand-ring);
  cursor: pointer;
}

.dim-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--dim-track);
  border: 1px solid rgba(255,255,255,.04);
}
.dim-range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--dim-track);
}

.ct-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ct-cool) 0%, var(--ct-neutral) 50%, var(--ct-warm) 100%);
  border: 1px solid rgba(255,255,255,.06);
}
.ct-range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ct-cool) 0%, var(--ct-neutral) 50%, var(--ct-warm) 100%);
}

/* ====== Switch ====== */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: 0 0 auto; }
.switch.big { width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--dim-track);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 999px;
  transition: background 0.22s ease, box-shadow 0.22s ease;
}
.slider::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.switch.big .slider::before { width: 26px; height: 26px; }

.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  box-shadow: 0 0 16px var(--brand-glow), 0 0 0 3px var(--brand-ring);
}
.switch input:checked + .slider::before {
  background: #fff;
  transform: translate(22px, -50%);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.switch.big input:checked + .slider::before { transform: translate(26px, -50%); }

/* ====== Status badge ====== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}
.badge.on {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.2);
}
.badge.off {
  background: var(--glass);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on::before { animation: blink 2s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ====== Logs ====== */
.logs { overflow-x: hidden; }
.logs .section-title { padding: 0 2px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 640px; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
th {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  position: sticky;
  top: 0;
}
td { color: var(--ink-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--glass); }

/* ====== Login Page ====== */
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
body.login::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70vw 60vh at 30% 40%, rgba(245,158,11,.07) 0%, transparent 60%),
    radial-gradient(ellipse 60vw 50vh at 75% 65%, rgba(251,146,60,.05) 0%, transparent 55%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow:
    0 32px 80px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,255,255,.04),
    inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  animation: card-in 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 25px;
  background: linear-gradient(135deg,
    rgba(245,158,11,.14) 0%,
    transparent 40%,
    transparent 60%,
    rgba(251,146,60,.07) 100%);
  pointer-events: none;
  z-index: -1;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--brand-glow), 0 0 48px rgba(245,158,11,.12);
  font-size: 22px;
}
.login-logo .logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.5px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.6px;
  text-align: center;
  margin-bottom: 6px;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.error {
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.25);
  color: #fca5a5;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.error::before { content: '⚠'; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; }
.form label span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.form input[type="text"],
.form input[type="password"],
.form input[name="username"],
.form input[name="password"] {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 13px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.form input::placeholder { color: var(--muted-2); }

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-2);
}

/* ====== Skeleton ====== */
.skeleton-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.skeleton-card {
  height: 220px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: linear-gradient(90deg,
    rgba(255,255,255,.03) 0%,
    rgba(255,255,255,.07) 50%,
    rgba(255,255,255,.03) 100%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ====== Dashboard — Eksik class'lar ====== */

/* body.app için genel sayfa stili (dashboard) */
body.app { background: var(--bg); }

/* Boş durum / bilgi mesajları */
.muted {
  color: var(--muted);
  font-size: 13px;
}
.muted.pad,
.pad {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Yükleniyor göstergesi */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  padding: 24px;
}
.loading.small {
  padding: 14px;
  font-size: 13px;
  gap: 6px;
}
.loading::before,
.loading.small::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.loading.small::before { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* section-title sağ taraf */
.section-title .rhs {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Işık slider grubu */
.light-sliders {
  display: grid;
  gap: 6px;
}

/* Log table wrapper */
.log-table { margin-top: 12px; }

/* Hata mesajı (dashboard içi) */
div.error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #fca5a5;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
div.error::before { content: '⚠'; }