/* ============================================================
   theme.css  —  Indoor RTLS Design System
   Dark / Light mode via [data-theme="dark"] on <html>
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Light (default) ── */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --bg:          #f0f4f8;
  --bg-card:     #ffffff;
  --bg-card2:    #f8fafc;
  --bg-input:    #f1f5f9;
  --bg-overlay:  rgba(255,255,255,0.85);

  --border:      #e2e8f0;
  --border-focus:#22c55e;

  --text:        #0f172a;
  --text-sub:    #64748b;
  --text-muted:  #94a3b8;

  --accent:      #22c55e;
  --accent2:     #16a34a;
  --accent-glow: rgba(34,197,94,0.18);

  --blue:        #3b82f6;
  --blue2:       #1d4ed8;
  --blue-glow:   rgba(59,130,246,0.15);

  --red:         #ef4444;
  --red-glow:    rgba(239,68,68,0.12);

  --orange:      #f97316;
  --purple:      #a855f7;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:      0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.05);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.12);

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   20px;
  --radius-pill: 999px;

  --topbar-h:    60px;
  --panel-w:     300px;
}

/* ── Dark ── */
[data-theme="dark"] {
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-card2:    #162032;
  --bg-input:    #0f172a;
  --bg-overlay:  rgba(30,41,59,0.92);

  --border:      rgba(148,163,184,0.12);
  --border-focus:#22c55e;

  --text:        #f1f5f9;
  --text-sub:    #94a3b8;
  --text-muted:  #475569;

  --accent:      #22c55e;
  --accent2:     #16a34a;
  --accent-glow: rgba(34,197,94,0.22);

  --blue:        #60a5fa;
  --blue2:       #3b82f6;
  --blue-glow:   rgba(96,165,250,0.15);

  --red:         #f87171;
  --red-glow:    rgba(248,113,113,0.12);

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow:      0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.5);
}

/* ── Base Reset ── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-family: var(--font); color-scheme: light dark; }
body { font-family: var(--font); background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }

/* ── Theme Toggle Button ── */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-sub); cursor: pointer; font-size: 18px;
  transition: all 0.2s; box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(20deg); }

/* ── Cards ── */
.t-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; transition: box-shadow 0.2s, border-color 0.2s;
}
.t-card:hover { box-shadow: var(--shadow-lg); }
.t-card-hd {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; justify-content: space-between; align-items: center;
}
.t-card-bd { padding: 14px 16px; display: grid; gap: 10px; }

/* ── Buttons ── */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.18s; white-space: nowrap; text-decoration: none;
}
.t-btn:hover { border-color: var(--text-sub); box-shadow: var(--shadow-sm); }
.t-btn:active { transform: translateY(1px); }
.t-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: var(--accent2); color: #fff; }
.t-btn.primary:hover { filter: brightness(1.08); box-shadow: 0 4px 14px var(--accent-glow); }
.t-btn.blue { background: linear-gradient(135deg, var(--blue), var(--blue2)); border-color: var(--blue2); color: #fff; }
.t-btn.blue:hover { filter: brightness(1.1); box-shadow: 0 4px 14px var(--blue-glow); }
.t-btn.danger { background: var(--bg-card); border-color: var(--red); color: var(--red); }
.t-btn.danger:hover { background: var(--red-glow); }
.t-btn.ghost { border-color: transparent; background: transparent; color: var(--text-sub); }
.t-btn.ghost:hover { background: var(--bg-card2); color: var(--text); }
.t-btn.sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 6px; }
.t-btn.full { width: 100%; }

/* ── Inputs ── */
.t-input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: var(--font); outline: none; transition: all 0.2s;
}
.t-input::placeholder { color: var(--text-muted); }
.t-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.t-select { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* ── Chips / Pills ── */
.t-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-card2);
  font-size: 11px; font-weight: 600; color: var(--text-sub);
}
.t-pill.ok { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }
.t-pill.bad { background: var(--red-glow); border-color: var(--red); color: var(--red); }
.t-pill.blue { background: var(--blue-glow); border-color: var(--blue); color: var(--blue); }

.t-chip {
  padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-card2);
  font-size: 12px; font-weight: 600; color: var(--text-sub);
  cursor: pointer; transition: all 0.18s;
}
.t-chip:hover { border-color: var(--accent); color: var(--accent); }
.t-chip.active { background: var(--accent); border-color: var(--accent2); color: #fff; }

/* ── Row layout ── */
.t-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.t-col { display: flex; flex-direction: column; gap: 4px; }
.t-label { font-size: 11px; font-weight: 600; color: var(--text-sub); }

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

/* ── Status indicator dot ── */
.t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.t-dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: dot-pulse 2s ease infinite; }
@keyframes dot-pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* ── Toast notification ── */
.t-toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  padding: 10px 20px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 600;
  z-index: 9999; box-shadow: var(--shadow-lg); pointer-events: none;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(-10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Theme toggle persistence script helper ── */
