:root {
  --bg: #222222;
  --bg-soft: #2c2c2c;
  --text: #f5f5f5;
  --muted: #aaaaaa;
  --accent: #ffd800;
  --brand-secondary: #222222;
  --border: rgba(255, 255, 255, 0.08);
}

body[data-theme="light"] {
  --bg: #f4f4f4;
  --bg-soft: #ffffff;
  --text: #1c1c1c;
  --muted: #666666;
  --border: rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: linear-gradient(180deg, #111, var(--bg)); color: var(--text); }
body[data-theme="light"] { background: linear-gradient(180deg, #ffffff, var(--bg)); }
a { color: inherit; }

/* Public catalog theme mapping:
   - background: always white
   - header background: primary color (--accent)
   - buttons + texts: secondary color (--brand-secondary)
   - button text: primary color (--accent)
*/
.public-layout {
  --bg: #ffffff;
  --bg-soft: #ffffff;
  --text: var(--brand-secondary);
  --muted: rgba(34, 34, 34, 0.72);
  --border: rgba(34, 34, 34, 0.16);
  background: #ffffff;
  color: var(--text);
}

.public-layout .public-shell {
  min-height: 100vh;
  background: #ffffff;
}

.public-layout .metric-card,
.public-layout .product-card,
.public-layout .product-detail {
  background: #ffffff;
}

.public-layout .button,
.public-layout .auth-form button,
.public-layout .store-search button {
  background: var(--brand-secondary);
  color: var(--accent);
}

.public-layout .store-header-wrap {
  background: var(--accent);
  border-bottom-color: rgba(0, 0, 0, 0.1);
  backdrop-filter: none;
}

.public-layout .store-brand,
.public-layout .store-brand-name,
.public-layout .store-cart {
  color: var(--brand-secondary);
}

.public-layout .store-cart {
  background: var(--brand-secondary);
  color: var(--accent);
  border-color: transparent;
}

.public-layout .store-search input {
  background: #ffffff;
  color: var(--brand-secondary);
  border-color: rgba(34, 34, 34, 0.2);
}
.auth-card, .metric-card, .product-card, .product-detail, .error-page { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 16px; }
.auth-card { width: min(420px, calc(100vw - 32px)); margin: 10vh auto; padding: 32px; }
.auth-form { display: grid; gap: 16px; }
.auth-form input, .auth-form select, .auth-form textarea { width: 100%; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border); background: #181818; color: var(--text); }
.auth-form select { appearance: none; }
.auth-form button, .button { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #111; font-weight: 700; border: 0; border-radius: 10px; padding: 12px 16px; text-decoration: none; cursor: pointer; }
.admin-frame { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: #171717; border-right: 1px solid var(--border); padding: 24px; }
body[data-theme="light"] .sidebar { background: #ffffff; }
.brand { font-size: 20px; font-weight: 800; margin-bottom: 24px; }
.menu { display: grid; gap: 8px; }
.menu a, .menu button { padding: 12px 14px; border-radius: 10px; text-decoration: none; color: var(--text); background: transparent; border: 0; width: 100%; text-align: left; font: inherit; cursor: pointer; }
.menu a:hover { background: rgba(255, 216, 0, 0.08); }
.menu button:hover { background: rgba(255, 216, 0, 0.08); }
.admin-content { display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; background: rgba(0, 0, 0, 0.18); border-bottom: 1px solid var(--border); }
.page-content { padding: 24px; }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.catalog-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.metric-card, .product-card { padding: 18px; }
.metric-card span, .product-card p { color: var(--muted); }
.landing-hero { padding: 28px 24px; }
.landing-hero { text-align: center; max-width: 860px; margin: 12vh auto; }
.public-footer { text-align: center; padding: 24px 0 40px; color: var(--muted); }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert-error { background: rgba(255, 80, 80, .12); color: #ffb4b4; }

.products-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.products-main {
  min-width: 0;
}

.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.products-toolbar h1 {
  margin: 0;
}

.products-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.product-list {
  display: grid;
  gap: 10px;
}

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.product-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.product-row-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.product-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-row-thumb.is-subproduct {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.product-row-children {
  margin: -2px 0 8px 56px;
  display: grid;
  gap: 8px;
}

.product-variation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.product-row:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 216, 0, 0.35);
}

.product-row-main, .product-row-meta {
  display: grid;
  gap: 4px;
}

.product-row-main span,
.product-row-meta span {
  color: var(--muted);
  font-size: 14px;
}

.product-row-meta {
  justify-items: end;
}

.product-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
  background: rgba(255,255,255,0.06);
}

.status-active { color: #9bffad; }
.status-draft { color: #ffd86b; }
.status-inactive { color: #ff8f8f; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.button-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.button-ghost.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.product-sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.product-sidebar-action {
  width: 100%;
}

.sidebar-card {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.product-modal {
  width: min(1180px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

.product-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.product-modal-form {
  padding: 20px;
  max-width: none;
}

.product-modal-head,
.product-modal-footer,
.modal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-modal-head h2,
.product-modal-head p,
.modal-section-head p {
  margin: 0;
}

.product-modal-head p,
.modal-help,
.modal-image-note,
.modal-section-head p,
.product-modal-footer {
  color: var(--muted);
}

.product-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 18px 0;
}

.modal-section {
  display: grid;
  gap: 12px;
}

.modal-section input,
.modal-section select,
.modal-section textarea,
.product-modal input,
.product-modal select,
.product-modal textarea {
  width: 100%;
}

.modal-image-note {
  font-size: 13px;
}

.product-existing-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.existing-image-thumb {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.existing-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.existing-image-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-section-head {
  margin-bottom: 14px;
}

.variation-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.variation-actions-bottom {
  margin-top: 12px;
}

.variation-attributes {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.variation-attribute {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
  display: grid;
  gap: 10px;
}

.variation-attribute-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.variation-chip-input {
  display: grid;
  gap: 8px;
}

.variation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variation-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 216, 0, 0.10);
  border: 1px solid rgba(255, 216, 0, 0.18);
}

.variation-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.variation-list {
  display: grid;
  gap: 12px;
}

.variation-row {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
  display: grid;
  gap: 14px;
}

.variation-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.variation-row-grid {
  display: grid;
  grid-template-columns: 1.1fr .7fr .7fr .55fr auto;
  gap: 10px;
  align-items: start;
}

.variation-images {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.variation-image-option {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
}

.variation-image-option img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
}

.variation-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variation-file-thumb {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.variation-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.variation-file-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-modal-footer {
  margin-top: 18px;
}

.button-danger {
  background: rgba(214, 46, 46, 0.18);
  color: #ffd7d7;
  border: 1px solid rgba(214, 46, 46, 0.55);
}

.button-danger:hover {
  background: rgba(214, 46, 46, 0.26);
}

dialog::backdrop {
  backdrop-filter: blur(2px);
}

.store-header-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.92), rgba(20, 20, 20, 0.8));
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

body[data-theme="light"] .store-header-wrap {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.88));
}

.store-header {
  min-height: 82px;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(300px, 1fr) 64px;
  align-items: center;
  gap: 14px;
}

.store-brand {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  text-decoration: none;
}

.store-logo {
  max-height: 44px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
}


.public-variation-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.public-variation-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.public-variation-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06) inset;
}

.variation-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.26);
  display: inline-block;
}
.store-brand-name {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.store-search {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 760px;
  justify-self: center;
}

.store-search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #171717;
  color: var(--text);
}

body[data-theme="light"] .store-search input {
  background: #ffffff;
}

.store-search button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: var(--accent);
  color: #151515;
  font-weight: 700;
  cursor: pointer;
}

.store-cart {
  justify-self: end;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

body[data-theme="light"] .store-cart {
  background: #ffffff;
}

.catalog-section-head {
  padding: 0 24px 12px;
}

.catalog-categories {
  row-gap: 8px;
}

.product-carousel {
  position: relative;
  width: 100%;
  height: 190px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: block;
}

.product-carousel-large {
  max-width: 560px;
  height: 360px;
  border-radius: 12px;
}

.carousel-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 380ms ease;
}

.carousel-image.is-active {
  opacity: 1;
}

@media (max-width: 1200px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .admin-frame { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .store-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 16px;
  }

  .store-brand {
    grid-column: 1;
  }

  .store-cart {
    grid-column: 2;
  }

  .store-search {
    grid-column: 1 / span 2;
    max-width: 100%;
  }

  .store-brand-name {
    font-size: 20px;
  }

  .products-shell,
  .product-modal-grid,
  .variation-row-grid {
    grid-template-columns: 1fr;
  }

  .product-sidebar {
    position: static;
  }
}

@media (max-width: 620px) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .product-carousel-large {
    max-width: 100%;
    height: 240px;
  }
}
