/* ─── Reset & base ───────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a12;
  color: #e6e6ef;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
:root {
  --bg-0: #0a0a12;
  --bg-1: #12121d;
  --bg-2: #1a1a2e;
  --bg-3: #22223a;
  --border: #2a2a44;
  --border-light: #3a3a5a;
  --text: #e6e6ef;
  --text-dim: #9a9ab0;
  --text-muted: #6a6a82;
  --accent: #ff6b35;        /* orange */
  --accent-2: #a855f7;      /* purple */
  --accent-3: #d4af37;      /* gold */
  --danger: #ef4444;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --preview-bg: #050509;
  --topbar-grad: linear-gradient(180deg, #14141f 0%, #101018 100%);
}

/* ─── Light theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-0: #f5f5fa;
  --bg-1: #ffffff;
  --bg-2: #f0f0f5;
  --bg-3: #e4e4ec;
  --border: #d4d4de;
  --border-light: #c0c0cc;
  --text: #1a1a2e;
  --text-dim: #5a5a6e;
  --text-muted: #8a8a9e;
  --accent: #e85a25;
  --accent-2: #9333ea;
  --accent-3: #b8860b;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --preview-bg: #1a1a2e;
  --topbar-grad: linear-gradient(180deg, #ffffff 0%, #f8f8fc 100%);
}

/* ─── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--topbar-grad);
  border-bottom: 1px solid var(--border);
  height: 56px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark { color: var(--accent); font-size: 20px; }
.logo-text { font-weight: 800; letter-spacing: 2px; font-size: 14px; }
.topbar-sub { color: var(--text-muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.platform-link {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px; font-weight: 700;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.platform-link:hover { border-color: var(--accent); color: var(--accent); }
.lang-toggle {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Layout ─────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
}
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(255,107,53,0.18), rgba(168,85,247,0.12));
  color: var(--text);
  border-left: 3px solid var(--accent);
}
.nav-icon { font-size: 14px; opacity: 0.85; width: 18px; text-align: center; }
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.status-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg-2);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-pill.ok .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-pill.err .dot { background: var(--danger); }

/* ─── Main ───────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ─── Views ──────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 16px;
}
.view-header h1 { font-size: 22px; font-weight: 700; }
.view-sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.view-header-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header h2 { font-size: 15px; font-weight: 700; color: var(--text); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ff8855 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255,107,53,0.35);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-go-live .live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px #fff;
  animation: livePulse 1.4s infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.i18n-fr { display: none; font-size: 12px; opacity: 0.9; }
body[data-lang="fr"] .i18n-fr { display: inline; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.badge-live { background: var(--danger); color: #fff; }
.badge-onair {
  background: var(--danger); color: #fff;
  animation: livePulse 1.4s infinite;
}
.badge-soon { background: var(--warn); color: #1a1a1a; }
.badge-upcoming { background: var(--bg-3); color: var(--text-dim); }

/* ─── Dashboard grid ────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}
.live-preview-card { grid-row: 1 / 2; grid-column: 1; }
.schedule-card { grid-row: 1 / 2; grid-column: 2; }
.products-card { grid-row: 2 / 3; grid-column: 1 / 3; }

/* ─── Live preview ──────────────────────────────────────────── */
.preview-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--preview-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.preview-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  gap: 8px;
}
.preview-icon { font-size: 42px; opacity: 0.4; }
.preview-overlay {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; justify-content: flex-end;
}
.overlay-product {
  background: linear-gradient(135deg, var(--accent-3) 0%, #f4d03f 100%);
  color: #1a1a1a;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
  min-width: 180px;
  box-shadow: var(--shadow);
}
.overlay-name { font-size: 13px; font-weight: 700; }
.overlay-price { font-size: 16px; font-weight: 800; }
.preview-meta {
  display: flex; gap: 24px;
  padding: 4px 2px;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.meta-value { font-size: 13px; font-weight: 600; }

/* ─── Schedule list ──────────────────────────────────────────── */
.schedule-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.schedule-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  background: var(--bg-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.schedule-time {
  font-size: 16px; font-weight: 800; color: var(--accent-3);
  min-width: 44px;
}
.schedule-info { flex: 1; }
.schedule-title { font-size: 13px; font-weight: 600; }
.schedule-sub { font-size: 11px; color: var(--text-muted); }

/* ─── Product gallery ───────────────────────────────────────── */
.product-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.gallery-loading { color: var(--text-muted); font-size: 13px; padding: 20px; }
.product-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.15s;
  cursor: pointer;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-img {
  aspect-ratio: 1 / 1;
  background: var(--bg-3);
  background-size: cover;
  background-position: center;
  position: relative;
}
.product-img .stock-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
}
.stock-badge.in_stock { background: var(--ok); color: #0a0a12; }
.stock-badge.low_stock { background: var(--warn); color: #1a1a1a; }
.stock-badge.out_of_stock { background: var(--danger); color: #fff; }
.product-body { padding: 10px 12px; }
.product-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.product-price { font-size: 15px; font-weight: 800; color: var(--accent-3); }
.product-currency { font-size: 11px; color: var(--text-muted); margin-left: 3px; }
.product-likes {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted);
  margin-top: 6px;
}

/* ─── Studio grid ───────────────────────────────────────────── */
.studio-grid {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 14px;
}
.scenes-card { grid-column: 1; }
.studio-preview-card { grid-column: 2; }
.right-panel { grid-column: 3; display: flex; flex-direction: column; gap: 14px; }

/* ─── Scenes ────────────────────────────────────────────────── */
.scene-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.scene-item {
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.15s;
}
.scene-item:hover { border-color: var(--border-light); color: var(--text); }
.scene-item.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.18), rgba(255,107,53,0.10));
  border-color: var(--accent-2);
  color: var(--text);
}

/* ─── Studio preview ────────────────────────────────────────── */
.studio-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--preview-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.studio-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 8px;
}
.scene-active-label {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.6);
  padding: 4px 10px; border-radius: 4px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 1px;
}

