/* app.css — Spool Panel — Industrial Dark Theme */

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

:root {
  --bg: #0d0f11;
  --bg-2: #141618;
  --bg-3: #1c1f22;
  --bg-4: #242729;
  --border: #2a2d31;
  --border-2: #363a3f;
  --text: #e8eaed;
  --text-2: #9aa3ad;
  --text-3: #5c6370;
  --accent: #f97316;
  --accent-dim: rgba(249,115,22,0.15);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234,179,8,0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'DM Sans', sans-serif;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; }

a { color: inherit; text-decoration: none; }

/* ── Layout ─────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.logo-mark { flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

.main { margin-left: var(--sidebar-w); flex: 1; padding: 28px; min-height: 100vh; }

/* ── Page Header ─────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 600; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 10px; }

/* ── Stat Grid ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; font-family: var(--font-mono); color: var(--text); line-height: 1; }
.stat-unit { font-size: 12px; color: var(--text-2); font-weight: 400; }

/* ── Grid layouts ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 750px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
tbody td { padding: 11px 14px; color: var(--text); vertical-align: middle; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: all var(--transition);
  line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ea6a0a; }
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--bg-4); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: none; color: var(--text-2); padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-3); }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gray { background: var(--bg-3); color: var(--text-2); }
.badge-orange { background: var(--accent-dim); color: var(--accent); }

/* ── Color dot ───────────────────────────────────────── */
.color-dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 0 1px var(--border);
}

/* ── Progress bar ────────────────────────────────────── */
.progress-bar { height: 5px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.progress-good { background: var(--green); }
.progress-warn { background: var(--yellow); }
.progress-low { background: var(--red); }

/* ── Spool card ──────────────────────────────────────── */
.spool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.spool-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  transition: border-color var(--transition);
  cursor: pointer;
}
.spool-card:hover { border-color: var(--border-2); }
.spool-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.spool-color-ring {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  position: relative;
}
.spool-color-ring::after {
  content: ''; position: absolute;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-2); border: 1.5px solid rgba(255,255,255,0.08);
}
.spool-name { font-weight: 600; font-size: 14px; }
.spool-meta { font-size: 12px; color: var(--text-2); }
.spool-weight { font-family: var(--font-mono); font-size: 13px; font-weight: 600; margin: 8px 0 4px; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-control {
  width: 100%; padding: 8px 10px;
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-sans); font-size: 13px;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); }
select.form-control option { background: var(--bg-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Filter bar ──────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control { width: auto; }
.filter-bar-right { margin-left: auto; }

/* ── Online dot ──────────────────────────────────────── */
.online-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.online-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.online-dot.off { background: var(--text-3); }

/* ── Empty state ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: var(--radius); }
.modal-close:hover { color: var(--text); background: var(--bg-3); }
#modal-body { padding: 20px; }

/* ── Toast ───────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 13px; min-width: 220px; max-width: 360px;
  animation: slideIn 0.2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

/* ── Alerts ──────────────────────────────────────────── */
.alert-badge { background: var(--red-dim); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; color: var(--red); display: flex; align-items: center; gap: 6px; }
.alert-badge.hidden { display: none; }

/* ── Loading ─────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text-3); gap: 10px; font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Chart container ─────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; }

/* ── Mono text ───────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-2); }
.text-tiny { font-size: 11px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
