/* =========================================
   Royal Bangle House – Pro Filter Styles
   Tamil Nadu Digital | v1.0.0
   ========================================= */

:root {
  --rbh-primary: #0000CD;
  --rbh-primary-light: #1a1aee;
  --rbh-accent: #0000CD;
  --rbh-dark: #1a1a1a;
  --rbh-text: #333;
  --rbh-muted: #777;
  --rbh-border: #dde3ef;
  --rbh-bg: #f4f6fb;
  --rbh-white: #ffffff;
  --rbh-panel-w: 340px;
  --rbh-radius: 10px;
  --rbh-shadow: 0 8px 40px rgba(0,0,205,0.15);
  --rbh-transition: 0.28s cubic-bezier(.4,0,.2,1);
}

/* ── WRAPPER ── */
#rbh-filter-wrapper {
  position: relative;
  margin-bottom: 20px;
}

/* ── TOP BAR ── */
#rbh-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rbh-border);
  flex-wrap: wrap;
}

.rbh-filter-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rbh-filter-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Filter Toggle Button */
.rbh-filter-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--rbh-primary);
  color: var(--rbh-white);
  border: none;
  padding: 10px 20px;
  border-radius: var(--rbh-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background var(--rbh-transition), transform 0.15s;
  white-space: nowrap;
}
.rbh-filter-toggle-btn:hover {
  background: var(--rbh-primary-light);
  transform: translateY(-1px);
}

.rbh-active-count {
  background: var(--rbh-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Active filter tags */
.rbh-active-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rbh-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8eafa;
  color: var(--rbh-primary);
  border: 1px solid #c0c8f0;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px 4px 12px;
  cursor: pointer;
  transition: background var(--rbh-transition);
}
.rbh-tag:hover { background: #d5dbf5; }
.rbh-tag svg { flex-shrink: 0; }

.rbh-result-count {
  font-size: 13px;
  color: var(--rbh-muted);
  white-space: nowrap;
}

.rbh-clear-all {
  background: none;
  border: 1px solid var(--rbh-border);
  color: var(--rbh-muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--rbh-transition);
  white-space: nowrap;
}
.rbh-clear-all:hover {
  border-color: var(--rbh-primary);
  color: var(--rbh-primary);
}

/* ── OVERLAY ── */
.rbh-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  backdrop-filter: blur(2px);
  animation: rbhFadeIn 0.25s ease;
}
.rbh-overlay.active { display: block; }

@keyframes rbhFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── FILTER PANEL ── */
.rbh-filter-panel {
  position: fixed;
  top: 0;
  left: -100%;
  width: var(--rbh-panel-w);
  max-width: 90vw;
  height: 100vh;
  background: var(--rbh-white);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: var(--rbh-shadow);
  transition: left var(--rbh-transition);
  overflow: hidden;
}
.rbh-filter-panel.open {
  left: 0;
}

/* Panel Header */
.rbh-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--rbh-border);
  background: var(--rbh-bg);
  flex-shrink: 0;
}
.rbh-panel-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--rbh-dark);
  letter-spacing: -0.2px;
}

.rbh-close-panel {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--rbh-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--rbh-transition), background var(--rbh-transition);
}
.rbh-close-panel:hover {
  color: var(--rbh-primary);
  background: #e8eafa;
}

/* Panel Body */
.rbh-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.rbh-panel-body::-webkit-scrollbar { width: 4px; }
.rbh-panel-body::-webkit-scrollbar-thumb { background: var(--rbh-border); border-radius: 4px; }

/* ── FILTER SECTIONS ── */
.rbh-filter-section {
  border-bottom: 1px solid var(--rbh-border);
}

.rbh-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--rbh-dark);
  text-align: left;
  transition: background var(--rbh-transition);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.rbh-section-toggle:hover { background: var(--rbh-bg); }
.rbh-section-toggle span:first-child { flex: 1; }

.rbh-chevron {
  transition: transform var(--rbh-transition);
  color: var(--rbh-muted);
  flex-shrink: 0;
}
.rbh-section-toggle.collapsed .rbh-chevron {
  transform: rotate(-90deg);
}

.rbh-section-content {
  padding: 0 22px 16px;
  overflow: hidden;
}
.rbh-section-content.collapsed {
  display: none;
}

/* Search Box */
.rbh-search-box {
  margin-bottom: 12px;
}
.rbh-search-input {
  width: 100%;
  border: 1px solid var(--rbh-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--rbh-dark);
  outline: none;
  background: var(--rbh-bg);
  box-sizing: border-box;
  transition: border-color var(--rbh-transition);
}
.rbh-search-input:focus {
  border-color: var(--rbh-primary);
  background: #fff;
}

/* ── CATEGORY CHECKBOXES ── */
.rbh-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.rbh-checkbox-list::-webkit-scrollbar { width: 3px; }
.rbh-checkbox-list::-webkit-scrollbar-thumb { background: var(--rbh-border); border-radius: 3px; }

