:root {
  --bg: #0f0f11;
  --surface: #18181b;
  --surface2: #242428;
  --border: #2e2e35;
  --accent: #7c3aed;
  --accent2: #a78bfa;
  --text: #f4f4f5;
  --muted: #71717a;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

/* ─── NAV ─── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,17,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  height: 60px;
}
.nav-logo {
  font-weight: 700; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-right: auto;
}
.nav-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: .85rem; transition: all .15s;
}
.nav-btn:hover, .nav-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.cart-btn {
  position: relative; background: var(--accent); border: none;
  color: #fff; padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: .85rem;
}
.cart-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--warn); color: #000;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  display: none;
}

/* ─── HERO ─── */
.hero {
  text-align: center;
  padding: 80px 24px 48px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800; line-height: 1.1;
  background: linear-gradient(135deg, #fff 40%, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 500px; margin: 0 auto; }

/* ─── GRID ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px 80px; }
.section-title {
  font-size: 1.4rem; font-weight: 700;
  margin: 40px 0 20px;
  display: flex; align-items: center; gap: 10px;
}
.badge {
  font-size: .7rem; font-weight: 600; padding: 3px 8px;
  border-radius: 20px; background: var(--accent); color: #fff;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0,0,0,.4);
  border-color: var(--accent);
}
.product-img-wrap {
  aspect-ratio: 1; overflow: hidden; background: var(--surface2);
  position: relative;
}
.product-img-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s;
}
.product-card:hover .product-img-wrap img { transform: scale(1.05); }
.product-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; color: var(--muted);
}
.product-body { padding: 16px; }
.product-title {
  font-size: .9rem; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 8px; line-height: 1.4;
}
.product-price {
  font-size: 1.3rem; font-weight: 800;
  color: var(--accent2);
}
.product-price small { font-size: .8rem; color: var(--muted); font-weight: 400; }
.product-rating {
  font-size: .8rem; color: var(--warn);
  margin: 4px 0 12px;
}
.add-to-cart-btn {
  width: 100%; background: var(--accent);
  border: none; color: #fff; padding: 10px;
  border-radius: 8px; font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: opacity .15s;
}
.add-to-cart-btn:hover { opacity: .85; }

/* ─── PRODUCT DETAIL ─── */
.product-detail {
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px;
  padding: 40px 0;
}
@media(max-width:768px) { .product-detail { grid-template-columns: 1fr; } }
.gallery { position: sticky; top: 80px; }
.gallery-main {
  aspect-ratio: 1; background: var(--surface2);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); margin-bottom: 12px;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb {
  width: 60px; height: 60px; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); cursor: pointer; transition: border-color .15s;
  background: var(--surface2);
}
.thumb.active, .thumb:hover { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-info h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 16px; line-height: 1.3; }
.detail-price { font-size: 2rem; font-weight: 800; color: var(--accent2); margin-bottom: 8px; }
.detail-desc { color: var(--muted); font-size: .95rem; margin: 20px 0; line-height: 1.7; }
.detail-actions { display: flex; gap: 12px; }
.btn-primary {
  flex: 1; background: var(--accent);
  border: none; color: #fff; padding: 14px;
  border-radius: 10px; font-weight: 700; font-size: 1rem;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-secondary {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 14px 20px;
  border-radius: 10px; font-weight: 600; cursor: pointer;
}
.back-btn {
  background: none; border: none; color: var(--accent2);
  font-size: .9rem; cursor: pointer; padding: 0;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 20px;
}

/* ─── ADMIN ─── */
.admin-panel { padding: 40px 0; }
.admin-header { margin-bottom: 32px; }
.admin-header h2 { font-size: 1.8rem; font-weight: 800; }
.admin-header p { color: var(--muted); margin-top: 4px; }

.scrape-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}
.scrape-form h3 { margin-bottom: 16px; font-size: 1.1rem; }
.input-row { display: flex; gap: 10px; }
.url-input {
  flex: 1; background: var(--bg);
  border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 8px; font-size: .95rem;
  transition: border-color .15s;
}
.url-input:focus { outline: none; border-color: var(--accent); }
.url-input::placeholder { color: var(--muted); }
.scrape-btn {
  background: var(--accent); border: none;
  color: #fff; padding: 12px 24px; border-radius: 8px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: opacity .15s;
}
.scrape-btn:hover { opacity: .85; }
.scrape-btn:disabled { opacity: .5; cursor: not-allowed; }

.scrape-result {
  margin-top: 20px; display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.result-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }
@media(max-width:600px) { .result-grid { grid-template-columns: 1fr; } }
.result-img {
  aspect-ratio: 1; background: var(--bg);
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.result-img img { width: 100%; height: 100%; object-fit: cover; }
.result-fields { display: flex; flex-direction: column; gap: 12px; }
.field label {
  display: block; font-size: .75rem;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 4px;
}
.field input, .field textarea {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 8px; font-size: .9rem;
  font-family: var(--font);
  transition: border-color .15s;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 80px; }
.result-actions { margin-top: 16px; display: flex; gap: 10px; }

.products-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
}
.products-table th {
  text-align: left; padding: 12px 16px;
  font-size: .8rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.products-table td {
  padding: 14px 16px; font-size: .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.products-table tr:last-child td { border-bottom: none; }
.products-table tr:hover td { background: var(--surface2); }
.table-img {
  width: 50px; height: 50px; border-radius: 6px;
  object-fit: cover; background: var(--bg);
}
.table-title { max-width: 300px; }
.tbl-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 5px 12px; border-radius: 6px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: opacity .15s;
}
.btn-del { background: rgba(239,68,68,.15); color: var(--danger); }
.btn-del:hover { background: var(--danger); color: #fff; }

/* ─── CART ─── */
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  z-index: 200; display: none; align-items: flex-start; justify-content: flex-end;
}
.cart-overlay.open { display: flex; }
.cart-panel {
  background: var(--surface);
  width: min(420px, 100vw);
  height: 100vh; overflow-y: auto;
  border-left: 1px solid var(--border);
  padding: 24px; display: flex; flex-direction: column;
}
.cart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.cart-header h3 { font-size: 1.2rem; font-weight: 700; }
.close-btn { background: none; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.cart-items { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.cart-item { display: flex; gap: 14px; padding: 14px; background: var(--surface2); border-radius: 10px; border: 1px solid var(--border); }
.cart-item-img { width: 70px; height: 70px; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { flex: 1; }
.cart-item-title { font-size: .85rem; font-weight: 600; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cart-item-price { color: var(--accent2); font-weight: 700; }
.cart-item-qty { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-btn { background: var(--border); border: none; color: var(--text); width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.cart-total { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; }
.cart-total-row { display: flex; justify-content: space-between; margin-bottom: 16px; }
.cart-total-row span:last-child { font-weight: 700; font-size: 1.1rem; color: var(--accent2); }
.checkout-btn { width: 100%; background: var(--accent); border: none; color: #fff; padding: 14px; border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer; }
.empty-cart { text-align: center; color: var(--muted); padding: 40px 0; }
.empty-cart div { font-size: 3rem; margin-bottom: 12px; }

/* ─── TOAST ─── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px; font-size: .9rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── LOADER ─── */
.loader {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent2); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 80px 24px; color: var(--muted);
}
.empty-state div:first-child { font-size: 4rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

/* ─── IMAGES STRIP ─── */
.images-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.strip-thumb {
  width: 64px; height: 64px; border-radius: 8px;
  overflow: hidden; border: 2px solid var(--border);
  cursor: pointer; transition: border-color .15s; background: var(--bg);
  flex-shrink: 0;
}
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.strip-thumb.selected { border-color: var(--accent); }
