@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #6b6862;
  --border: #dcd6cb;
  --danger: #991b1b;
  --sticky-bg: rgba(250, 248, 245, 0.92);
  --overlay-pill: rgba(255, 255, 255, 0.95);
  --backdrop-bg: rgba(24, 24, 27, 0.58);
  --star-fill: #c58f36;
  --star-empty: #e2ddd5;
  --bg-dot: rgba(24, 24, 27, 0.055);
  --bg-glow: rgba(197, 143, 54, 0.08);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #18181b;
  --ink: #f4f3ef;
  --muted: #a19d94;
  --border: #2b2b30;
  --danger: #f87171;
  --sticky-bg: rgba(17, 17, 19, 0.92);
  --overlay-pill: rgba(24, 24, 27, 0.95);
  --backdrop-bg: rgba(0, 0, 0, 0.72);
  --star-fill: #d49b38;
  --star-empty: #323238;
  --bg-dot: rgba(244, 243, 239, 0.045);
  --bg-glow: rgba(212, 155, 56, 0.06);
}

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

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 0%, var(--bg-glow) 0%, transparent 62%),
    radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Sticky Search Bar, Theme Toggle & Subtle Disclosure */
.top-controls {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  margin-bottom: 2.5rem;
}

.top-controls-inner {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 0.78rem 1.15rem 0.78rem 2.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s;
}

#searchInput:focus {
  border-color: var(--ink);
  box-shadow: 0 6px 20px rgba(24, 24, 27, 0.08);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s ease, background-color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--ink);
  transform: scale(1.06);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.disclosure-note {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Main Grid */
main {
  max-width: 1320px;
  margin: 0 auto 6rem;
  padding: 0 2rem;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 2rem;
}

/* Bordered & Softly Rounded Editorial Product Card */
.card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  transition: border-color 0.25s, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease, background-color 0.25s;
}

.card:hover {
  border-color: var(--ink);
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.1rem;
}

.card-media img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover .card-media img {
  transform: scale(1.05);
}

.card-overlay-hint {
  position: absolute;
  bottom: 0.85rem;
  left: 50%;
  transform: translate(-50%, 8px);
  background: var(--overlay-pill);
  color: var(--ink);
  padding: 0.45rem 1.1rem;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.card:hover .card-overlay-hint {
  opacity: 1;
  transform: translate(-50%, 0);
}

.card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 0.2rem 0.25rem;
  flex: 1;
  justify-content: space-between;
}

.card-title-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 0.2rem;
  color: var(--muted);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.25s ease;
}

.card:hover .card-arrow {
  color: var(--ink);
  transform: translate(3px, -3px);
}

/* Vector Star Rating */
.rating-row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.stars-svg {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stars-svg svg {
  width: 20px;
  height: 20px;
}

.rating-score {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.modal-rating .stars-svg svg {
  width: 24px;
  height: 24px;
}

.modal-rating .rating-score {
  font-size: 1.12rem;
}

.crud-sub-row .stars-svg {
  gap: 2px;
}

.crud-sub-row .stars-svg svg {
  width: 15px;
  height: 15px;
}

.crud-sub-row .rating-score {
  font-size: 0.85rem;
}

/* Quick-View Pop-Up Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-bg);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 840px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.28);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--overlay-pill);
  border: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  z-index: 2;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.modal-close:hover {
  border-color: var(--ink);
  transform: scale(1.08);
}

.modal-image-wrap {
  background: var(--bg);
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
}

.modal-image-wrap img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.modal-details {
  padding: 2.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal-title {
  font-family: var(--sans);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.modal-rating {
  margin-bottom: 2rem;
}

.btn-amazon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--sans);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-amazon:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.modal-note {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* Admin Studio Top Bar */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 2rem;
}

.admin-topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.2s ease;
}

.admin-back:hover {
  transform: scale(1.03);
}

.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.76rem;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status-linked {
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.35);
}

