/* Santali Web Driver styles — sidebar layout, palette inspired by Aagaz S1-O */

:root {
  --bg:        #0e1218;
  --bg-elev:   #161b23;
  --bg-elev-2: #1d232c;
  --bg-elev-3: #262d38;

  --fg:        #e8ecf2;
  --fg-dim:    #8a93a3;
  --fg-faint:  #4a5260;

  --border:    #232a35;
  --border-strong: #3a4452;

  /* Santali colors from the mouse render: light blue body, orange accent */
  --santali-blue:   #75c3e8;
  --santali-blue-2: #5fb3df;
  --accent:         #ff8d3d;
  --accent-2:       #ff7320;
  --accent-dim:     #a85a23;

  --success: #5dd39e;
  --warn:    #ffb454;
  --err:     #ff5c5c;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --font-display: 'Syne', 'DM Sans', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1000px 700px at 100% 0%, rgba(117, 195, 232, 0.06), transparent 60%),
    radial-gradient(800px 500px at 0% 100%, rgba(255, 141, 61, 0.04), transparent 60%),
    var(--bg);
}

/* View-based visibility is now JS-driven via setView() toggling the `hidden`
   attribute on [data-view-show] elements. Component display rules (.hero
   uses display: grid, .splash uses block, etc.) take effect when shown.
   The [hidden] { display: none !important } rule above ensures hiding
   wins over component display. */

/* Blocker */
.blocker {
  position: fixed; inset: 0;
  background: rgba(14, 18, 24, 0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 32px;
}
.blocker-content {
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--err);
  padding: 32px;
  border-radius: var(--radius);
}
.blocker h2 { font-family: var(--font-display); font-size: 22px; margin-bottom: 12px; color: var(--err); }
.blocker p { color: var(--fg-dim); }