/* ─── Chat ──────────────────────────────────────────────────── */
.chat-count {
  background: var(--bg-3); color: var(--text-dim);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.chat-card { flex: 1; min-height: 280px; display: flex; flex-direction: column; }
.chat-feed {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 4px;
  min-height: 200px; max-height: 380px;
}
.chat-msg {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}
.chat-user { font-weight: 700; color: var(--accent-2); margin-bottom: 2px; }
.chat-text { color: var(--text); line-height: 1.35; word-break: break-word; }

/* ─── Product queue ─────────────────────────────────────────── */
.queue-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.queue-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.queue-thumb {
  width: 36px; height: 36px;
  border-radius: 6px;
  background-size: cover; background-position: center;
  background-color: var(--bg-3);
  flex-shrink: 0;
}
.queue-info { flex: 1; min-width: 0; }
.queue-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-price { font-size: 11px; color: var(--accent-3); font-weight: 700; }
.queue-actions { display: flex; flex-direction: column; gap: 4px; }
.toggle-overlay-btn {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}
.toggle-overlay-btn:hover { color: var(--text); border-color: var(--border-light); }
.toggle-overlay-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Bottom toolbar ────────────────────────────────────────── */
.toolbar {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }
.toolbar-center { display: flex; align-items: center; }
.ctrl-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.ctrl-btn:hover { border-color: var(--border-light); color: var(--text); }
.ctrl-btn.off { color: var(--danger); border-color: rgba(239,68,68,0.4); }
.ctrl-icon { font-size: 14px; }
.stream-timer {
  font-family: 'Courier New', monospace;
  font-size: 16px; font-weight: 700;
  color: var(--accent-3);
  padding: 4px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.health-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
}

/* ─── Status bar ─────────────────────────────────────────────── */
.statusbar {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 8px 24px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.statusbar-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-good { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-ok { color: var(--ok); font-weight: 600; }

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .studio-grid { grid-template-columns: 200px 1fr 280px; }
}
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-footer .status-pill span:not(.dot) { display: none; }
  .topbar-sub { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .live-preview-card, .schedule-card, .products-card { grid-column: auto; grid-row: auto; }
  .studio-grid { grid-template-columns: 1fr; }
  .right-panel { flex-direction: row; }
  .chat-card, .queue-card { flex: 1; }
  .toolbar { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .right-panel { flex-direction: column; }
  .product-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .statusbar { flex-wrap: wrap; gap: 12px; }
  .view-header { flex-direction: column; }
}

/* ─── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
/* ─── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Light theme overrides ──────────────────────────────────── */
[data-theme="light"] .badge-live { background: var(--danger); }
[data-theme="light"] .stock-badge.in_stock { color: #fff; }
[data-theme="light"] .stock-badge.low_stock { color: #fff; }
[data-theme="light"] .overlay-product { color: #1a1a2e; }
[data-theme="light"] .scene-active-label { background: rgba(255,255,255,0.85); color: #1a1a2e; }
[data-theme="light"] .chat-user { color: var(--accent-2); }