.rbh-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--rbh-transition);
  user-select: none;
}
.rbh-checkbox-item:hover { background: var(--rbh-bg); }
.rbh-checkbox-item input[type="checkbox"] { display: none; }

.rbh-checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--rbh-border);
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  transition: all var(--rbh-transition);
  background: #fff;
}
.rbh-checkbox-item input:checked + .rbh-checkmark {
  background: var(--rbh-primary);
  border-color: var(--rbh-primary);
}
.rbh-checkbox-item input:checked + .rbh-checkmark::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.rbh-label {
  flex: 1;
  font-size: 13.5px;
  color: var(--rbh-text);
}
.rbh-checkbox-item input:checked ~ .rbh-label {
  color: var(--rbh-primary);
  font-weight: 600;
}

.rbh-count {
  font-size: 11px;
  color: var(--rbh-muted);
  background: var(--rbh-bg);
  border-radius: 10px;
  padding: 2px 7px;
}

/* ── COLOR — text only (same as category) ── */
.rbh-color-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.rbh-color-grid::-webkit-scrollbar { width: 3px; }
.rbh-color-grid::-webkit-scrollbar-thumb { background: var(--rbh-border); }

.rbh-color-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--rbh-transition);
  user-select: none;
}
.rbh-color-item:hover { background: var(--rbh-bg); }
.rbh-color-item input[type="checkbox"] { display: none; }

/* reuse same checkmark as category */
.rbh-color-item .rbh-checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--rbh-border);
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  transition: all var(--rbh-transition);
  background: #fff;
}
.rbh-color-item input:checked + .rbh-checkmark {
  background: var(--rbh-primary);
  border-color: var(--rbh-primary);
}
.rbh-color-item input:checked + .rbh-checkmark::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.rbh-color-name {
  flex: 1;
  font-size: 13.5px;
  color: var(--rbh-text);
}
.rbh-color-item input:checked ~ .rbh-color-name {
  color: var(--rbh-primary);
  font-weight: 600;
}

/* ── SIZE BUTTONS ── */
.rbh-size-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rbh-size-item {
  cursor: pointer;
  user-select: none;
}
.rbh-size-item input[type="checkbox"] { display: none; }

.rbh-size-btn {
  display: block;
  padding: 8px 16px;
  border: 1.5px solid var(--rbh-border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--rbh-text);
  background: #fff;
  transition: all var(--rbh-transition);
  white-space: nowrap;
  min-width: 52px;
  text-align: center;
}
.rbh-size-item:hover .rbh-size-btn {
  border-color: var(--rbh-primary);
  color: var(--rbh-primary);
}
.rbh-size-item input:checked + .rbh-size-btn {
  background: var(--rbh-primary);
  border-color: var(--rbh-primary);
  color: #fff;
  font-weight: 600;
}

/* ── PANEL FOOTER ── */
.rbh-panel-footer {
  display: flex;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--rbh-border);
  background: var(--rbh-bg);
  flex-shrink: 0;
}

.rbh-reset-btn {
  flex: 0 0 auto;
  padding: 12px 18px;
  background: none;
  border: 1.5px solid var(--rbh-border);
  border-radius: var(--rbh-radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--rbh-muted);
  cursor: pointer;
  transition: all var(--rbh-transition);
}
.rbh-reset-btn:hover {
  border-color: var(--rbh-primary);
  color: var(--rbh-primary);
}

.rbh-apply-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  background: var(--rbh-primary);
  color: #fff;
  border: none;
  border-radius: var(--rbh-radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: background var(--rbh-transition), transform 0.12s;
  position: relative;
  overflow: hidden;
}
.rbh-apply-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
}
.rbh-apply-btn:hover {
  background: var(--rbh-primary-light);
  transform: translateY(-1px);
}
.rbh-apply-btn:active { transform: translateY(0); }

.rbh-apply-count {
  background: rgba(255,255,255,0.25);
  border-radius: 12px;
  font-size: 12px;
  padding: 2px 8px;
  font-weight: 700;
}

/* ── PRODUCT GRID (AJAX results) ── */
#rbh-products-wrapper .products {
  transition: opacity 0.25s ease;
}
#rbh-products-wrapper.loading .products {
  opacity: 0.4;
  pointer-events: none;
}

/* ════════════════════════════════════════
   FORCE 2 COL GRID — override all themes
   ════════════════════════════════════════ */

/* Reset WC float system completely */
.woocommerce ul.products::before,
.woocommerce ul.products::after,
.woocommerce-page ul.products::before,
.woocommerce-page ul.products::after,
ul.products::before,
ul.products::after {
  display: none !important;
  content: none !important;
}

.woocommerce ul.products,
.woocommerce-page ul.products,
ul.products {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
  list-style: none !important;
  float: none !important;
  clear: both !important;
  width: 100% !important;
}

/* Every product li — must fill the grid cell */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
ul.products li.product {
  float: none !important;
  clear: none !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
}

/* Product link wrapper — fill card */
.woocommerce ul.products li.product a.woocommerce-loop-product__link,
ul.products li.product a.woocommerce-loop-product__link {
  display: block !important;
  width: 100% !important;
}

