/* ============ Tasarım sistemi ============ */
:root {
  --bg: hsl(228 40% 7%);
  --surface: hsl(228 30% 12% / 0.65);
  --surface-solid: hsl(228 30% 12%);
  --border: hsl(228 30% 100% / 0.08);
  --border-strong: hsl(228 30% 100% / 0.16);
  --text: hsl(220 30% 96%);
  --text-dim: hsl(222 14% 64%);
  --ok: hsl(150 80% 52%);
  --warn: hsl(40 100% 58%);
  --bad: hsl(355 90% 62%);
  --off: hsl(222 12% 46%);
  --info: hsl(262 90% 74%);
  --radius: 22px;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { color-scheme: dark; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}
.bg-glow--a { top: -25vmax; left: -15vmax; background: hsl(255 90% 60%); animation: drift 22s ease-in-out infinite alternate; }
.bg-glow--b { bottom: -28vmax; right: -18vmax; background: hsl(190 95% 50%); animation: drift 28s ease-in-out infinite alternate-reverse; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, 4vmax) scale(1.12); }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============ Üst çubuk ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}

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

.brand__logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, hsl(255 85% 62%), hsl(190 95% 50%));
  box-shadow: 0 8px 28px hsl(230 90% 60% / 0.4);
}
.brand__logo svg { width: 26px; height: 26px; }

.brand__title { font-size: clamp(1.25rem, 2.6vw, 1.7rem); font-weight: 700; letter-spacing: -0.01em; }
.brand__subtitle { color: var(--text-dim); font-size: 0.9rem; font-weight: 300; }

.badges { display: flex; gap: 12px; flex-wrap: wrap; }

.badge {
  --c: var(--off);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.4s, box-shadow 0.4s;
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 14%, transparent);
}
.badge--on  { --c: var(--ok); }
.badge--off { --c: var(--bad); }
.badge--wait { --c: var(--warn); }

.badge__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
  transition: background 0.4s;
}
.badge--on .badge__dot { animation: pulse 2s ease-out infinite; }
.badge--wait .badge__dot { animation: blink 1s ease-in-out infinite; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 70%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}
@keyframes blink { 50% { opacity: 0.25; } }

.badge__text { display: flex; flex-direction: column; line-height: 1.15; }
.badge__text small { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); }
.badge__text strong { font-size: 0.95rem; font-weight: 600; color: var(--c); }

/* ============ Bölümler ============ */
.section-title {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
}

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ============ Sensör kartı ============ */
.card {
  --accent: white;
  --level: var(--ok);
  position: relative;
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s, box-shadow 0.3s, opacity 0.4s, filter 0.4s;
  animation: rise 0.6s ease both;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 16%, transparent);
}
.card.is-stale { opacity: 0.55; filter: grayscale(0.55); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.card__head { width: 100%; display: flex; align-items: center; gap: 10px; position: relative; }
.card__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.card__icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card__label { font-size: 1rem; font-weight: 500; }

.gauge { position: relative; width: 190px; height: 190px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(135deg); overflow: visible; }
.gauge circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.gauge__track { stroke: hsl(228 30% 100% / 0.08); }
.gauge__value {
  stroke: var(--accent);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 65%, transparent));
  transition: stroke-dasharray 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge__number { font-size: 2.7rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.gauge__unit { margin-top: 4px; font-size: 1rem; color: var(--text-dim); font-weight: 300; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--level);
  background: color-mix(in srgb, var(--level) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--level) 38%, transparent);
  transition: color 0.4s, background 0.4s, border-color 0.4s;
  position: relative;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.chip[data-level="ok"]   { --level: var(--ok); }
.chip[data-level="warn"] { --level: var(--warn); }
.chip[data-level="bad"]  { --level: var(--bad); }
.chip[data-level="none"] { --level: var(--off); }
.chip[data-level="info"] { --level: var(--info); }

.card__range { display: flex; justify-content: space-between; width: 100%; font-size: 0.75rem; color: var(--text-dim); position: relative; }

.footer { text-align: center; color: var(--text-dim); font-size: 0.82rem; font-weight: 300; }

/* ============ Akıllı perde kartı ============ */
.card--wide { align-items: stretch; }
.card--wide .card__head { gap: 12px; }
.card--wide .card__label { flex: 1; }

