/* ============ BASE ============ */
:root {
  --navy: #0f2c4d;
  --navy-2: #1e3a5f;
  --navy-3: #2c5282;
  --red: #ec3b24;
  --red-2: #c22e1a;
  --red-light: #fff1ef;
  --gray: #f5f7fb;
  --gray-2: #eef1f6;
  --border: #e3e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 4px 20px rgba(15,23,42,0.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,0.15);
  --radius: 16px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--gray);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }

/* ============ HEADER ============ */
header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border);
}
.hwrap {
  max-width: 1200px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { width: 42px; height: 42px; object-fit: contain; }
.logo-text {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.6px; font-style: italic;
  color: var(--navy);
}
.logo-text span { color: var(--red); }

.h-actions { display: flex; align-items: center; gap: 10px; }

.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  transition: all 0.2s; white-space: nowrap;
  background: #fff; color: var(--navy);
  border: 1px solid var(--border);
  position: relative;
}
.nav-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.nav-btn.primary { background: var(--red); color: #fff; border-color: var(--red); }
.nav-btn.primary:hover { background: var(--red-2); border-color: var(--red-2); }

.cart-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--red); color: #fff;
  min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ============ HERO ============ */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  color: #fff;
  padding: 48px 24px;
  text-align: center;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute;
  top: -50%; right: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(236,59,36,0.25) 0%, transparent 70%);
  border-radius: 50%;
}
.hero::after {
  content: ''; position: absolute;
  bottom: -60%; left: -5%;
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  border-radius: 50%;
}
.hero-inner { position: relative; z-index: 1; max-width: 700px; margin: 0 auto; }
.hero h1 {
  font-size: 36px; font-weight: 900;
  letter-spacing: -1px; margin-bottom: 10px;
  line-height: 1.15;
}
.hero p { opacity: 0.9; font-size: 16px; }

/* ============ CONTAINER ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }

/* ============ SEARCHBAR ============ */
.searchbar {
  display: flex; gap: 10px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.search-input-wrap { flex: 2; min-width: 240px; position: relative; }
.search-input-wrap::before {
  content: '🔍'; position: absolute;
  left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 16px; pointer-events: none; opacity: 0.6;
}
.searchbar input {
  width: 100%; padding: 14px 16px 14px 46px;
  border: 1.5px solid var(--border); background: #fff;
  border-radius: 12px; font-size: 15px; outline: none;
  transition: all 0.2s; color: var(--text);
}
.searchbar input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 4px rgba(30,58,95,0.08);
}
.searchbar select {
  flex: 1; min-width: 160px;
  padding: 14px 16px;
  border: 1.5px solid var(--border); background: #fff;
  border-radius: 12px; font-size: 15px; outline: none;
  cursor: pointer; color: var(--text);
}
.searchbar select:focus { border-color: var(--navy); }

/* ============ GRID ============ */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

/* ============ CARD ============ */
.card {
  background: #fff; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  display: flex; flex-direction: column;
  position: relative;
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.card .imwrap {
  width: 100%; aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #f0f2f5, #e8ecf1);
  display: flex; align-items: center; justify-content: center;
  font-size: 56px; color: #cbd5e1;
  overflow: hidden; position: relative;
}
.card .imwrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.16,1,0.3,1);
}
.card:hover .imwrap img { transform: scale(1.08); }

.stock-tag {
  position: absolute; top: 12px; right: 12px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.stock-tag.in  { color: var(--success); }
.stock-tag.low { color: var(--warning); }
.stock-tag.out { color: var(--red); }

.card .info {
  padding: 14px 16px 16px; flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.card h3 {
  font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.card .shop {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
}
.card .price {
  color: var(--red); font-weight: 900;
  font-size: 20px; letter-spacing: -0.5px;
  margin-top: 6px;
}
.card .card-stats {
  display: flex; gap: 6px; margin-top: 8px;
  flex-wrap: wrap; font-size: 11px;
}
.card .sold-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--red-light); color: var(--red);
  padding: 4px 8px; border-radius: 6px; font-weight: 700;
}
.card .sold-badge.new { background: var(--gray-2); color: var(--muted); }
.card .stock-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--success-bg); color: var(--success);
  padding: 4px 8px; border-radius: 6px; font-weight: 700;
}
.card .stock-badge.low { background: var(--warning-bg); color: var(--warning); }

.card .card-actions {
  display: flex; gap: 8px; margin-top: 12px;
}
.card .view-btn, .card .add-btn {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  font-weight: 700; font-size: 13px;
  transition: all 0.2s; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.card .view-btn {
  background: #fff; color: var(--navy);
  border: 1.5px solid var(--border);
}
.card .view-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.card .add-btn {
  background: var(--red); color: #fff;
}
.card .add-btn:hover { background: var(--red-2); }
.card .add-btn:disabled {
  background: var(--gray-2); color: var(--muted); cursor: not-allowed;
}

/* ============ STATES ============ */
.loading-state, .empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--muted); font-size: 15px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state .emoji { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { color: var(--text); font-size: 20px; margin-bottom: 6px; font-weight: 800; }

/* ============ DETAIL PAGE ============ */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--navy);
  padding: 10px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  margin-bottom: 20px; border: 1px solid var(--border);
  transition: all 0.2s;
}
.back-link:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

