/* =========================
   Livi Frontend UI (modern)
   Light / airy / smart-home
   ========================= */

:root {
  --bg: #f6f9ff;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;

  --primary: #2563eb;
  --primary-weak: rgba(37, 99, 235, 0.12);

  --border: rgba(15, 23, 42, 0.10);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.06);

  --radius: 16px;

  /* statuses */
  --ok: #16a34a;
  --bad: #ef4444;
  --warn: #f59e0b;
  --unknown: #94a3b8;

  --focus: rgba(37, 99, 235, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(37,99,235,0.14), transparent 55%),
              radial-gradient(900px 500px at 90% 0%, rgba(14,165,233,0.12), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.4;
}

main {
  width: min(1200px, calc(100% - 32px));
  margin: 18px auto 42px;
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(246, 249, 255, 0.72);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding: 14px 16px;
}

#searchInput {
  width: min(680px, 100%);
  display: block;
  margin: 0 auto;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  color: var(--text);
  font-size: 15px;
  outline: none;
  box-shadow: 0 0 0 0 transparent;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

#searchInput::placeholder { color: rgba(100,116,139,0.9); }

#searchInput:focus {
  border-color: rgba(37,99,235,0.45);
  box-shadow: 0 0 0 6px var(--focus);
  background: #fff;
}

/* ===== Stale banner ===== */
.stale-banner {
  margin: 14px auto 14px;
  width: min(1200px, 100%);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #7a4b00;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow-soft);
}

.stale-banner::before {
  content: "⚠️";
  font-size: 16px;
}

.hidden { display: none !important; }

/* ===== Grid ===== */
.rooms-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .rooms-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .rooms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  main { width: calc(100% - 20px); }
  .rooms-grid { grid-template-columns: 1fr; }
}

/* ===== Card ===== */
.room-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.86));
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, opacity .15s ease;
}

.room-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.10);
  border-color: rgba(37,99,235,0.18);
}

/* left accent stripe by status */
.room-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--unknown);
  opacity: 0.9;
}

.room-card.online::before  { background: var(--ok); }
.room-card.offline::before { background: var(--bad); }
.room-card.pending::before { background: var(--warn); }
.room-card.unknown::before { background: var(--unknown); }

/* Header */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.room-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* status pill */
.room-status {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(148,163,184,0.12);
  color: rgba(51,65,85,0.95);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.room-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--unknown);
  box-shadow: 0 0 0 3px rgba(148,163,184,0.18);
}

.room-status::after {
  content: "Неизвестно";
}

.room-card.online .room-status {
  background: rgba(22,163,74,0.10);
  border-color: rgba(22,163,74,0.22);
  color: rgba(21,128,61,1);
}
.room-card.online .room-status::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.16);
}
.room-card.online .room-status::after { content: "В сети"; }

.room-card.offline .room-status {
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.22);
  color: rgba(185,28,28,1);
}
.room-card.offline .room-status::before {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.16);
}
.room-card.offline .room-status::after { content: "Оффлайн"; }

.room-card.pending .room-status {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.28);
  color: rgba(146,64,14,1);
}
.room-card.pending .room-status::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.18);
}
.room-card.pending .room-status::after { content: "Отправлено"; }

/* ===== Target temperature ===== */
.target-temp {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 10px;
  margin: 10px 0 10px;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(37,99,235,0.06);
  border: 1px solid rgba(37,99,235,0.14);
}

.target-temp span {
  text-align: center;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.7px;
  color: var(--text);
}

/* buttons */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255,255,255,0.92);
  color: var(--text);
  border-radius: 12px;
  height: 38px;
  padding: 0 12px;
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
  box-shadow: 0 8px 18px rgba(15,23,42,0.06);
}

.target-temp button {
  width: 40px;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(37,99,235,0.10);
}

button:hover {
  border-color: rgba(37,99,235,0.25);
  box-shadow: 0 12px 26px rgba(15,23,42,0.10);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 6px var(--focus);
}

/* disabled */
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

/* ===== Quick modes ===== */
.quick-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 10px;
}

.quick-modes button {
  height: 38px;
  border-radius: 12px;
  font-weight: 650;
}

.quick-modes button[data-temp="15"] {
  background: rgba(14,165,233,0.10);
  border-color: rgba(14,165,233,0.22);
}

.quick-modes button[data-temp="22"] {
  background: rgba(37,99,235,0.10);
  border-color: rgba(37,99,235,0.22);
}

/* ===== Info block ===== */
.room-info {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.room-info > div:first-child {
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -0.3px;
}

.room-info > div:last-child {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* ===== Offline look ===== */
.room-card.offline {
  opacity: 0.92;
}
.room-card.offline .target-temp,
.room-card.offline .quick-modes button {
  filter: grayscale(0.2);
}

/* ===== Pending animation (subtle shimmer) ===== */
.room-card.pending {
  position: relative;
}

.room-card.pending::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255,255,255,0.55) 45%,
    transparent 70%
  );
  transform: translateX(-110%);
  animation: shimmer 1.2s infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(110%); }
}


/* ===== Environment block (В помещении) ===== */
.room-env {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.room-env__title {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.2px;
  margin-bottom: 8px;
}

.room-env__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.env-item {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 8px 18px rgba(15,23,42,0.04);
}

.env-item__label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 4px;
}

.env-item__value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.env-item__unit {
  font-size: 12px;
  font-weight: 750;
  color: rgba(100,116,139,0.95);
}


/* ===== Active mode button ===== */
.quick-modes .is-active {
  border-color: rgba(37,99,235,0.45);
  box-shadow: 0 0 0 6px rgba(37,99,235,0.18);
  background: rgba(37,99,235,0.14);
}

/* ===== Updated line ===== */
.room-env__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.room-updated {
  font-size: 12px;
  color: rgba(100,116,139,0.95);
  font-weight: 600;
}

/* ===== Smooth value update animation ===== */
.js-anim-flash {
  animation: valueFlash 280ms ease;
}

@keyframes valueFlash {
  0%   { transform: translateY(-1px); opacity: 0.75; }
  100% { transform: translateY(0); opacity: 1; }
}
