/* ============================================================
   Room Reminder — Stylesheet (mobile-first PWA)
   ============================================================ */

:root {
  --primary:      #1e3a5f;
  --primary-lt:   #2d5a9e;
  --accent:       #2563eb;
  --bg:           #f0f4f8;
  --card:         #ffffff;
  --text:         #1a202c;
  --muted:        #6b7280;
  --border:       #e5e7eb;
  --header-h:     52px;
  --nav-h:        62px;

  /* Status colours */
  --vr: #16a34a;
  --vd: #d97706;
  --vc: #0891b2;
  --od: #dc2626;
  --or: #ea580c;
  --oc: #7c3aed;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* ── Login ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
  padding: 20px;
}
.login-container {
  background: white;
  border-radius: 18px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 48px rgba(0,0,0,.22);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 52px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; color: var(--primary); font-weight: 800; }
.login-logo p  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  color: white;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
}
.app-name { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.sync-time { font-size: 11px; color: rgba(255,255,255,.65); }
.logout-btn {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}
.logout-btn:hover { color: white; background: rgba(255,255,255,.12); }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  min-height: calc(100vh - var(--header-h) - var(--nav-h));
  padding: 14px 14px 6px;
}

/* ── Bottom nav ───────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.07);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  gap: 2px;
  position: relative;
  transition: color .15s;
}
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 22px; }
.nav-badge {
  position: absolute; top: 7px; right: calc(50% - 20px);
  background: #ef4444; color: white;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Checkbox group */
.checkbox-group { display: flex; gap: 8px; flex-wrap: wrap; }
.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 13px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  transition: all .15s;
  user-select: none;
}
.checkbox-label:hover { border-color: var(--accent); background: #eff6ff; }
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }

/* Checked state per condition */
.checkbox-label.cb-vr:has(input:checked) { border-color: var(--vr); background: #dcfce7; color: var(--vr); font-weight: 700; }
.checkbox-label.cb-vd:has(input:checked) { border-color: var(--vd); background: #fef3c7; color: var(--vd); font-weight: 700; }
.checkbox-label.cb-vc:has(input:checked) { border-color: var(--vc); background: #cffafe; color: var(--vc); font-weight: 700; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 18px;
  border-radius: 8px; border: none;
  font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all .15s; white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-danger    { background: #fee2e2; color: #dc2626; }
.btn-danger:hover  { background: #fecaca; }
.btn-success   { background: #d1fae5; color: #059669; }
.btn-success:hover { background: #a7f3d0; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm    { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 7px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
}
.badge-vr      { background: #dcfce7; color: var(--vr); }
.badge-vd      { background: #fef3c7; color: var(--vd); }
.badge-vc      { background: #cffafe; color: var(--vc); }
.badge-od      { background: #fee2e2; color: var(--od); }
.badge-or      { background: #ffedd5; color: var(--or); }
.badge-oc      { background: #ede9fe; color: var(--oc); }
.badge-default { background: #f3f4f6; color: var(--muted); }

/* ── Stats row ────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card {
  background: white;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  cursor: pointer;
  border-top: 3px solid var(--sc, var(--border));
  transition: transform .1s;
}
.stat-card:active { transform: scale(.97); }
.stat-vr { --sc: var(--vr); }
.stat-vd { --sc: var(--vd); }
.stat-vc { --sc: var(--vc); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 500; }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 6px;
  overflow-x: auto; padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 12px; font-weight: 600;
  cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.filter-btn.active,
.filter-btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

/* ── Room grid ────────────────────────────────────────────── */
.section-label {
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 10px 0 6px;
}
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.room-card {
  background: white;
  border-radius: 10px;
  padding: 10px 8px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-left: 4px solid var(--rc, var(--border));
  cursor: pointer;
  position: relative;
  transition: transform .1s, box-shadow .1s;
}
.room-card:active { transform: scale(.96); }
.rc-vr { --rc: var(--vr); }
.rc-vd { --rc: var(--vd); }
.rc-vc { --rc: var(--vc); }
.rc-od { --rc: var(--od); }
.rc-or { --rc: var(--or); }
.rc-oc { --rc: var(--oc); }
.room-watch-dot {
  position: absolute; top: 5px; right: 5px;
  font-size: 11px;
}
.room-number { font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1; }
.room-type   { font-size: 10px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-status-badge { margin-top: 5px; }
.room-info   { font-size: 9px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Section header ───────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 700; color: var(--primary); }

/* ── Collapsible form ─────────────────────────────────────── */
.collapsible-form {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: none;
}
.collapsible-form.open { display: block; }

/* ── Reminder / Scenario items ────────────────────────────── */
.reminder-item {
  background: white;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border-left: 4px solid var(--ic, var(--accent));
}
.reminder-item.status-active    { --ic: var(--accent); }
.reminder-item.status-triggered { --ic: #9ca3af; opacity: .75; }

.reminder-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 6px;
}
.reminder-title { font-size: 15px; font-weight: 700; color: var(--primary); }
.reminder-meta  { font-size: 11px; color: var(--muted); margin-top: 3px; }
.reminder-conditions { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.reminder-actions { display: flex; gap: 6px; margin-top: 10px; }

/* Scenario room list */
.scenario-rooms-list { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.scenario-room-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  background: #f8fafc; border-radius: 8px; font-size: 13px;
}
.scenario-room-num { font-weight: 700; color: var(--primary); }

/* ── Scenario builder ─────────────────────────────────────── */
.room-builder-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 10px;
}
.room-builder-item {
  display: flex; align-items: center; justify-content: space-between;
  background: white; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.remove-room-btn {
  background: none; border: none; color: #ef4444;
  cursor: pointer; font-size: 16px; padding: 2px 4px;
  border-radius: 4px; line-height: 1;
}
.add-room-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 8px; align-items: end;
}
.add-room-row .form-group { margin-bottom: 0; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; margin-bottom: 14px; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 10px);
  left: 50%; transform: translateX(-50%) translateY(16px);
  background: #1a202c; color: white;
  padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 500;
  z-index: 200; opacity: 0;
  transition: all .22s ease; white-space: nowrap;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Details / summary ────────────────────────────────────── */
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* ── Responsive tweaks ────────────────────────────────────── */
@media (min-width: 480px) {
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .stats-row { gap: 12px; }
}
@media (min-width: 768px) {
  .main-content { max-width: 720px; margin-left: auto; margin-right: auto; }
}