.detail-card {
  background: #fff; border-radius: 24px;
  overflow: hidden; border: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr;
  box-shadow: var(--shadow);
}

/* Image gallery */
.gallery {
  display: flex; flex-direction: column;
  background: linear-gradient(135deg, #f0f2f5, #e8ecf1);
}
.gallery-main {
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 100px; color: #cbd5e1;
  overflow: hidden;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs {
  display: flex; gap: 8px; padding: 12px;
  overflow-x: auto; background: #fff;
  scrollbar-width: thin;
}
.gallery-thumbs::-webkit-scrollbar { height: 6px; }
.gallery-thumbs::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 3px;
}
.thumb {
  width: 68px; height: 68px;
  border-radius: 10px; overflow: hidden;
  cursor: pointer; flex-shrink: 0;
  border: 2px solid transparent;
  transition: all 0.2s;
  background: var(--gray-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--navy); }
.thumb:hover { border-color: var(--navy-3); }

.detail-body { padding: 32px; display: flex; flex-direction: column; }
.detail-shop {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; margin-bottom: 10px;
}
.detail-body h1 {
  font-size: 28px; font-weight: 900;
  letter-spacing: -0.6px; margin-bottom: 10px;
  line-height: 1.2;
}
.detail-price {
  color: var(--red); font-size: 34px;
  font-weight: 900; letter-spacing: -1px;
  margin-bottom: 10px;
}
.delivery-info {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--warning-bg); color: var(--warning);
  padding: 8px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  margin-bottom: 20px; width: fit-content;
}

.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.stat-box {
  background: var(--gray); padding: 14px 8px;
  border-radius: 12px; text-align: center;
  border: 1px solid var(--border);
}
.stat-box .val {
  font-size: 20px; font-weight: 800;
  color: var(--navy); line-height: 1.2;
}
.stat-box .lbl {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 3px; font-weight: 700;
}
.stat-box.sold .val { color: var(--red); }
.stat-box.stock .val { color: var(--success); }

.detail-desc {
  background: #fafbfd; border-left: 3px solid var(--navy);
  padding: 14px 16px; border-radius: 8px;
  font-size: 14px; color: #4b5563;
  line-height: 1.7; margin-bottom: 20px;
}

