/* Interactive components for v2 site: catalog menu, search, cart panel, breadcrumbs helpers */

.v2-breadcrumbs {
  padding: 20px 24px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.v2-breadcrumbs a { color: var(--color-text-muted); }
.v2-breadcrumbs a:hover { color: var(--color-accent); }

.v2-page-head {
  padding: 32px 0 16px;
}

.v2-page-head h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 40px);
}

.v2-page-head p {
  margin: 0;
  color: var(--color-text-muted);
}

.v2-content-page {
  padding: 16px 0 64px;
}

.v2-content {
  max-width: 820px;
  line-height: 1.7;
}

.v2-content--product {
  max-width: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.v2-content--product table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

.v2-content--product table[width],
.v2-content--product td[width],
.v2-content--product th[width] {
  width: auto !important;
  max-width: none;
}

.v2-content--product td,
.v2-content--product th {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
}

.v2-content-page .v2-content {
  max-width: none;
}

.v2-empty {
  grid-column: 1 / -1;
  color: var(--color-text-muted);
}

/* Catalog mega menu */
.v2-catalog-menu {
  position: fixed;
  inset: 0;
  z-index: 250;
}

.v2-catalog-menu__panel {
  position: absolute;
  top: 168px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, calc(100% - 32px));
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.v2-catalog-menu__col h3 {
  margin: 0 0 12px;
  color: #fff;
  font-size: 16px;
}

.v2-catalog-menu__col h3 a {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.v2-catalog-menu__col h3 img {
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1);
}

.v2-catalog-menu__col ul li {
  margin-bottom: 8px;
}

.v2-catalog-menu__col a {
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
}

.v2-catalog-menu__col a:hover {
  color: var(--color-accent);
}

/* Search modal */
.v2-search-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px;
}

.v2-search-modal__backdrop,
.v2-cart-panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.v2-search-modal__box {
  position: relative;
  width: min(640px, 100%);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.v2-search-modal__head,
.v2-cart-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.v2-search-modal__head h2,
.v2-cart-panel__head h2 {
  margin: 0;
  font-size: 22px;
}

.v2-search-modal__head button,
.v2-cart-panel__head button {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.v2-search-modal__form {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
}

.v2-search-modal__form input,
.v2-search-modal__form select,
.v2-checkout-form input,
.v2-checkout-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font: inherit;
}

.v2-search-results {
  margin-top: 16px;
  max-height: 360px;
  overflow: auto;
}

.v2-search-result {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  color: inherit;
}

.v2-search-result:hover {
  color: var(--color-accent);
}

.v2-search-result img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* Cart panel */
.v2-cart-panel {
  position: fixed;
  inset: 0;
  z-index: 255;
}

.v2-cart-panel__drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.v2-cart-panel__body {
  flex: 1;
  overflow: auto;
  padding: 0 20px;
}

.v2-cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.v2-cart-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.v2-cart-item__title {
  font-weight: 600;
  margin: 0 0 4px;
  font-size: 14px;
}

.v2-cart-item__price {
  color: var(--color-accent);
  font-weight: 700;
}

.v2-cart-item__qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.v2-cart-item__qty button {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.v2-cart-panel__foot {
  padding: 20px;
  border-top: 1px solid var(--color-border);
}

.v2-cart-panel__total {
  margin-bottom: 12px;
  font-size: 18px;
}

.v2-btn--block {
  display: block;
  width: 100%;
  text-align: center;
}

.v2-cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.v2-cart-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Catalog page */
.v2-catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.v2-filter-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-size: 14px;
}

.v2-filter-chip:hover {
  background: var(--color-accent);
  color: #fff;
}

.v2-catalog-page {
  padding: 0 0 64px;
}

/* Product page */
.v2-product-page {
  padding: 16px 0 64px;
}

.v2-product-page__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.v2-product-gallery__main {
  background: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.v2-product-gallery__main img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin: 0 auto;
}

.v2-product-gallery__thumbs {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.v2-product-gallery__thumb {
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

.v2-product-gallery__thumb.active {
  border-color: var(--color-accent);
}

.v2-product-gallery__thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
}

.v2-product__price--lg {
  font-size: 28px;
  margin: 16px 0;
}

.v2-product-page__desc h2 {
  margin-top: 32px;
}

.v2-product-page__desc {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.v2-attrs-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

.v2-attrs-table th,
.v2-attrs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.v2-attrs-table th {
  width: 40%;
  color: var(--color-text-muted);
}

/* Cart / checkout pages */
.v2-cart-page,
.v2-checkout-page {
  padding: 0 0 64px;
}

.v2-cart-table {
  width: 100%;
  border-collapse: collapse;
}

.v2-cart-table th,
.v2-cart-table td {
  padding: 14px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.v2-cart-summary {
  margin-top: 24px;
  max-width: 360px;
  margin-left: auto;
}

.v2-checkout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.v2-checkout-form label {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
}

.v2-checkout-order {
  background: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.v2-checkout-order ul {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.v2-checkout-order li {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.v2-article-hero-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.v2-blog--page {
  padding-bottom: 64px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .v2-catalog-menu__panel {
    grid-template-columns: 1fr;
    top: 120px;
    max-height: calc(100vh - 140px);
    overflow: auto;
  }

  .v2-search-modal__form {
    grid-template-columns: 1fr;
  }

  .v2-product-page__grid,
  .v2-checkout-grid {
    grid-template-columns: 1fr;
  }

  .v2-cart-table thead {
    display: none;
  }

  .v2-cart-table tbody tr {
    display: block;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .v2-cart-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border: none;
    text-align: right;
  }

  .v2-cart-table tbody td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    text-align: left;
  }

  .v2-cart-table tbody td:first-child {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 4px;
  }

  .v2-cart-table tbody td:first-child::before,
  .v2-cart-table tbody td:last-child::before {
    display: none;
  }

  .v2-cart-table tbody td:last-child {
    justify-content: center;
    padding-top: 12px;
  }

  .v2-cart-table tbody td button {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    font: inherit;
  }

  .v2-cart-table tbody td input[type="number"] {
    min-height: 44px;
    min-width: 72px;
    font-size: 16px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }

  .v2-cart-summary {
    max-width: none;
    margin-left: 0;
    padding-bottom: max(80px, calc(56px + env(safe-area-inset-bottom, 0px) + 24px));
  }

  .v2-cart-page,
  .v2-checkout-page {
    padding-bottom: max(96px, calc(56px + env(safe-area-inset-bottom, 0px) + 32px));
  }
}
