/* =========================================================
   main.css — Design System
   Font: Inter | Accent: #3B82F6 | Mode: Light
   ========================================================= */

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #3B82F6;
  --accent-dark:  #1D4ED8;
  --accent-light: #EFF6FF;
  --success:      #10B981;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --info:         #6366F1;

  --bg:           #F8FAFC;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --border:       #E2E8F0;
  --border-focus: #93C5FD;

  --text-primary:   #0F172A;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;

  --sidebar-w:    220px;
  --topbar-h:     56px;
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.12);
  --transition:   0.18s ease;

  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
}

body { display: flex; min-height: 100vh; overflow-x: hidden; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}
.logo-icon { font-size: 24px; }
.logo-text  { letter-spacing: -.3px; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.nav-item.active .nav-icon { filter: none; }
.nav-icon  { font-size: 17px; flex-shrink: 0; }
.nav-label { font-size: 13.5px; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.version-badge {
  font-size: 11px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* ── Main Wrap ───────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.api-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 2s infinite;
}
.status-dot.ok  { background: var(--success); animation: none; }
.status-dot.err { background: var(--danger);  animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Content ─────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
}

/* ── Typography ─────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 14px; font-weight: 600; }
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-meta  { font-size: 12px; color: var(--text-muted); }

/* ── Stat Cards ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent  { border-left: 3px solid var(--accent); }
.stat-card.success { border-left: 3px solid var(--success); }
.stat-card.danger  { border-left: 3px solid var(--danger);  }
.stat-card.warning { border-left: 3px solid var(--warning); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-ghost   { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* ── Search ──────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: inline-block;
}
.search-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}
.search-input {
  padding-left: 34px;
  width: 280px;
}

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--surface-2); }
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text-primary); }
thead th.sort-asc::after  { content: ' ↑'; }
thead th.sort-desc::after { content: ' ↓'; }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-light); }
tbody td { padding: 10px 14px; vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-neutral { background: var(--surface-2); color: var(--text-secondary); }
.badge-accent  { background: var(--accent-light); color: var(--accent-dark); }

/* ── Price cells ─────────────────────────────────────── */
.price-best  { color: var(--success); font-weight: 700; }
.price-oos   { color: var(--danger); font-style: italic; }
.price-cell  { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Loading ─────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
  color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .7; }
.empty-text { font-size: 15px; font-weight: 500; margin-bottom: 8px; color: var(--text-secondary); }
.empty-sub  { font-size: 13px; }

/* ── Progress bar ────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--surface-2);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60A5FA);
  border-radius: 20px;
  transition: width .3s ease;
}
.progress-label { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* ── Page header ─────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Row actions ─────────────────────────────────────── */
.row-actions { display: flex; gap: 6px; }

/* ── Divider ─────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-wrap { margin-left: 0; }
  .menu-btn  { display: block; }
  .content   { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .search-input { width: 200px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  h1 { font-size: 18px; }
}
