@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --bg: #f8fafc;
  --bg-pattern: radial-gradient(circle at 18% 0%, rgba(13, 148, 136, 0.05) 0%, transparent 42%),
    radial-gradient(circle at 82% 100%, rgba(249, 115, 22, 0.04) 0%, transparent 38%);
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --primary-glow: rgba(13, 148, 136, 0.25);
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-light: #ffedd5;
  --accent-glow: rgba(249, 115, 22, 0.3);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gradient-primary: linear-gradient(135deg, #0d9488 0%, #0891b2 100%);
  --gradient-accent: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  --gradient-hero: linear-gradient(145deg, #042f2e 0%, #0d9488 42%, #0891b2 100%);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08), 0 8px 32px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12), 0 24px 64px rgba(13, 148, 136, 0.08);
  --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --header-h: 76px;
  --category-nav-h: 56px;
  --bottom-nav-h: 72px;
  --page-gutter: max(16px, calc((100vw - min(1280px, 100vw - 32px)) / 2));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --focus-ring: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-pattern);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

html {
  scroll-behavior: auto;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  box-shadow: none;
}

.container {
  width: min(1280px, 100% - 32px);
  margin-inline: auto;
}

.page { padding: 28px 0 56px; min-height: calc(100vh - var(--header-h)); }
.muted { color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 11px 20px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.925rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.2s;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-accent {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: 10px; }
.btn-lg { padding: 15px 28px; font-size: 1.05rem; border-radius: 14px; }

/* ── Forms ─────────────────────────────────────── */
.input, .select, .textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.9;
}

.textarea { resize: vertical; min-height: 110px; }
.label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 7px; color: var(--text); }
.field { margin-bottom: 18px; }
.field-hint { display: block; margin-top: 6px; font-size: 0.8rem; }

/* ── Custom select ─────────────────────────────── */
.select-custom {
  position: relative;
  width: 100%;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.select-trigger:hover:not(:disabled) {
  border-color: rgba(13, 148, 136, 0.45);
  background: #fff;
}

.select-custom.is-open .select-trigger,
.select-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: #fff;
}

.select-custom.is-disabled .select-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.select-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-trigger-label.is-placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.select-chevron {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  transition: transform 0.22s var(--ease-out), background 0.2s, color 0.2s;
}

.select-chevron svg {
  width: 16px;
  height: 16px;
}

.select-custom.is-open .select-chevron {
  transform: rotate(180deg);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.select-menu {
  z-index: 500;
  max-height: min(280px, 50vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: selectMenuIn 0.2s var(--ease-out) both;
}

.select-menu-fixed {
  position: fixed;
}

@keyframes selectMenuIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.select-option:hover:not(:disabled) {
  background: var(--surface-2);
}

.select-option.is-selected {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.select-option.is-selected:hover:not(:disabled) {
  background: #99f6e4;
}

.select-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.select-option-label {
  flex: 1;
  min-width: 0;
}

.select-option-check {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.select-option-check svg {
  width: 13px;
  height: 13px;
}

.select-custom.select-sm {
  width: auto;
  min-width: 100px;
}

.select-custom.select-sm .select-trigger {
  padding: 10px 12px;
  font-size: 0.88rem;
}

/* Native select fallback (if any remain) */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 42px;
  cursor: pointer;
}

.select:hover:not(:disabled) {
  border-color: rgba(13, 148, 136, 0.45);
}

.select option {
  padding: 10px;
  font-weight: 600;
}

.select-native-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.browse-filters-form .select-custom .select-trigger {
  min-height: 46px;
  padding: 11px 12px;
  font-size: 0.88rem;
}

.browse-filters-form .input {
  min-height: 46px;
  padding: 11px 14px;
  font-size: 0.88rem;
}

/* ── Custom checkbox ───────────────────────────── */
.checkbox-custom {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.checkbox-custom input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.checkbox-custom-box {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: transparent;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}

.checkbox-custom-box svg {
  width: 14px;
  height: 14px;
}

.checkbox-custom-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.checkbox-custom:hover .checkbox-custom-box {
  border-color: rgba(13, 148, 136, 0.45);
}

.checkbox-custom input:focus-visible + .checkbox-custom-box {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.checkbox-custom input:checked + .checkbox-custom-box {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* ── Cards ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-card);
}

.card-padded { padding: 22px 26px; }
.card-padded-sm { padding: 16px 20px; }
.card-padded-lg { padding: 32px 36px; }

/* ── Badges ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-featured { background: var(--accent-light); color: var(--accent-dark); }
.badge-verified { background: #ecfdf5; color: #047857; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-sold { background: var(--surface-2); color: var(--text-muted); }
.badge-condition { background: rgba(255,255,255,0.92); color: var(--text); font-size: 0.68rem; backdrop-filter: blur(4px); }

/* ── Listing cards ─────────────────────────────── */
.grid-listings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 22px;
}

.listing-card {
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  position: relative;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.listing-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(13, 148, 136, 0.2);
}

.listing-card-image {
  position: relative;
  aspect-ratio: 4/3;
  background: linear-gradient(145deg, var(--surface-2), var(--surface-3));
  overflow: hidden;
  display: block;
}

.listing-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.35) 0%, transparent 45%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.listing-card:hover .listing-card-image::after { opacity: 1; }

.listing-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--ease-out);
}