.curtain__body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) 1.3fr;
  gap: 26px;
  align-items: center;
}
.curtain__visual { display: grid; place-items: center; }
.curtain__window { width: 100%; max-width: 260px; filter: drop-shadow(0 12px 28px hsl(262 80% 30% / 0.45)); }

.curtain__panel {
  transform-box: fill-box;
  transition: transform 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}
.curtain__panel--left  { transform-origin: left center; }
.curtain__panel--right { transform-origin: right center; }
.curtain__window[data-state="close"] .curtain__panel,
.curtain__window[data-state="unknown"] .curtain__panel { transform: scaleX(1); }
.curtain__window[data-state="open"] .curtain__panel { transform: scaleX(0.16); }
.curtain__sun { opacity: 0.9; animation: sun 5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.curtain__window[data-state="unknown"] .curtain__panel { opacity: 0.55; }
@keyframes sun { to { transform: scale(1.12); opacity: 1; } }

.curtain__controls { display: flex; flex-direction: column; gap: 18px; }

.mode { display: flex; align-items: center; gap: 12px; }
.mode__label { font-size: 0.95rem; color: var(--text-dim); transition: color 0.3s; }
.mode__label.is-active { color: var(--text); font-weight: 600; }

.switch { position: relative; display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  display: block;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: hsl(228 30% 100% / 0.12);
  border: 1px solid var(--border-strong);
  transition: background 0.3s, border-color 0.3s;
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.switch input:checked + .switch__track { background: linear-gradient(135deg, hsl(262 85% 62%), hsl(222 90% 62%)); border-color: transparent; }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(24px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--info); outline-offset: 3px; }
.switch input:disabled { cursor: not-allowed; }

.auto-settings { display: flex; flex-direction: column; gap: 10px; transition: opacity 0.3s, filter 0.3s; }
.auto-settings.is-inactive, .manual-buttons.is-inactive { opacity: 0.45; }
.auto-settings__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.92rem; }
.auto-settings__value { font-size: 1.35rem; font-weight: 600; color: var(--info); font-variant-numeric: tabular-nums; }
.auto-settings__scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-dim); }

input[type="range"] {
  --pct: 55%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg, var(--info) var(--pct), hsl(228 30% 100% / 0.12) var(--pct));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--info);
  box-shadow: 0 2px 10px hsl(262 90% 40% / 0.5);
  transition: transform 0.2s;
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: white; border: 4px solid var(--info); }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible { outline: 2px solid var(--info); outline-offset: 4px; }
input[type="range"]:disabled { cursor: not-allowed; }

.manual-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; transition: opacity 0.3s; }
.btn {
  font: inherit;
  font-weight: 500;
  padding: 13px 16px;
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  background: hsl(228 30% 100% / 0.07);
  border: 1px solid var(--border-strong);
  transition: transform 0.2s, background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); background: hsl(262 80% 65% / 0.22); border-color: hsl(262 80% 72% / 0.7); box-shadow: 0 8px 22px hsl(262 80% 50% / 0.25); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--info); outline-offset: 3px; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn.is-current { border-color: color-mix(in srgb, var(--info) 70%, transparent); background: color-mix(in srgb, var(--info) 18%, transparent); }
.manual-buttons.is-inactive .btn:hover:not(:disabled) { background: hsl(228 30% 100% / 0.12); box-shadow: none; transform: none; }

.curtain__hint { min-height: 1.2em; font-size: 0.8rem; color: var(--text-dim); }

main { display: flex; flex-direction: column; gap: 28px; }

@media (min-width: 760px) {
  .card--wide { grid-column: span 2; }
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .curtain__body { grid-template-columns: 1fr; gap: 18px; }
  .curtain__window { max-width: 220px; }
  .app { padding: 20px 14px 32px; gap: 22px; }
  .badges { width: 100%; }
  .badge { flex: 1; }
  .gauge { width: 170px; height: 170px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============ Bildirim butonu ============ */
.btn-notify {
  --c: hsl(262 90% 72%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--c);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.2s, color 0.3s;
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 14%, transparent);
  white-space: nowrap;
}
.btn-notify svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  transition: transform 0.3s;
}
.btn-notify:hover:not(:disabled) {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--c) 28%, transparent);
}
.btn-notify:active:not(:disabled) { transform: translateY(0); }
.btn-notify:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }
.btn-notify:disabled { opacity: 0.6; cursor: not-allowed; }

