/* style.css — device frames, panel layout, UI chrome */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #F8F9FA;
  --color-surface: #FFFFFF;
  --color-surface-2: #F1F3F5;
  --color-surface-offset: #E9ECEF;
  --color-text: #212529;
  --color-text-muted: #6C757D;
  --color-text-faint: #ADB5BD;
  --color-primary: #2F80ED;
  --color-primary-hover: #1A6FD6;
  --color-error: #E03131;
  --color-warning: #F08C00;
  --color-success: #2F9E44;
  --color-border: rgba(33,37,41,0.12);
  --color-divider: rgba(33,37,41,0.07);
  --font-display: 'Satoshi', sans-serif;
  --font-body: 'Inter', sans-serif;
  --space-4: 1rem; --space-8: 2rem; --space-12: 3rem; --space-16: 4rem;
  --radius-sm: 0.375rem; --radius-md: 0.5rem;
  --radius-lg: 0.75rem; --radius-xl: 1rem;
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);
}

html.dark {
  --color-bg: #0D1117; --color-surface: #161B22;
  --color-surface-2: #1C2128; --color-surface-offset: #21262D;
  --color-text: #E6EDF3; --color-text-muted: #8B949E;
  --color-text-faint: #484F58; --color-primary: #4493F8;
  --color-border: rgba(230,237,243,0.10); --color-divider: rgba(230,237,243,0.06);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
}
.topbar-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-badge {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }

/* ── Main layout ────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 49px);
}

/* ── Panels ─────────────────────────────────────────────────── */
.panel {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.panel:last-child { border-right: none; border-left: 1px solid var(--color-border); }
.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--color-divider);
}
.panel-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  margin-bottom: 12px;
}

/* ── Color rows ─────────────────────────────────────────────── */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.color-row label { font-size: 12px; color: var(--color-text-muted); flex: 1; }
.color-row input[type=color] {
  width: 32px; height: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer; padding: 1px;
  background: var(--color-surface);
}
.color-hex {
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-muted);
  width: 60px;
}

/* ── Center: device stage ───────────────────────────────────── */
.stage {
  background: var(--color-surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px;
  overflow: auto;
}

/* ── Device frames ──────────────────────────────────────────── */
.device-frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
}

/* Mobile */
.device-mobile {
  width: 375px;
  min-height: 812px;
  border-radius: 44px;
  border: 10px solid #1a1a1a;
  box-shadow: 0 0 0 1px #333, var(--shadow-lg);
}
.device-mobile::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 120px; height: 30px;
  background: #1a1a1a;
  border-radius: 0 0 20px 20px;
  z-index: 10;
}

/* Web */
.device-web {
  width: 960px;
  min-height: 640px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  max-width: 100%;
}
.device-web-bar {
  height: 36px;
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
}
.device-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

/* Watch */
.device-watch {
  width: 198px;
  min-height: 240px;
  border-radius: 60px;
  border: 8px solid #1a1a1a;
  box-shadow: 0 0 0 1px #333, var(--shadow-lg);
}

/* Desktop */
.device-desktop {
  width: 960px;
  min-height: 600px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

/* Device screen */
.device-screen {
  background: var(--color-bg);
  width: 100%;
  min-height: 100%;
  overflow-y: auto;
  padding: 0;
}
.device-mobile .device-screen { padding-top: 30px; }

/* ── Component preview inside device ────────────────────────── */
.preview-section { padding: 24px 16px; border-bottom: 1px solid var(--color-divider); }
.preview-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-text-faint); margin-bottom: 12px;
}
.preview-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}
.preview-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}
.preview-body {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.preview-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.preview-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.preview-btn-primary { background: var(--color-primary); color: #fff; }
.preview-btn-primary:hover { background: var(--color-primary-hover); }
.preview-btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.preview-btn-ghost:hover { background: var(--color-surface-2); }
.preview-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 13px;
  font-family: var(--font-body);
  margin-bottom: 8px;
  outline: none;
  transition: border-color 0.15s;
}
.preview-input:focus { border-color: var(--color-primary); }
.preview-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full, 9999px);
  font-size: 11px;
  font-weight: 500;
  gap: 4px;
}
.badge-success { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--color-success); }
.badge-error   { background: color-mix(in srgb, var(--color-error) 15%, transparent);   color: var(--color-error); }
.badge-warning { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); }

/* ── Mobile bottom nav ──────────────────────────────────────── */
.mobile-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 12px 0 20px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  position: sticky;
  bottom: 0;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--color-text-faint);
}
.nav-item.active { color: var(--color-primary); }
.nav-icon { font-size: 20px; }

/* ── Audit rows ─────────────────────────────────────────────── */
.audit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-divider);
  font-size: 12px;
}
.audit-row:last-child { border-bottom: none; }
.audit-swatch { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }
.audit-label { flex: 1; color: var(--color-text-muted); }
.audit-ratio { color: var(--color-text); font-family: monospace; font-size: 11px; }
.audit-grade {
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.grade-aaa   { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--color-success); }
.grade-aa    { background: color-mix(in srgb, var(--color-success) 10%, transparent); color: var(--color-success); }
.grade-aalarge { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); }
.grade-fail  { background: color-mix(in srgb, var(--color-error) 15%, transparent); color: var(--color-error); }
.grade-✓     { color: var(--color-success); }
.grade-✗noteongrid { color: var(--color-error); }

/* ── Export buttons ─────────────────────────────────────────── */
.export-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s;
}
.export-btn:hover { background: var(--color-surface-offset); }
.export-icon { font-size: 14px; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }

/* ── Custom Sliders ─────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: var(--color-surface-offset);
  height: 6px;
  border-radius: var(--radius-full, 99px);
  outline: none;
  transition: background 0.15s;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s;
}
input[type=range]:active::-webkit-slider-thumb {
  background: var(--color-primary-hover);
  transform: scale(1.15);
}
