/* MOTO ELITE 3000 - Catalog Styles */
:root {
  --brand-red: #cc1414;
  --brand-dark: #0d0d12;
  --brand-dark-sub: #1a1a24;
  --neutral-50: #f8f8fb;
  --neutral-200: #e4e4ea;
  --neutral-500: #6b6b80;
  --neutral-700: #3a3a48;
  --neutral-900: #161620;
  --success: #16a34a;
  --warning: #a16207;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--neutral-50);
  color: var(--neutral-900);
  padding-bottom: 80px; /* space for floating cart button */
}

/* Header */
.site-header {
  background: var(--brand-dark);
  color: white;
  padding: 10px 12px 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.brand-logo {
  height: 32px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  flex-shrink: 0;
  background: white;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.brand-text {
  min-width: 0;
  display: none; /* Hide redundant text since logo has company name */
}
.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--brand-red);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text .subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--neutral-200);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vendedor-badge {
  display: inline-block;
  margin-top: 4px;
  background: var(--brand-red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
/* 手机窄屏：徽章显示在 brand 下一行 */
@media (max-width: 639px) {
  .brand-text {
    display: block !important;
  }
  .brand-text h1 { display: none; }
  .brand-text .subtitle { display: none; }
  .vendedor-badge { font-size: 10px; padding: 2px 6px; }
}
@media (min-width: 640px) {
  .brand-text { display: block; }
  .brand-text .subtitle { display: block; }
}

/* Cart toggle in top-right */
.cart-toggle {
  background: var(--brand-red);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  font-weight: 700;
  transition: transform 0.1s;
  box-shadow: var(--shadow-sm);
}
.cart-toggle:active { transform: scale(0.95); }
.cart-toggle .cart-icon {
  flex-shrink: 0;
}
.cart-toggle .cart-count {
  background: white;
  color: var(--brand-red);
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 900;
  min-width: 20px;
  text-align: center;
}
.cart-toggle .cart-total {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.cart-toggle.empty .cart-count {
  display: none;
}

.search-box {
  margin-top: 8px;
}
.search-box input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  background: white;
  color: var(--neutral-900);
}
.search-box input:focus {
  outline: 2px solid var(--brand-red);
}

/* Category Nav — now inside header */
.category-nav {
  margin: 8px -12px -8px;
  padding: 8px 12px;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--brand-dark-sub);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }
.cat-link {
  display: inline-block;
  padding: 5px 10px;
  margin-right: 4px;
  color: var(--neutral-200);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  transition: all 0.15s;
}
.cat-link.active,
.cat-link:hover {
  background: var(--brand-red);
  color: white;
}

/* Product Grid */
main {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
}
@media (min-width: 640px) {
  main { grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px; }
}
@media (min-width: 900px) {
  main { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
  main { grid-template-columns: repeat(5, 1fr); }
}

/* Product Card */
.product-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.1s;
  display: flex;
  flex-direction: column;
}
.product-card.hidden { display: none; }
.product-card:has(.qty-input:not([value="0"])) {
  box-shadow: 0 0 0 2px var(--brand-red), var(--shadow-md);
}

.product-image {
  background: #e9e9ef;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;     /* 显示完整图，不裁切（避免摩配零件细节被切掉） */
  display: block;
  background: white;       /* contain 会留白，给个白底好看 */
  padding: 6%;             /* 源图常紧贴边缘，留内边距避免视觉截断 */
  box-sizing: border-box;
}
.product-image.no-image,
.product-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 18px;
  color: var(--neutral-500);
  background: linear-gradient(135deg, #e9e9ef 0%, #d4d4dc 100%);
  text-align: center;
  padding: 8px;
}

.product-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.product-code-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.product-code {
  font-size: 14px;
  font-weight: 900;
  color: var(--brand-red);
  letter-spacing: 0.02em;
}
.product-unit {
  font-size: 10px;
  color: var(--neutral-500);
  font-style: italic;
  white-space: nowrap;
  background: var(--neutral-50);
  padding: 1px 6px;
  border-radius: 10px;
}
.product-name {
  font-size: 11px;
  color: var(--neutral-700);
  line-height: 1.3;
  min-height: 28px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Primary price (USD amount paid at BCV rate) */
.price-primary {
  font-size: 12px;
  color: var(--neutral-700);
  margin: 4px 0 2px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}
.price-primary strong {
  color: var(--brand-red);
  font-size: 16px;
  font-weight: 900;
}
.price-primary-note {
  font-size: 10px;
  color: var(--neutral-500);
  font-weight: 600;
  font-style: italic;
}

/* Reference prices list (4 other options - single column, full width) */
.price-refs {
  list-style: none;
  margin: 0 0 6px;
  padding: 6px 8px;
  background: var(--neutral-50);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}
.price-ref {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  color: var(--neutral-700);
  line-height: 1.3;
}
.price-ref.is-credit {
  color: var(--warning);
}
.price-ref .ref-label {
  font-weight: 600;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.price-ref .ref-value {
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
  font-size: 11px;
}
.price-ref.is-credit .ref-value {
  color: var(--warning);
}

/* Quantity Control */
.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 6px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutral-50);
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: white;
  font-size: 18px;
  font-weight: bold;
  color: var(--brand-red);
  cursor: pointer;
  flex-shrink: 0;
}
.qty-btn:active {
  background: var(--neutral-200);
}
.qty-input {
  flex: 1;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--neutral-900);
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* (Floating cart removed - cart toggle is now in header top-right) */

/* Checkout Panel */
.checkout-panel {
  position: fixed;
  inset: 0;
  background: var(--neutral-50);
  z-index: 300;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
.checkout-panel.open { display: flex; }

.checkout-header {
  background: var(--brand-dark);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.checkout-logo {
  height: 28px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  background: white;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.checkout-header h2 {
  margin: 0;
  flex: 1;
  font-size: 16px;
  color: white;
  font-weight: 700;
}
#closeCheckout {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.cart-items {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}
.cart-item {
  background: white;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 8px 12px;
  box-shadow: var(--shadow-sm);
}
.cart-item-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--neutral-200);
  flex-shrink: 0;
}
.cart-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: white;
}
.cart-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 11px;
  color: var(--neutral-500);
  background: linear-gradient(135deg, #e9e9ef 0%, #d4d4dc 100%);
  padding: 4px;
  text-align: center;
  line-height: 1.1;
}
.cart-item-info {
  min-width: 0;
}
.cart-item-code {
  font-weight: 900;
  color: var(--brand-red);
  font-size: 14px;
}
.cart-item-name {
  font-size: 12px;
  color: var(--neutral-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item-price {
  font-size: 11px;
  color: var(--neutral-500);
  margin-top: 2px;
}
.cart-item-price strong {
  color: var(--brand-red);
  font-size: 13px;
  font-weight: 700;
}
.cart-item-discounts {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
}
.cart-discount-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--neutral-700);
}
.cart-discount-row .disc-label {
  color: var(--neutral-500);
  font-weight: 600;
}
.cart-discount-row .disc-value {
  color: var(--success);
  font-weight: 700;
}
.cart-discount-row.is-credit .disc-value {
  color: var(--warning);
}
.cart-discount-row .disc-save {
  color: var(--success);
  font-size: 9px;
  font-style: italic;
  margin-left: 4px;
}
.cart-item-unit-badge {
  display: inline-block;
  font-size: 9px;
  color: var(--neutral-500);
  background: var(--neutral-50);
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 6px;
  font-style: italic;
}
.cart-item-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.cart-item-qty-ctrl {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutral-50);
}
.cart-item-qty-ctrl .qty-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
}
.cart-item-qty-ctrl .qty-input {
  width: 40px;
  font-size: 13px;
}
.cart-item-subtotal {
  font-size: 12px;
  color: var(--success);
  font-weight: 700;
}
.unit-note {
  font-size: 9px;
  color: var(--neutral-500);
  font-weight: 500;
  font-style: italic;
}
.cart-item-remove {
  background: transparent;
  border: none;
  color: var(--neutral-500);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
}
.cart-empty {
  text-align: center;
  color: var(--neutral-500);
  padding: 40px 20px;
}