:root[data-theme="dark"] .status-linked {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
}

.status-linked .status-dot {
  background: #22c55e;
}

.status-warn {
  color: var(--danger);
  border-color: rgba(153, 27, 27, 0.35);
}

.status-warn .status-dot {
  background: var(--danger);
}

.btn-pill {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.btn-pill:hover {
  border-color: var(--ink);
  transform: scale(1.03);
}

.btn-pill-primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.btn-pill-primary:hover {
  transform: scale(1.03);
}

/* Admin Workspace Grid (Centered) */
.admin-main {
  max-width: 1040px;
  margin: 2.5rem auto 5rem;
  padding: 0 2rem;
}

.admin-grid {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  justify-content: center;
}

.admin-left {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.admin-panel {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.35rem;
}

.panel-eyebrow {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.admin-panel h1,
.admin-panel h2 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--ink);
}

.admin-panel h1 {
  font-size: 1.5rem;
}

.admin-panel h2 {
  font-size: 1.2rem;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-text-danger:hover {
  transform: scale(1.04);
}

.field {
  margin-bottom: 1.15rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.field label {
  display: block;
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.label-row label {
  margin-bottom: 0;
}

.rating-badge {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--star-fill);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="number"] {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.field input:focus {
  border-color: var(--ink);
  background: var(--surface);
}

.admin-btns {
  margin-top: 1.5rem;
}

/* Live Preview Card Box */
.preview-stage {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
}

.preview-card {
  width: 100%;
  max-width: 250px;
  cursor: default;
}

.preview-card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

/* Catalog / Inventory List */
.crud-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

#adminSearchInput {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--ink);
  outline: none;
}

#adminSearchInput:focus {
  border-color: var(--ink);
  background: var(--surface);
}

.crud-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 760px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.crud-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.2s, background-color 0.2s;
}

.crud-item:hover {
  border-color: var(--ink);
}

.crud-item.is-editing {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.crud-item img {
  width: 60px;
  height: 60px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-shrink: 0;
}

.crud-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.crud-title {
  font-family: var(--sans);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}

.crud-sub-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.crud-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, transform 0.2s ease;
}

.crud-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
  transform: scale(1.03);
}

.crud-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.45rem 0.72rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.btn-sm:hover {
  border-color: var(--ink);
  transform: scale(1.04);
}

.btn-sm-delete {
  color: var(--danger);
}

.btn-sm-delete:hover {
  border-color: var(--danger);
  transform: scale(1.04);
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
    max-width: 560px;
  }
  .admin-topbar {
    padding: 0.85rem 1rem;
  }
  .admin-main {
    padding: 0 1rem;
  }
}

@media (max-width: 768px) {
  .modal-card {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-image-wrap {
    aspect-ratio: 1 / 1;
    max-height: 360px;
  }
  .modal-details {
    padding: 1.75rem 1.5rem;
  }
}

/* 2x2 Grid Layout on Mobile */
@media (max-width: 640px) {
  .top-controls {
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .disclosure-note {
    font-size: 0.7rem;
  }

  main {
    padding: 0 0.85rem 4rem;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .card {
    border-radius: 10px;
    padding: 0.55rem;
  }

  .card:hover {
    transform: none;
  }

  .card-media {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    margin-bottom: 0.65rem;
  }

  .card-overlay-hint {
    display: none;
  }

  .card-title-row {
    gap: 0.35rem;
    margin-bottom: 0.45rem;
  }

  .card-title {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  .card-arrow {
    width: 14px;
    height: 14px;
    margin-top: 0.15rem;
  }

  .rating-row {
    gap: 0.35rem;
  }

  .stars-svg {
    gap: 2px;
  }

  .stars-svg svg {
    width: 15px;
    height: 15px;
  }

  .rating-score {
    font-size: 0.85rem;
  }

  .crud-item {
    flex-wrap: wrap;
  }

  .crud-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
}