.qty-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.qty-row label {
  font-size: 13px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px;
}
.qty-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 20px; font-weight: 700; color: var(--navy);
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover:not(:disabled) { background: var(--navy); color: #fff; border-color: var(--navy); }
.qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-input {
  width: 70px; text-align: center;
  font-weight: 800; font-size: 16px;
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px; outline: none;
}

.total-box {
  background: linear-gradient(135deg, #fff8f6 0%, #ffe9e3 100%);
  border: 1.5px dashed var(--red);
  padding: 16px; border-radius: 14px;
  margin: 8px 0 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.total-box .lbl { color: var(--muted); font-size: 13px; font-weight: 700; }
.total-box .amt { color: var(--red); font-size: 24px; font-weight: 900; letter-spacing: -0.5px; }

.btn {
  width: 100%; padding: 15px;
  border-radius: 12px; font-weight: 800;
  font-size: 15px; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary {
  background: var(--navy); color: #fff;
  box-shadow: 0 6px 18px rgba(15,44,77,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-2); transform: translateY(-2px); }
.btn-red {
  background: var(--red); color: #fff;
  box-shadow: 0 6px 18px rgba(236,59,36,0.3);
}
.btn-red:hover:not(:disabled) { background: var(--red-2); transform: translateY(-2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-row { display: flex; gap: 10px; }

/* ============ CART ============ */
.cart-item {
  background: #fff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  display: flex; gap: 14px; align-items: center;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.cart-item:hover { box-shadow: var(--shadow); border-color: transparent; }
.cart-item img, .cart-item .noimg {
  width: 84px; height: 84px;
  border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--gray-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #cbd5e1;
}
.cart-item .details { flex: 1; min-width: 0; }
.cart-item .details .nm {
  font-weight: 800; font-size: 15px;
  margin-bottom: 4px; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-item .details .sh { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cart-item .details .pr { color: var(--red); font-weight: 900; font-size: 16px; }
.cart-item .details .df { font-size: 11px; color: var(--warning); font-weight: 700; margin-top: 2px; }

.cart-item .qty-mini {
  display: flex; align-items: center; gap: 4px;
  background: var(--gray); border-radius: 10px;
  padding: 4px;
}
.cart-item .qty-mini button {
  width: 30px; height: 30px; border-radius: 8px;
  background: #fff; color: var(--navy);
  font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.cart-item .qty-mini button:hover { background: var(--navy); color: #fff; }
.cart-item .qty-mini .q {
  min-width: 32px; text-align: center;
  font-weight: 800; font-size: 14px;
}

.cart-item .remove-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--red-light); color: var(--red);
  font-size: 16px; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cart-item .remove-btn:hover { background: var(--red); color: #fff; }

.summary-box {
  background: #fff; border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--border);
  position: sticky; top: 90px;
}
.summary-box h3 {
  font-size: 18px; font-weight: 800;
  color: var(--navy); margin-bottom: 16px;
}
.summary-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; font-size: 14px;
  color: var(--muted);
}
.summary-row .v { color: var(--text); font-weight: 700; }
.summary-row.total {
  border-top: 2px dashed var(--border);
  margin-top: 10px; padding-top: 14px;
  font-size: 16px; color: var(--text);
  font-weight: 700;
}
.summary-row.total .v {
  color: var(--red); font-size: 24px;
  font-weight: 900; letter-spacing: -0.5px;
}

/* ============ CHECKOUT ============ */
.summary-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  margin-bottom: 20px;
}
.mini-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.mini-item:last-child { border-bottom: none; }
.mini-item img, .mini-item .noimg {
  width: 50px; height: 50px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  background: var(--gray-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #cbd5e1;
}
.mini-item .info { flex: 1; min-width: 0; }
.mini-item .info .nm {
  font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-item .info .sh { font-size: 11px; color: var(--muted); }
.mini-item .qty-pr { font-weight: 800; color: var(--navy); font-size: 14px; }

.form-card {
  background: #fff; border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--border);
}
.form-card h2 {
  font-size: 20px; font-weight: 800;
  color: var(--navy); margin-bottom: 6px;
}
.form-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.form-card label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.3px; margin-bottom: 6px; margin-top: 12px;
}
.form-card input, .form-card textarea, .form-card select {
  width: 100%; padding: 13px 15px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: all 0.2s; background: #fff;
}
.form-card input:focus, .form-card textarea:focus, .form-card select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 4px rgba(30,58,95,0.08);
}
.form-card textarea { resize: vertical; min-height: 70px; }

/* ============ TRACKING ============ */
.track-order {
  background: #fff; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  margin-bottom: 14px;
}
.track-head {
  display: flex; justify-content: space-between;
  align-items: start; gap: 12px; margin-bottom: 12px;
}
.track-head .nm {
  font-weight: 800; font-size: 16px;
  color: var(--navy); margin-bottom: 4px;
}
.track-head .id {
  font-size: 12px; color: var(--muted);
}
.status-badge {
  padding: 6px 12px; border-radius: 8px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
.status-badge.pending    { background: var(--warning-bg); color: var(--warning); }
.status-badge.completed  { background: var(--success-bg); color: var(--success); }
.status-badge.cancelled  { background: var(--red-light); color: var(--red); }
.status-badge.processing { background: #e0f2fe; color: #0369a1; }
.status-badge.shipped    { background: #f3e8ff; color: #7c3aed; }

.track-details {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; font-size: 13px; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--border);
}
.track-details b { color: var(--text); }

/* ============ MESSAGES ============ */
.form-msg {
  padding: 12px; border-radius: 10px;
  margin-top: 12px; font-size: 14px;
  font-weight: 700; display: none; text-align: center;
}
.form-msg.ok  { background: var(--success-bg); color: var(--success); display: block; }
.form-msg.err { background: var(--red-light); color: var(--red); display: block; }

/* ============ FOOTER ============ */
footer {
  text-align: center; padding: 32px 20px;
  color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--border); margin-top: 40px;
}
footer a { color: var(--navy); font-weight: 700; }

/* ============ MOBILE ============ */
@media (max-width: 860px) {
  .detail-card { grid-template-columns: 1fr; }
  .detail-body { padding: 24px; }
  .gallery-main { aspect-ratio: 4 / 3; }
}
@media (max-width: 640px) {
  .hwrap { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .logo img { width: 36px; height: 36px; }
  .logo-text { font-size: 18px; }
  .nav-btn { padding: 8px 12px; font-size: 13px; }
  .hero { padding: 32px 20px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 14px; }
  .container { padding: 18px 14px 60px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card h3 { font-size: 13px; }
  .card .price { font-size: 17px; }
  .card .info { padding: 12px; }
  .card .card-actions { flex-direction: column; }
  .card .view-btn, .card .add-btn { padding: 8px; font-size: 12px; }
  .detail-body { padding: 20px; }
  .detail-body h1 { font-size: 22px; }
  .detail-price { font-size: 28px; }
  .stat-box .val { font-size: 17px; }
  .cart-item { flex-wrap: wrap; }
  .cart-item .details { flex: 1 1 100%; order: 3; }
  .cart-item .qty-mini { order: 4; }
  .summary-box { position: static; }
}