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

:root {
  --bg:         #07070f;
  --bg2:        #0e0e1a;
  --bg3:        #141424;
  --border:     rgba(255,255,255,0.07);
  --border-h:   rgba(255,255,255,0.14);
  --text:       #e8e8f0;
  --text-2:     #9090b0;
  --text-3:     #5a5a7a;
  --accent:     #6366f1;
  --accent-2:   #818cf8;
  --accent-g:   linear-gradient(135deg, #6366f1, #a855f7);
  --success:    #10b981;
  --success-bg: rgba(16,185,129,.12);
  --warn:       #f59e0b;
  --warn-bg:    rgba(245,158,11,.12);
  --danger:     #ef4444;
  --danger-bg:  rgba(239,68,68,.12);
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,.6);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Navbar ─────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: rgba(7,7,15,.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; text-decoration: none;
}

.brand-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px #6366f180);
}

.brand-name {
  font-size: 18px; font-weight: 700;
  background: var(--accent-g);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-actions {
  display: flex; align-items: center; gap: 12px;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  transition: background var(--transition);
}
.status-dot.ok     { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.error  { background: var(--danger);  box-shadow: 0 0 8px var(--danger);  }
.status-dot.busy   { background: var(--warn);    box-shadow: 0 0 8px var(--warn); animation: pulse 1s infinite; }

.status-text { font-size: 12px; color: var(--text-2); }

/* ── Container ───────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Pages ───────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; animation: fadeIn .3s ease; }

@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ── Add Product Card ────────────────────────────── */
.add-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  margin-bottom: 36px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.add-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-g);
}

.add-card-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px;
}

.add-card-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-g);
  border-radius: 12px;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.add-card-title { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.add-card-sub   { font-size: 13px; color: var(--text-2); }

.url-input-wrap {
  position: relative; margin-bottom: 12px;
}

.url-prefix-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 16px; pointer-events: none;
}

.url-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', monospace;
  font-size: 14px;
  padding: 14px 16px 14px 44px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.url-input::placeholder { color: var(--text-3); }
.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}

.add-form-row {
  display: flex; gap: 12px; align-items: center;
}

.price-input-wrap {
  position: relative; flex: 0 0 220px;
}

.price-symbol {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--accent-2); font-weight: 600; pointer-events: none;
}

.price-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 14px 16px 14px 32px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.price-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.price-input::placeholder { color: var(--text-3); }
.price-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}

.add-error {
  margin-top: 12px; padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  padding: 14px 24px;
  background: var(--accent-g);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border-h); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-danger-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.3);
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-icon { font-size: 16px; transition: transform .4s; }
.btn-ghost:hover .btn-icon { transform: rotate(180deg); }

/* ── Section header ──────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px; font-weight: 700; color: var(--text);
}

.product-count {
  font-size: 12px; font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent-2);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── Products Grid ───────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Skeleton */
.skeleton-card {
  height: 180px;
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* Product card */
.product-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden;
  animation: fadeIn .3s ease;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-h);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}

.card-status-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-status-bar.above  { background: linear-gradient(90deg,#6366f1,#8b5cf6); }
.card-status-bar.below  { background: linear-gradient(90deg,#10b981,#34d399); }
.card-status-bar.error  { background: linear-gradient(90deg,#ef4444,#f87171); }

.card-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 16px; margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.4;
  min-height: 36px;
}

.card-price {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.card-price .rupee { font-size: 18px; font-weight: 600; color: var(--text-2); }

.card-target {
  font-size: 12px; color: var(--text-2);
  margin-bottom: 14px;
}
.card-target span { color: var(--text-3); }

.card-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
.badge-above { background: rgba(99,102,241,.15); color: var(--accent-2); }
.badge-below { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--danger-bg);  color: var(--danger);  }
.badge-loading { background: var(--warn-bg);  color: var(--warn);    }

.card-time {
  font-size: 11px; color: var(--text-3);
  margin-top: 10px;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center; padding: 64px 0;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p  { color: var(--text-2); font-size: 14px; }

/* ── Detail page ─────────────────────────────────── */
.detail-header {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 28px;
}

.back-btn { align-self: center; }

.detail-meta { flex: 1; }

.detail-name {
  font-size: 20px; font-weight: 700; margin-bottom: 6px; line-height: 1.3;
}

.detail-url {
  font-size: 12px; color: var(--text-2);
  word-break: break-all;
}
.detail-url a { color: var(--accent-2); text-decoration: none; }
.detail-url a:hover { text-decoration: underline; }

/* Stat row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-2); margin-bottom: 8px;
}

.stat-value {
  font-size: 24px; font-weight: 800; letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 12px; color: var(--text-3); margin-top: 4px;
}

/* Chart */
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.chart-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.chart-title { font-size: 15px; font-weight: 700; }

.chart-legend {
  display: flex; align-items: center; gap: 16px;
  font-size: 12px; color: var(--text-2);
}

.legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 4px;
}
.legend-dot.current { background: var(--accent); }
.legend-dot.target  { background: var(--warn); }

.chart-wrap { position: relative; height: 240px; }

/* Table */
.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  overflow: hidden;
}

.table-card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}

.table-title { font-size: 15px; font-weight: 700; }
.table-sub { font-size: 12px; color: var(--text-2); }

.table-wrap { overflow-x: auto; }

.price-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}

.price-table th {
  text-align: left; padding: 10px 12px;
  color: var(--text-3); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
}

.price-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
  vertical-align: middle;
}

.price-table tr:hover td { background: rgba(255,255,255,.025); }
.price-table tr:last-child td { border-bottom: none; }

.price-table .price-val { font-weight: 700; font-size: 14px; }
.price-table .diff-pos  { color: var(--success); }
.price-table .diff-neg  { color: var(--danger); }
.price-table .diff-zero { color: var(--text-2); }

.alert-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}
.alert-yes { background: var(--success-bg); color: var(--success); }
.alert-no  { color: var(--text-3); }

/* Danger zone */
.danger-zone {
  padding-top: 8px; display: flex; justify-content: flex-end;
}

/* ── Hidden utility ───────────────────────────────── */
.hidden { display: none !important; }

/* ── Toast ───────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 999; pointer-events: none;
}

.toast {
  min-width: 260px; max-width: 360px;
  background: var(--bg3);
  border: 1px solid var(--border-h);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease;
}

@keyframes slideIn {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: none; }
}

@keyframes slideOut {
  to { opacity:0; transform: translateX(20px); }
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-info    { border-left: 3px solid var(--accent);  }

/* ── Pulse animation ──────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .4; }
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 20px 16px 60px; }
  .add-form-row { flex-direction: column; }
  .price-input-wrap { flex: none; width: 100%; }
  .btn-primary { width: 100%; justify-content: center; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-row .stat-card:last-child { grid-column: span 2; }
  .detail-header { flex-direction: column; gap: 12px; }
  .products-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .products-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .stat-row .stat-card:last-child { grid-column: auto; }
}