/* ─── Layout ────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 6px;
}
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 22px;
  color: var(--santali-blue);
  background: linear-gradient(135deg, rgba(117, 195, 232, 0.18), rgba(117, 195, 232, 0.04));
  border: 1px solid rgba(117, 195, 232, 0.4);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-product {
  color: var(--fg-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: color 0.12s, background 0.12s;
  position: relative;
}
.nav-item:not(:disabled):hover {
  background: var(--bg-elev-2);
  color: var(--fg);
}
.nav-item.active {
  background: rgba(117, 195, 232, 0.08);
  color: var(--santali-blue);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px; bottom: 8px;
  width: 2px;
  background: var(--santali-blue);
  border-radius: 0 2px 2px 0;
}
.nav-item:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-glyph {
  width: 18px;
  display: inline-block;
  text-align: center;
  font-size: 14px;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }
.btn-block { width: 100%; }

/* Main content */
.main {
  padding: 24px 32px 60px;
  max-width: 1100px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover:not(:disabled) { background: var(--bg-elev-3); border-color: var(--fg-faint); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #1a0d04;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
  border-color: var(--accent-2);
  box-shadow: 0 4px 16px rgba(255, 141, 61, 0.3);
}

.btn-ghost { background: transparent; }
.btn-danger { color: var(--err); border-color: rgba(255, 92, 92, 0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 92, 92, 0.1); border-color: var(--err); }
.btn-sm { padding: 5px 12px; font-size: 11px; }

/* ─── Topbar (status) ───────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 12px;
  flex-wrap: wrap;
}
.topbar-status { display: flex; align-items: center; gap: 10px; }
.topbar-status #status { color: var(--fg-dim); }
.topbar-status #status.err { color: var(--err); }
.led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex-shrink: 0;
  transition: all 0.2s;
}
.led.ok { background: var(--success); box-shadow: 0 0 8px var(--success); }
.led.err { background: var(--err); box-shadow: 0 0 8px var(--err); }

.topbar-meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
}
.meta-item { display: flex; align-items: center; gap: 8px; }
.meta-k {
  color: var(--fg-faint);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.meta-v { color: var(--fg); }

.battery-frame {
  width: 36px; height: 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 2px;
  position: relative;
  padding: 1px;
}
.battery-frame::after {
  content: '';
  position: absolute;
  right: -4px; top: 3px;
  width: 2px; height: 4px;
  background: var(--border-strong);
}
.battery-bar {
  height: 100%;
  background: var(--success);
  border-radius: 1px;
  width: 0%;
  transition: width 0.4s ease;
}
.battery-bar.low { background: var(--err); }
.battery-bar.charging { background: var(--warn); }

/* ─── Panels (tab panes) ────────────────────────────────────────────────── */

.panel { padding: 0; }

.cards { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-hdr {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.card-hdr h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.card-sub { color: var(--fg-faint); font-size: 12px; }
.card-body { padding: 22px 24px; }

/* ─── Splash (Home view) ────────────────────────────────────────────────── */

.splash {
  text-align: center;
  padding: 40px 32px;
  max-width: 720px;
  margin: 0 auto;
}
.splash-mouse {
  width: 180px;
  height: auto;
  margin-bottom: 24px;
  filter: drop-shadow(0 8px 32px rgba(117, 195, 232, 0.25));
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.splash-icon { font-size: 56px; color: var(--accent); margin-bottom: 20px; }
.splash-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.splash-tag { color: var(--fg-dim); margin-bottom: 24px; }
.splash-list {
  text-align: left;
  max-width: 480px;
  margin: 24px auto;
  list-style: none;
}
.splash-list li {
  padding: 8px 0 8px 26px;
  color: var(--fg);
  position: relative;
  border-bottom: 1px solid var(--border);
}
.splash-list li:last-child { border-bottom: none; }
.splash-list li::before {
  content: '+';
  position: absolute;
  left: 0;
  color: var(--santali-blue);
  font-weight: 700;
}
.splash-note { color: var(--fg-faint); font-size: 12px; margin-top: 24px; }
.splash-warn .splash-icon { color: var(--warn); }
.splash-warn h2 { color: var(--warn); font-family: var(--font-display); }

/* Hero (when connected) */
.hero {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  align-items: center;
}
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; text-align: center; } }
.hero-mouse {
  width: 100%;
  max-width: 240px;
  height: auto;
  filter: drop-shadow(0 8px 32px rgba(117, 195, 232, 0.3));
}
.hero h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.hero-meta { display: flex; flex-direction: column; gap: 8px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 4px 0; }
.kv .k {
  color: var(--fg-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  align-self: center;
}
.kv .v { font-family: var(--font-mono); font-size: 12px; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

/* ─── Controls ──────────────────────────────────────────────────────────── */

.ctl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.ctl-grid:last-child { margin-bottom: 0; }
.ctl-label {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  font-weight: 500;
}

.select, .num {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  appearance: none;
  cursor: pointer;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238a93a3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.select:focus, .num:focus { outline: none; border-color: var(--santali-blue); }
.select-sm { font-size: 11px; padding: 4px 24px 4px 8px; width: auto; background-position: right 6px center; }
.num { cursor: text; }
.num:disabled { opacity: 0.4; cursor: not-allowed; }
.select:disabled { opacity: 0.4; cursor: not-allowed; }

.color {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 100%;
  height: 36px;
  cursor: pointer;
  padding: 4px;
}
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: none; border-radius: 3px; }

.slider {
  width: 100%;
  height: 32px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track { height: 4px; background: var(--bg-elev-3); border-radius: 2px; }
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  margin-top: -6px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(255,141,61,0.15); }
.slider:disabled::-webkit-slider-thumb { background: var(--fg-faint); }

.ctl-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.ctl-row label {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ctl-row .checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ctl-row .checkbox input { accent-color: var(--santali-blue); }

/* ─── Toggles ───────────────────────────────────────────────────────────── */

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  align-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
}
.toggle:hover { border-color: var(--border-strong); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-vis {
  grid-row: 1 / 3;
  width: 32px; height: 18px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle-vis::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--fg-faint);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.toggle input:checked ~ .toggle-vis { background: var(--accent); border-color: var(--accent); }
.toggle input:checked ~ .toggle-vis::after { background: var(--bg); transform: translateX(14px); }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-hint { color: var(--fg-faint); font-size: 11px; grid-column: 2; }

/* Peak performance row (with attached timer dropdown) */
.peak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.peak-row .toggle { flex: 1; min-width: 280px; }
.peak-timer-wrap { display: flex; align-items: center; gap: 10px; }
.peak-timer-label {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── DPI stages ────────────────────────────────────────────────────────── */

.dpi-row {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 780px) { .dpi-row { grid-template-columns: 1fr; } }

.dpi-stages-wrap {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.dpi-stages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.dpi-tile {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px 8px;
  text-align: center;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  color: var(--fg);
  transition: border-color 0.12s, background 0.12s;
}
.dpi-tile:hover { border-color: var(--fg-faint); }
.dpi-tile.selected { border-color: var(--santali-blue); }
.dpi-tile.active { background: rgba(255, 141, 61, 0.08); }
.dpi-tile.active::before {
  content: '●';
  position: absolute;
  top: 4px; right: 6px;
  color: var(--accent);
  font-size: 8px;
}
.dpi-tile-stage {
  font-size: 9px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.dpi-tile-value { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
.dpi-tile-y     { font-family: var(--font-mono); font-size: 10px; color: var(--fg-dim); }
.dpi-tile-color { width: 100%; height: 4px; border-radius: 2px; margin-top: 8px; }

.dpi-count {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.dpi-count-label {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dpi-editor {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.dpi-editor-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dpi-editor-hdr span:first-child {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--santali-blue);
  font-weight: 500;
}
.dpi-hint { font-size: 11px; color: var(--fg-faint); margin-top: 12px; font-style: italic; }
.hint { color: var(--fg-dim); font-size: 12px; line-height: 1.6; }
.hint code { background: var(--bg-elev-2); padding: 1px 6px; color: var(--santali-blue); font-family: var(--font-mono); font-size: 11px; border-radius: 3px; }

/* ─── Stubs (coming-soon) ───────────────────────────────────────────────── */

.stub {
  text-align: center;
  padding: 32px 24px;
}
.stub-icon { font-size: 48px; color: var(--accent); margin-bottom: 16px; opacity: 0.7; }
.stub h3 {
  font-family: var(--font-display);
  font-size: 20px;
  margin-bottom: 12px;
  color: var(--fg);
}
.stub p { color: var(--fg-dim); max-width: 580px; margin: 0 auto 12px; }
.stub code { background: var(--bg-elev-2); padding: 1px 6px; color: var(--santali-blue); font-family: var(--font-mono); font-size: 11px; border-radius: 3px; }

.button-preview {
  margin-top: 28px;
  padding: 20px;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: left;
}
.button-preview h4 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  color: var(--fg-dim);
}
.button-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.btn-list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.btn-list-item .name { color: var(--fg-dim); font-family: var(--font-mono); font-size: 11px; }
.btn-list-item .action { color: var(--fg); font-weight: 500; }

.pair-status {
  margin-left: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
}
.pair-status.ok { color: var(--success); }
.pair-status.err { color: var(--err); }
.pair-status.pending { color: var(--warn); }

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { flex-shrink: 0; padding: 8px 12px; }
  .nav-item.active::before { display: none; }
  .sidebar-brand { margin-bottom: 14px; }
  .sidebar-footer { flex-direction: row; }
  .main { padding: 16px; }
  .topbar { flex-direction: column; align-items: start; }
}
