/**
 * biXci MercadoLibre Grid - Master CSS Stylesheet
 * Brand colors: Yellow #FFDB00, Royal Blue #0359B3, Neutral #F8FAFC, Success #00A650
 */

:root {
  --bixci-primary: #0359b3;
  --bixci-primary-hover: #024792;
  --bixci-primary-light: #f0f7ff;
  --bixci-yellow: #ffdb00;
  --bixci-yellow-dark: #e6c800;
  --bixci-green: #00a650;
  --bixci-green-light: #e6f7ee;
  --bixci-red: #e63946;
  --bixci-bg-app: #f8fafc;
  --bixci-bg-card: #ffffff;
  --bixci-text-main: #0f172a;
  --bixci-text-muted: #64748b;
  --bixci-border: #e2e8f0;
  --bixci-radius-card: 12px;
  --bixci-radius-btn: 8px;
  --bixci-shadow-card: 0 3px 12px -2px rgba(15, 23, 42, 0.06);
  --bixci-shadow-hover: 0 8px 24px -4px rgba(3, 89, 179, 0.14);
}

/* Fix legacy theme clearfix (Astra/WooCommerce ::before) occupying Grid Cell 1 */
ul.products::before,
ul.products::after,
.products::before,
.products::after,
.bixci-ml-products-grid::before,
.bixci-ml-products-grid::after {
  display: none !important;
  content: none !important;
}

/* Base Wrapper Reset & Layout */
.bixci-ml-wrapper {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", sans-serif;
  color: var(--bixci-text-main);
  background-color: transparent;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 12px;
  box-sizing: border-box;
}

/* 1. DYNAMIC FREE SHIPPING PROGRESS BAR */
.bixci-ml-shipping-bar-container {
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-left: 4px solid var(--bixci-yellow);
  border-radius: var(--bixci-radius-card);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: var(--bixci-shadow-card);
}

.bixci-ml-shipping-bar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.bixci-ml-shipping-icon {
  font-size: 16px;
}

.bixci-ml-shipping-text {
  flex: 1;
  color: var(--bixci-text-main);
}

.bixci-ml-shipping-pct-badge {
  background: var(--bixci-yellow);
  color: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
}

.bixci-ml-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bixci-border);
  border-radius: 4px;
  overflow: hidden;
}

.bixci-ml-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bixci-yellow) 0%, var(--bixci-green) 100%);
  border-radius: 4px;
  transition: width 0.4s ease-in-out;
}

/* 2. TOP QUICK-FILTER HORIZONTAL PILLS BAR */
.bixci-ml-quick-filters-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.bixci-ml-quick-filters-bar::-webkit-scrollbar {
  display: none;
}

.bixci-ml-pill-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bixci-text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.bixci-ml-pill-filter:hover {
  border-color: var(--bixci-primary);
  color: var(--bixci-primary);
  background: var(--bixci-primary-light);
}

.bixci-ml-pill-filter.active {
  background: var(--bixci-primary);
  color: #ffffff;
  border-color: var(--bixci-primary);
}

/* 3. SMART CONTROLS HEADER BAR */
.bixci-ml-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bixci-border);
  flex-wrap: wrap;
}

.bixci-ml-count-text {
  font-size: 12px;
  color: var(--bixci-text-muted);
  font-weight: 500;
}

.bixci-ml-controls-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bixci-ml-btn-open-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bixci-ml-btn-open-filters:hover {
  background: var(--bixci-primary-light);
  border-color: var(--bixci-primary);
  color: var(--bixci-primary);
}

.bixci-ml-filter-badge-count {
  background: var(--bixci-yellow);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bixci-ml-select-sort {
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  padding: 6px 24px 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bixci-text-main);
  cursor: pointer;
  outline: none;
  appearance: auto;
}

.bixci-ml-view-switcher {
  display: flex;
  background: var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  padding: 2px;
}

.bixci-ml-view-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--bixci-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.bixci-ml-view-btn.active,
.bixci-ml-view-btn:hover {
  background: #ffffff;
  color: var(--bixci-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 4. SLIDE-OUT FILTER PANEL DRAWER */
.bixci-ml-filter-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bixci-ml-filter-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bixci-ml-filter-drawer {
  position: fixed;
  top: 0;
  right: -340px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: #ffffff;
  z-index: 99999;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bixci-ml-filter-drawer.active {
  right: 0;
}

.bixci-ml-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--bixci-border);
}

.bixci-ml-drawer-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.bixci-ml-drawer-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--bixci-text-muted);
}