.listing-card:hover .listing-card-image img { transform: scale(1.06); }

.listing-card-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 2;
}

.listing-card-fav {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 3;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: transform 0.2s, color 0.2s, background 0.2s;
}

.listing-card-fav:hover { transform: scale(1.08); background: white; }
.listing-card-fav.active { color: var(--danger); }
.listing-card-fav.active svg { fill: var(--danger); stroke: var(--danger); }

.listing-card-body { padding: 18px 20px 22px; display: block; }

.listing-card-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.listing-card-price {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}

.listing-card-negotiable {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 9px;
  border-radius: 999px;
}

.listing-card-title {
  margin: 8px 0 6px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}

.listing-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.listing-card-meta .meta-icon { flex-shrink: 0; opacity: 0.75; color: var(--primary); }

.listing-card-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.listing-card-seller {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.listing-card-seller .badge { font-size: 0.62rem; padding: 2px 7px; }

.stars { color: #fbbf24; }

/* ── Empty & skeleton ──────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 36px;
  color: var(--text-muted);
  border: 1.5px dashed rgba(226, 232, 240, 0.9);
  background: linear-gradient(165deg, var(--surface) 0%, rgba(248, 250, 252, 0.6) 100%);
}

.empty-state-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  background: var(--primary-light);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.12);
}

.empty-state h3 { margin: 0 0 10px; color: var(--text); font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.empty-state p { margin: 0; max-width: 36ch; margin-inline: auto; line-height: 1.6; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}

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

/* ── Auth shell ────────────────────────────────── */
html.auth-shell-page,
body.auth-shell-page {
  height: 100%;
  overflow: hidden;
}

body.auth-shell-page {
  height: 100dvh;
}

.auth-shell {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-hero {
  background: var(--gradient-hero);
  color: white;
  padding: clamp(20px, 3vh, 32px) clamp(24px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.auth-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 85%, rgba(251, 191, 36, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.1) 0%, transparent 35%);
  pointer-events: none;
}

.auth-hero::after {
  content: '';
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.auth-hero > * { position: relative; z-index: 1; }

.auth-hero h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
  margin: 0 0 10px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.auth-hero h1 em {
  font-style: normal;
  color: #99f6e4;
}
.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3vh, 32px) clamp(20px, 3vw, 28px);
  background: var(--surface);
  min-height: 0;
  overflow: hidden;
}
.auth-form { width: 100%; max-width: 400px; }
.auth-form h2 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-form .field { margin-bottom: 14px; }

.seller-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

@media (max-width: 768px) {
  html.auth-shell-page,
  body.auth-shell-page {
    overflow: auto;
    height: auto;
  }

  .auth-shell {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .auth-hero { display: none; }
  .auth-form-panel { padding: 28px 20px; overflow: visible; }
  .card-padded { padding: 18px 16px; }
  .card-padded-lg { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .grid-listings { grid-template-columns: 1fr; gap: 16px; }
}
