/* ═══════════════════════════════════════════════════════════════
   WaterStation Configurator — Shared Design System
   Matches the WaterStation HMI dark theme
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:      #0d1117;
  --surf:    #161b22;
  --surf2:   #21262d;
  --surf3:   #2d333b;
  --border:  #30363d;
  --text:    #e6edf3;
  --text2:   #c9d1d9;
  --muted:   #8b949e;
  --green:   #3fb950;
  --red:     #f85149;
  --yellow:  #d29922;
  --blue:    #58a6ff;
  --brand:   #1f6feb;
  --teal:    #2dd4bf;
  --orange:  #fb923c;
  --purple:  #bc8cff;
  --cyan:    #39d3f4;

  --radius:  8px;
  --radius-sm: 5px;
  --shadow:  0 4px 24px rgba(0,0,0,0.5);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surf); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── TOPBAR ────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.topbar-logo svg { flex-shrink: 0; }
.topbar-logo .brand {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.topbar-logo .sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text2);
}
.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

/* ── BUTTONS ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary  { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover:not(:disabled)  { background: #2879f5; }
.btn-ghost    { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--surf2); color: var(--text); }
.btn-danger   { background: transparent; color: var(--red); border-color: rgba(248,81,73,0.4); }
.btn-danger:hover:not(:disabled)   { background: rgba(248,81,73,0.1); }
.btn-success  { background: transparent; color: var(--green); border-color: rgba(63,185,80,0.4); }
.btn-success:hover:not(:disabled)  { background: rgba(63,185,80,0.1); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 6px; }

/* ── FORM ELEMENTS ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text2); }
.input, .select, .textarea {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.input::placeholder { color: var(--muted); }
.textarea { resize: vertical; min-height: 80px; }
.select { cursor: pointer; appearance: none; }
.field-error { font-size: 11px; color: var(--red); margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────────────── */
.card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-sm { padding: 14px; }
.card-hover { transition: border-color 0.12s, box-shadow 0.12s; cursor: pointer; }
.card-hover:hover { border-color: var(--blue); box-shadow: 0 0 0 1px var(--brand); }

/* ── STATUS BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-draft    { color: var(--muted);   background: var(--surf3);               border: 1px solid var(--border); }
.badge-submitted{ color: var(--blue);    background: rgba(88,166,255,0.12);      border: 1px solid rgba(88,166,255,0.3); }
.badge-quoted   { color: var(--yellow);  background: rgba(210,153,34,0.12);      border: 1px solid rgba(210,153,34,0.3); }
.badge-approved { color: var(--green);   background: rgba(63,185,80,0.12);       border: 1px solid rgba(63,185,80,0.3); }
.badge-deployed { color: var(--teal);    background: rgba(45,212,191,0.12);      border: 1px solid rgba(45,212,191,0.3); }

/* ── DIVIDER ───────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ── TOAST NOTIFICATIONS ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 240px;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  pointer-events: auto;
}
.toast.ok   { border-left: 3px solid var(--green); }
.toast.err  { border-left: 3px solid var(--red); }
.toast.warn { border-left: 3px solid var(--yellow); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── LOADING SPINNER ───────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ───────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--muted);
  text-align: center;
}
.empty-icon { font-size: 40px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text2); }
.empty-sub   { font-size: 13px; max-width: 280px; }

/* ── UTILITY ───────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.mt-8    { margin-top: 8px; }
.mt-16   { margin-top: 16px; }
.text-muted   { color: var(--muted); }
.text-sm      { font-size: 12px; }
.text-right   { text-align: right; }
.font-bold    { font-weight: 700; }

/* ── REV BAR ───────────────────────────────────────────────────── */
#rev-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  background: rgba(13,17,23,0.92);
  border-top: 1px solid var(--border);
  padding: 4px 16px;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  letter-spacing: .06em; pointer-events: none;
  backdrop-filter: blur(6px);
}