.bixci-ml-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.bixci-ml-filter-group {
  margin-bottom: 20px;
}

.bixci-ml-filter-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--bixci-text-main);
}

.bixci-ml-search-box {
  position: relative;
}

.bixci-ml-input-search {
  width: 100%;
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  font-size: 12px;
  box-sizing: border-box;
}

.bixci-ml-search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
}

.bixci-ml-price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bixci-ml-price-inputs input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  font-size: 12px;
  box-sizing: border-box;
}

.bixci-ml-brand-list {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bixci-ml-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.bixci-ml-checkbox-count {
  color: var(--bixci-text-muted);
  font-size: 11px;
}

.bixci-ml-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}

.bixci-ml-toggle-cb {
  display: none;
}

.bixci-ml-toggle-switch {
  width: 34px;
  height: 18px;
  background: var(--bixci-border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
}

.bixci-ml-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.bixci-ml-toggle-cb:checked + .bixci-ml-toggle-switch {
  background: var(--bixci-green);
}

.bixci-ml-toggle-cb:checked + .bixci-ml-toggle-switch::after {
  transform: translateX(16px);
}

.bixci-ml-drawer-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--bixci-border);
  display: flex;
  gap: 10px;
}

.bixci-ml-btn-reset-filters {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-btn);
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bixci-ml-btn-apply-filters {
  flex: 2;
  background: var(--bixci-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--bixci-radius-btn);
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* 5. PRODUCTS GRID LAYOUTS & TRANSITIONS */
.bixci-ml-products-grid {
  display: grid;
  gap: 12px;
  transition: all 0.3s ease;
}

/* 2-Column Mobile Default / 4-Column Desktop Default */
.bixci-ml-products-grid.view-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .bixci-ml-products-grid.view-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .bixci-ml-products-grid.view-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 1-Column Detailed List View */
.bixci-ml-products-grid.view-list {
  grid-template-columns: 1fr;
  gap: 12px;
}

/* PRODUCT CARD COMPONENT DESIGN (MercadoLibre Style) */
.bixci-ml-card {
  background: var(--bixci-bg-card);
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-card);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--bixci-shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bixci-ml-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--bixci-shadow-hover);
}

/* Badges Overlay */
.bixci-ml-badges-top {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.bixci-ml-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bixci-badge-discount {
  background: var(--bixci-yellow);
  color: #000000;
}

.bixci-badge-shipping {
  background: var(--bixci-green-light);
  color: var(--bixci-green);
  border: 1px solid var(--bixci-green);
}

.bixci-badge-stock {
  background: #fff0f0;
  color: var(--bixci-red);
}

/* Media Block & Hover Swipe Gallery */
.bixci-ml-media-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect ratio */
  background: #f1f5f9;
  overflow: hidden;
}

.bixci-ml-media-link {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bixci-ml-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.bixci-ml-gallery-dots {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 2;
}

.bixci-ml-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s ease;
}

.bixci-ml-dot.active {
  background: var(--bixci-primary);
  width: 12px;
  border-radius: 4px;
}

/* Card Content Body */
.bixci-ml-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.bixci-ml-trust-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
}

.bixci-ml-tag-express {
  color: var(--bixci-green);
}

.bixci-ml-tag-sales {
  color: var(--bixci-text-muted);
}

.bixci-ml-card-title {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.bixci-ml-card-title a {
  color: var(--bixci-text-main);
  text-decoration: none;
}

.bixci-ml-card-title a:hover {
  color: var(--bixci-primary);
}

/* Rating Row */
.bixci-ml-rating-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  margin-bottom: 8px;
}

.bixci-ml-stars {
  color: var(--bixci-yellow-dark);
  letter-spacing: -1px;
}

.bixci-ml-rating-num {
  font-weight: 700;
}

.bixci-ml-rating-count {
  color: var(--bixci-text-muted);
}

/* Pricing Block */
.bixci-ml-price-block {
  margin-top: auto;
  margin-bottom: 8px;
}

.bixci-ml-price-original {
  font-size: 11px;
  color: var(--bixci-text-muted);
  text-decoration: line-through;
  display: block;
}