/* ALL images inside product cards — force full width square */
.woocommerce ul.products li.product img,
.woocommerce-page ul.products li.product img,
ul.products li.product img,
.woocommerce ul.products li.product .woocommerce-loop-product__link img,
ul.products li.product .attachment-woocommerce_thumbnail,
ul.products li.product .wp-post-image {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Product title fix — no letter-spacing wrap issue */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
ul.products li.product h2,
ul.products li.product .woocommerce-loop-product__title {
  font-size: 12.5px !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
  padding: 6px 10px 2px !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* Price fix */
.woocommerce ul.products li.product .price,
ul.products li.product .price {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: var(--rbh-primary) !important;
  padding: 0 10px 10px !important;
  display: block !important;
}

/* Category label fix */
.woocommerce ul.products li.product .woocommerce-loop-category__title,
ul.products li.product .ast-woo-product-category {
  font-size: 10px !important;
  letter-spacing: 0 !important;
  word-break: normal !important;
}

/* ── Desktop: 3 cols (tablet), 4 cols (PC) ── */
@media (min-width: 768px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products,
  ul.products {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }
  .woocommerce ul.products li.product .woocommerce-loop-product__title,
  ul.products li.product .woocommerce-loop-product__title {
    font-size: 14px !important;
  }
}
@media (min-width: 1024px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products,
  ul.products {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 18px !important;
  }
}

/* ── AJAX rendered grid (after filter apply) ── */
#rbh-products-wrapper ul.products.rbh-ajax-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 12px !important;
  padding: 0 !important;
  list-style: none !important;
}
@media (min-width: 768px) {
  #rbh-products-wrapper ul.products.rbh-ajax-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (min-width: 1024px) {
  #rbh-products-wrapper ul.products.rbh-ajax-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

#rbh-products-wrapper .rbh-ajax-grid li.product {
  background: #fff;
  border: 1px solid var(--rbh-border);
  border-radius: var(--rbh-radius);
  overflow: hidden;
  float: none !important;
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#rbh-products-wrapper .rbh-ajax-grid li.product:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,205,0.1);
}
#rbh-products-wrapper .rbh-ajax-grid li.product a {
  display: block;
  color: inherit;
  text-decoration: none;
}
#rbh-products-wrapper .rbh-ajax-grid li.product img {
  width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  display: block !important;
  min-height: 0 !important;
}
#rbh-products-wrapper .rbh-ajax-grid .rbh-product-info {
  padding: 8px 10px 10px;
}
#rbh-products-wrapper .rbh-ajax-grid .woocommerce-loop-product__title {
  font-size: 12.5px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 4px;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
}
#rbh-products-wrapper .rbh-ajax-grid .price {
  font-size: 13px;
  font-weight: 700;
  color: var(--rbh-primary);
  display: block;
}
#rbh-products-wrapper .rbh-ajax-grid .rbh-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #e8eefa;
  color: #0000a0;
  font-weight: 600;
  margin-bottom: 5px;
}

/* ── SKELETON LOADER ── */
#rbh-loading {
  margin-top: 20px;
}
.rbh-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}
.rbh-skeleton-card {
  border-radius: var(--rbh-radius);
  overflow: hidden;
  background: #f5f5f5;
}
.rbh-skeleton-img {
  width: 100%;
  padding-top: 100%;
  background: linear-gradient(90deg, #ececec 25%, #f8f8f8 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: rbhShimmer 1.4s infinite;
}
.rbh-skeleton-line {
  height: 14px;
  margin: 12px 12px 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ececec 25%, #f8f8f8 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: rbhShimmer 1.4s infinite 0.1s;
}
.rbh-skeleton-line.short {
  width: 60%;
  margin-bottom: 14px;
}
@keyframes rbhShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── NO RESULTS ── */
.rbh-no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--rbh-muted);
}
.rbh-no-results svg {
  display: block;
  margin: 0 auto 16px;
  opacity: 0.35;
}
.rbh-no-results h4 {
  font-size: 18px;
  color: var(--rbh-dark);
  margin: 0 0 8px;
}
.rbh-no-results p { margin: 0; font-size: 14px; }

/* ── HIDDEN FILTER UTILITY ── */
.rbh-item-hidden { display: none !important; }

/* ── MOBILE BOTTOM BAR — hidden, using inline bar instead ── */
#rbh-mobile-bottom-bar {
  display: none !important;
}

/* ── RESPONSIVE ── */
@media (max-width: 767px) {
  #rbh-filter-bar {
    display: flex;
    padding: 10px 0;
  }

  .rbh-filter-panel {
    width: 100%;
    max-width: 100%;
    top: 0;
    left: -100%;
    height: 100vh;
    border-radius: 0;
    transition: left var(--rbh-transition);
  }
  .rbh-filter-panel.open {
    left: 0;
    bottom: auto;
  }

  .rbh-skeleton-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rbh-active-tags {
    display: none;
  }
}