/* Aktif (abone) durumu */
.btn-notify--active {
  --c: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}
.btn-notify--active svg { animation: bell-shake 3s ease-in-out infinite; }

/* İzin reddedildi / desteklenmiyor */
.btn-notify--denied,
.btn-notify--unsupported { --c: var(--off); }

/* Hata durumu */
.btn-notify--error { --c: var(--bad); }

@keyframes bell-shake {
  0%, 85%, 100% { transform: rotate(0deg); }
  88%           { transform: rotate(-12deg); }
  92%           { transform: rotate(12deg); }
  96%           { transform: rotate(-8deg); }
}

/* ============ Evde Yokum kartı ============ */
.away-card {
  --accent: hsl(222 14% 46%);
  transition: transform 0.3s ease, border-color 0.5s, box-shadow 0.5s, opacity 0.4s, filter 0.4s;
}
.away--active {
  --accent: hsl(355 90% 62%);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent) !important;
  box-shadow: 0 0 48px color-mix(in srgb, var(--accent) 22%, transparent) !important;
}

.away__body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
}

/* ---- Kalkan görseli ---- */
.away__visual-wrap { display: grid; place-items: center; }

.away__shield-wrap {
  position: relative;
  width: 120px;
  height: 136px;
  display: grid;
  place-items: center;
}

.away__shield-svg { width: 100%; height: 100%; overflow: visible; }

.away__shield-path {
  fill: color-mix(in srgb, var(--off) 18%, transparent);
  stroke: var(--off);
  stroke-width: 2;
  transition: fill 0.5s, stroke 0.5s, filter 0.5s;
  filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--off) 20%, transparent));
}
.away--active .away__shield-path {
  fill: color-mix(in srgb, var(--bad) 22%, transparent);
  stroke: var(--bad);
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--bad) 55%, transparent));
}

.away__icon-layer { transition: opacity 0.4s; }

/* ---- Pulsing rings ---- */
.away__rings {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.away__ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--bad);
  opacity: 0;
  pointer-events: none;
}
.away__ring--1 { width: 86px;  height: 86px; }
.away__ring--2 { width: 112px; height: 112px; }
.away__ring--3 { width: 138px; height: 138px; }

.away--active .away__ring--1 { animation: away-ring 2.2s 0s    ease-out infinite; }
.away--active .away__ring--2 { animation: away-ring 2.2s 0.5s  ease-out infinite; }
.away--active .away__ring--3 { animation: away-ring 2.2s 1.0s  ease-out infinite; }

@keyframes away-ring {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ---- Kontroller ---- */
.away__controls { display: flex; flex-direction: column; gap: 16px; }

.away__desc {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.65;
  transition: color 0.4s;
}
.away--active .away__desc { color: var(--text); }

.away__toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 16px;
  background: hsl(228 30% 100% / 0.05);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}
.away--active .away__toggle-row {
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}
.away__toggle-row:hover { background: hsl(228 30% 100% / 0.09); }
.away--active .away__toggle-row:hover { background: color-mix(in srgb, var(--bad) 15%, transparent); }

.away__toggle-text {
  font-size: 1rem;
  font-weight: 600;
  transition: color 0.3s;
}
.away--active .away__toggle-text { color: var(--bad); }

/* ---- Büyük toggle switch ---- */
.away__switch { position: relative; display: inline-block; flex-shrink: 0; }
.away__switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.away__track {
  display: block;
  width: 66px;
  height: 34px;
  border-radius: 999px;
  background: hsl(228 30% 100% / 0.12);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.3s, border-color 0.3s;
}
.away__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.away__switch input:checked + .away__track {
  background: linear-gradient(135deg, hsl(355 90% 55%), hsl(15 95% 55%));
  border-color: transparent;
}
.away__switch input:checked + .away__track .away__thumb { transform: translateX(32px); }
.away__switch input:focus-visible + .away__track { outline: 2px solid var(--bad); outline-offset: 3px; }
.away__switch input:disabled { cursor: not-allowed; }

.away__hint {
  min-height: 1.2em;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .away__body { grid-template-columns: 1fr; gap: 20px; }
  .away__visual-wrap { order: -1; }
  .away__shield-wrap { width: 100px; height: 114px; }
}