/* Payment Options */
.payment-options {
  padding: 16px;
  background: white;
  border-top: 2px solid var(--neutral-200);
}
.payment-options h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--neutral-900);
}
.payment-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .payment-grid { grid-template-columns: repeat(5, 1fr); }
}
.payment-card {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 300px;
}
.payment-card .pay-select-btn {
  margin-top: auto;
}
.payment-card[data-is-credit="1"] {
  background: #fff9ea;
  border-color: #f0d38a;
}
.pay-label {
  font-size: 11px;
  font-weight: bold;
  color: var(--neutral-700);
  text-transform: uppercase;
}
.pay-discount {
  font-size: 11px;
  color: var(--success);
  font-weight: 700;
}
.pay-breakdown {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px 8px;
  background: white;
  border-radius: var(--radius-sm);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pay-breakdown li {
  display: flex;
  justify-content: space-between;
  color: var(--neutral-700);
  line-height: 1.3;
}
.pay-breakdown li span:first-child {
  color: var(--neutral-500);
}
.pay-breakdown .pay-subtotal {
  color: var(--neutral-900);
  font-weight: 600;
}
.pay-breakdown .pay-discount-amount {
  color: var(--success);
  font-weight: 700;
}
.pay-breakdown .pay-shipping {
  color: var(--neutral-500);
  font-style: italic;
  font-size: 10px;
}
.payment-card[data-is-credit="1"] .pay-breakdown .pay-discount-amount {
  color: var(--warning);
}
.pay-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 8px;
  border-top: 2px solid var(--neutral-200);
  margin-top: 4px;
}
.pay-total-label {
  font-size: 10px;
  color: var(--neutral-700);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.pay-total {
  font-size: 16px;
  font-weight: 900;
  color: var(--brand-red);
}
.pay-select-btn {
  background: var(--brand-red);
  color: white;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
}
.pay-select-btn:active { opacity: 0.85; }
.pay-select-btn.full-width { width: 100%; padding: 12px; font-size: 14px; }
.pay-select-btn:disabled,
.pay-select-btn[disabled] {
  background: var(--neutral-200);
  color: var(--neutral-500);
  cursor: not-allowed;
}

/* Single-card summary (retail / vip layouts) */
.payment-grid.single-card {
  grid-template-columns: 1fr;
  max-width: 480px;
  margin: 0 auto;
}
.payment-card.single {
  min-height: auto;
  background: white;
  border: 2px solid var(--brand-red);
}
.payment-card.single .pay-label {
  font-size: 14px;
  color: var(--brand-red);
}
.payment-card.single .pay-total {
  font-size: 22px;
}

/* Min-order warning */
.min-order-note {
  margin: 8px 0 12px;
  padding: 8px 12px;
  font-size: 12px;
  background: #f0f4f8;
  border-radius: var(--radius-sm);
  color: var(--neutral-700);
}
.min-order-note.warning,
.min-order-hint.warning {
  background: #fff5e0;
  color: #b45309;
  font-weight: 700;
  border-left: 3px solid #f59e0b;
}

/* "Consultar precio" placeholder for VIP missing MAYOR price */
.price-primary.price-consult {
  color: var(--neutral-500);
  font-style: italic;
  font-size: 13px;
  font-weight: 600;
}
.credit-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--warning);
  background: #fff9ea;
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
.credit-note strong {
  color: #7a4d00;
}

/* Payment card sub-text showing unit price context */
.payment-card .pay-hint {
  font-size: 9px;
  color: var(--neutral-500);
  font-style: italic;
  margin-top: 2px;
}
.payment-card[data-is-credit="1"] .pay-hint {
  color: var(--warning);
}

/* No-price summary */
.no-price-summary {
  padding: 16px;
  background: white;
  border-top: 2px solid var(--neutral-200);
  text-align: center;
}
.no-price-summary p {
  margin: 8px 0;
  font-size: 14px;
}