.bixci-ml-price-current {
  font-size: 18px;
  font-weight: 800;
  color: var(--bixci-text-main);
  line-height: 1.1;
}

.bixci-ml-currency {
  font-size: 13px;
  margin-right: 2px;
}

.bixci-ml-financing-pill {
  display: inline-block;
  font-size: 10px;
  color: var(--bixci-green);
  font-weight: 600;
  margin-top: 2px;
}

/* Urgency Micro Counter */
.bixci-ml-urgency-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--bixci-text-muted);
  margin-bottom: 10px;
}

.bixci-ml-pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--bixci-green);
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(0, 166, 80, 0.4);
  animation: bixciPulse 1.8s infinite;
}

@keyframes bixciPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 166, 80, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(0, 166, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 166, 80, 0); }
}

/* Quick Action Cart Button */
.bixci-ml-action-button-wrapper {
  margin-top: 4px;
}

.bixci-ml-btn-quick-add {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bixci-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--bixci-radius-btn);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

.bixci-ml-btn-quick-add:hover {
  background: var(--bixci-primary-hover);
}

.bixci-ml-btn-quick-add.disabled {
  background: var(--bixci-border);
  color: var(--bixci-text-muted);
  cursor: not-allowed;
}

/* 1-COLUMN LIST VIEW CARD OVERRIDES */
.bixci-ml-products-grid.view-list .bixci-ml-card {
  flex-direction: row;
}

.bixci-ml-products-grid.view-list .bixci-ml-media-wrapper {
  width: 140px;
  min-width: 140px;
  padding-top: 0;
  height: 140px;
}

.bixci-ml-products-grid.view-list .bixci-ml-card-body {
  padding: 12px 16px;
}

/* SKELETON SHIMMER LOADERS */
.bixci-ml-skeletons-grid {
  display: grid;
  gap: 12px;
}

.bixci-ml-skeletons-grid.view-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .bixci-ml-skeletons-grid.view-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.bixci-ml-skeleton-card {
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: var(--bixci-radius-card);
  overflow: hidden;
  height: 280px;
  display: flex;
  flex-direction: column;
}

.bixci-ml-skel-img {
  height: 140px;
  width: 100%;
}

.bixci-ml-skel-body {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bixci-ml-skel-title { height: 14px; width: 85%; }
.bixci-ml-skel-line { height: 10px; width: 60%; }
.bixci-ml-skel-price { height: 20px; width: 40%; margin-top: auto; }
.bixci-ml-skel-btn { height: 32px; width: 100%; border-radius: 6px; }

.bixci-shimmer {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: bixciShimmer 1.5s infinite;
}

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

/* VARIATION SELECTION DRAWER MODAL */
.bixci-ml-variation-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bixci-ml-variation-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bixci-ml-variation-drawer {
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  max-width: 500px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  z-index: 99999;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.2);
  padding: 20px;
  transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bixci-ml-variation-drawer.active {
  bottom: 0;
}

.bixci-ml-drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bixci-border);
  margin-bottom: 14px;
}

.bixci-ml-drawer-thumb img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
}

.bixci-ml-drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.bixci-ml-attr-group {
  margin-bottom: 14px;
}

.bixci-ml-attr-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.bixci-ml-attr-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bixci-ml-attr-pill {
  background: #ffffff;
  border: 1px solid var(--bixci-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bixci-ml-attr-pill.selected {
  border-color: var(--bixci-primary);
  background: var(--bixci-primary-light);
  color: var(--bixci-primary);
  font-weight: 700;
}

.bixci-ml-btn-add-cart-drawer {
  width: 100%;
  background: var(--bixci-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--bixci-radius-btn);
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.bixci-ml-btn-add-cart-drawer:disabled {
  background: var(--bixci-border);
  color: var(--bixci-text-muted);
  cursor: not-allowed;
}

/* PAGINATION SENTINEL */
.bixci-ml-pagination-sentinel {
  text-align: center;
  padding: 20px;
}

.bixci-ml-loader-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--bixci-text-muted);
}

.bixci-ml-spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--bixci-border);
  border-top-color: var(--bixci-primary);
  border-radius: 50%;
  animation: bixciSpin 0.8s linear infinite;
}

@keyframes bixciSpin {
  100% { transform: rotate(360deg); }
}
