/* ── Proměnné ─────────────────────────────────────────────────────────────── */
:root {
  --bg:            #f0f4f8;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --primary:       #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --success:       #16a34a;
  --success-bg:    #f0fdf4;
  --danger:        #dc2626;
  --danger-bg:     #fef2f2;
  --warning:       #d97706;
  --warning-bg:    #fffbeb;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --radius:        12px;
  --radius-sm:     8px;
  --sidebar-w:     240px;
  --header-h:      60px;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Typografie ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

/* ── Tlačítka ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-lg { padding: 12px 32px; font-size: 1rem; }

/* ── Karta ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ── Toggle (přepínač) ────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Logo SVG ─────────────────────────────────────────────────────────────── */
.logo-img {
  display: block;
  /* Přebarvení na bílou přes CSS filter – funguje pro libovolné SVG */
  filter: brightness(0) invert(1);
}
.login-logo .logo-icon .logo-img  { width: 32px; height: 32px; }
.header-logo .logo-icon .logo-img { width: 20px; height: 20px; }

/* ══════════════════════════════════════════════════════════════════════════ */
/*  LOGIN                                                                     */
/* ══════════════════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0eaff 0%, #f0f4f8 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 16px;
  margin-bottom: 12px;
  font-size: 28px;
}
.login-logo h1 { font-size: 1.4rem; color: var(--text); }
.login-logo p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.login-btn {
  width: 100%;
  padding: 11px;
  margin-top: 8px;
  font-size: 0.95rem;
  justify-content: center;
}

.login-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: none;
}

/* ══════════════════════════════════════════════════════════════════════════ */
/*  APP LAYOUT                                                                */
/* ══════════════════════════════════════════════════════════════════════════ */
.app-layout {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main";
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.header-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.app-sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 8px;
  margin-bottom: 8px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  transition: background .12s;
  user-select: none;
}
.room-item:hover   { background: var(--bg); }
.room-item.active  { background: var(--primary-light); color: var(--primary); }

.room-item .room-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}
.room-item.active .room-dot,
.room-item.online .room-dot  { background: var(--success); }
.room-item.offline .room-dot { background: #94a3b8; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.app-main {
  grid-area: main;
  padding: 28px;
  overflow-y: auto;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 12px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; opacity: .4; }

/* ══════════════════════════════════════════════════════════════════════════ */
/*  ROOM DASHBOARD                                                            */
/* ══════════════════════════════════════════════════════════════════════════ */
.room-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.offline-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #fcd34d;
}

/* ── Statusové karty ──────────────────────────────────────────────────────── */
.status-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.temp-display {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -.02em;
}

.last-seen {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Badge stavu relé */
.relay-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: .04em;
  align-self: flex-start;
}
.relay-badge::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  display: block;
}
.relay-badge.on {
  background: var(--success-bg);
  color: var(--success);
}
.relay-badge.on::before { background: var(--success); animation: pulse 2s infinite; }

.relay-badge.off {
  background: #f1f5f9;
  color: var(--text-muted);
}
.relay-badge.off::before { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── Karty s nastavením ───────────────────────────────────────────────────── */
.settings-card { margin-bottom: 20px; }

/* Přepínač režimů */
.mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}

.mode-tab {
  padding: 7px 18px;
  border: none;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.mode-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.mode-tab:hover:not(.active) { color: var(--text); }

.mode-content { display: none; }
.mode-content.active { display: block; }

/* ── Rozvrh ───────────────────────────────────────────────────────────────── */
.schedule-table { width: 100%; border-collapse: collapse; }
.schedule-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 0 12px 10px;
}
.schedule-table td {
  padding: 8px 12px;
  vertical-align: middle;
  border-top: 1px solid var(--border);
}
.schedule-table tr:first-child td { border-top: none; }

.day-name { font-weight: 600; min-width: 90px; }

.time-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  width: 120px;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.time-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.time-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }

.schedule-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; }
.save-status { font-size: 0.85rem; color: var(--success); display: none; }

/* ── Cílová teplota ───────────────────────────────────────────────────────── */
.target-control {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
.target-display {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.target-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: var(--shadow);
  transition: transform .1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }

.target-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Manuální ovládání ────────────────────────────────────────────────────── */
.manual-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.manual-controls .btn {
  min-width: 140px;
  justify-content: center;
  opacity: .6;
}
.manual-controls .btn.active { opacity: 1; box-shadow: 0 0 0 3px rgba(0,0,0,.12); }

/* ── Graf ─────────────────────────────────────────────────────────────────── */
.chart-card { margin-bottom: 0; }

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.chart-header h2 { font-size: 1rem; }

.period-btns { display: flex; gap: 4px; }
.period-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.period-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chart-container { position: relative; height: 220px; }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: var(--text-muted);
  font-size: 0.875rem;
  display: none;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.mt-4  { margin-top: 16px; }
.flex  { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
