/* =========================================================
   Product Filters (Desktop + Mobile Drawer)
   Light Only + FIX:
   - Desktop: f-actions selalu tampil (static bottom)
   - Mobile: konten filter dapat discroll
   ========================================================= */

/* ========== Layout wrapper (tidak mengubah grid produk) ========== */
.product-archive.with-filters .pa-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.pa-main {
  flex: 1;
  min-width: 0;
}

/* =========================================================
   DESKTOP PANEL
   ========================================================= */
.pa-filters {
  width: 300px;
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 55%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  padding: 18px 18px 12px; /* bottom dikurangi karena f-actions punya padding sendiri */
  border-radius: 18px;
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px); /* tinggi stabil untuk inner scroll */
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: box-shadow 0.3s, background 0.4s;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* cegah double scroll, inner yang scroll */
}
.pa-filters::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  border-radius: 18px 0 0 18px;
  background: linear-gradient(180deg, #f59e0b 0%, #ffb53a 35%, #1d6ce0 100%);
}
.pa-filters.active {
  box-shadow: 0 8px 32px -4px rgba(15, 23, 42, 0.35);
}

/* Scroll area (desktop/mode shared) */
.filters-scroll {
  flex: 1;
  min-height: 0; /* wajib agar overflow terbaca dalam flex container */
  overflow: auto;
  padding-right: 6px;
  margin-right: -6px; /* kompensasi scrollbar */
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.filters-scroll::-webkit-scrollbar {
  width: 8px;
}
.filters-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 20px;
  border: 2px solid #f1f5f9;
}
.filters-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Heading */
.pa-filters h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.15;
  background: linear-gradient(90deg, #0f172a, #1d6ce0 60%, #0f172a);
  -webkit-background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: titleSheen 8s linear infinite;
}
@keyframes titleSheen {
  0% {
    background-position: 0 0;
  }
  50% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* Form groups */
.pa-filters .f-group {
  margin-bottom: 18px;
  position: relative;
}
.pa-filters label {
  display: block;
  font-weight: 600;
  margin: 0 0 6px;
  font-size: 13px;
  color: #0f172a;
  letter-spacing: 0.3px;
}

/* Inputs / selects */
.pa-filters input[type="text"],
.pa-filters input[type="number"],
.pa-filters select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  min-height: 34px;
  background: #ffffff;
  box-sizing: border-box;
  color: #0f172a;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.pa-filters select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230f172a' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 32px;
}
.pa-filters input[type="text"]:hover,
.pa-filters input[type="number"]:hover,
.pa-filters select:hover {
  border-color: #94b5ec;
}
.pa-filters input[type="text"]:focus,
.pa-filters input[type="number"]:focus,
.pa-filters select:focus {
  outline: none;
  border-color: #1d6ce0;
  box-shadow: 0 0 0 3px rgba(29, 108, 224, 0.25);
  background: #f8fbff;
}
.pa-filters .range {
  display: flex;
  gap: 10px;
}
.pa-filters .range input {
  flex: 1;
}
.pa-filters .hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 6px;
}

/* Spec blocks */
.f-specs {
  margin-top: 4px;
}
.spec-attr {
  margin: 0 0 14px;
  padding: 12px 12px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: linear-gradient(130deg, #ffffff 0%, #f7faff 85%);
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.4s;
}
.spec-attr.collapsed {
  padding-bottom: 8px;
}
.spec-attr.has-selected {
  border-color: #1d6ce0;
  box-shadow: 0 0 0 2px rgba(29, 108, 224, 0.15),
    0 2px 8px -2px rgba(29, 108, 224, 0.35);
  background: linear-gradient(135deg, #ffffff 0%, #e9f2ff 100%);
}
.spec-attr-title {
  font-weight: 600;
  margin: 0 0 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #0f172a;
  user-select: none;
}
.spec-attr-title .chevron {
  font-size: 10px;
  transition: transform 0.25s, opacity 0.25s;
  opacity: 0.65;
}
.spec-attr.collapsed .spec-attr-title .chevron {
  transform: rotate(-90deg);
  opacity: 0.5;
}

/* Spec options */
.spec-attr-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.spec-attr-options label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  border: 1px solid #d4dde7;
  padding: 6px 9px;
  border-radius: 30px;
  cursor: pointer;
  background: #f3f6fa;
  font-size: 12px;
  line-height: 1.1;
  transition: background 0.25s, border-color 0.25s, color 0.25s,
    box-shadow 0.25s;
  position: relative;
}
.spec-attr-options label:hover {
  background: #e8f1ff;
  border-color: #b1cff3;
}
.spec-attr-options input {
  margin: 0;
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.spec-attr-options label:has(input:checked) {
  background: linear-gradient(135deg, #1d6ce0 0%, #155ab8 100%);
  border-color: #1d6ce0;
  color: #ffffff;
  box-shadow: 0 2px 6px -1px rgba(29, 108, 224, 0.55);
}
.spec-attr-options label:has(input:checked)::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 6px;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25),
    0 0 0 7px rgba(29, 108, 224, 0.5);
  animation: pulseDot 1.9s ease-out infinite;
}
@keyframes pulseDot {
  0% {
    transform: scale(0.8);
    opacity: 0.9;
  }
  60% {
    transform: scale(1.4);
    opacity: 0.15;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.9;
  }
}

/* Badges */
.pa-filter-badges {
  margin: 0 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pa-filter-badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: linear-gradient(135deg, #eef4ff 0%, #e0edff 100%);
  border: 1px solid #b4cff3;
  padding: 5px 10px 5px 12px;
  border-radius: 22px;
  margin: 2px 4px 0 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: #0f172a;
  position: relative;
  overflow: hidden;
}
.pa-filter-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0)
  );
  transform: translateX(-100%);
  animation: badgeSheen 6s linear infinite;
}
@keyframes badgeSheen {
  0% {
    transform: translateX(-100%);
  }
  55% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(120%);
  }
}
.pa-filter-badge a.clear {
  text-decoration: none;
  color: #c02828;
  font-weight: 700;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.25s, color 0.25s;
}
.pa-filter-badge a.clear:hover {
  background: #ffeded;
  color: #a40000;
}
.pa-btn-filter {
  width: 100%;
}

/* =========================================================
   ACTIONS (DESKTOP) - STATIC BOTTOM
   ========================================================= */
.f-actions {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 0 4px;
  border-top: 1px solid #e2e8f0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #f1f5f9 70%);
  flex-shrink: 0;
}
.f-actions button {
  background: linear-gradient(135deg, #1d6ce0 0%, #155ab8 100%);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px -2px rgba(29, 108, 224, 0.45);
  transition: transform 0.25s, box-shadow 0.3s;
}
.f-actions button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 26px -4px rgba(29, 108, 224, 0.6);
}
.f-actions button:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 4px 14px -4px rgba(29, 108, 224, 0.55);
}
.f-actions .reset {
  font-size: 12px;
  text-decoration: none;
  color: #d92d2d;
  align-self: center;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.25s, color 0.25s;
}
.f-actions .reset:hover {
  background: #ffe6e6;
  color: #b80000;
  text-decoration: underline;
}
.pa-filters .close-drawer {
  display: none;
}

/* Form wrapper: flex container agar inner .filters-scroll bisa scroll di desktop */
.filter-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
   FILTER TOGGLE (MOBILE TRIGGER)
   ========================================================= */
.filter-toggle {
  display: none;
  margin: 0 0 14px;
  background: linear-gradient(135deg, #1d6ce0 0%, #155ab8 100%);
  color: #fff;
  border: none;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 14px -2px rgba(29, 108, 224, 0.55);
  position: relative;
  z-index: 100;
  transition: box-shadow 0.3s, transform 0.25s;
}
.filter-toggle:hover {
  box-shadow: 0 8px 26px -4px rgba(29, 108, 224, 0.6);
  transform: translateY(-2px);
}
.filter-toggle:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px -4px rgba(29, 108, 224, 0.55);
}
.filter-toggle .count-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #ffb43d 55%, #f59e0b 100%);
  color: #1d2b44;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px 4px;
  border-radius: 30px;
  margin-left: 8px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #1d6ce0;
}

/* Overlay (mobile) */
.pa-filters-overlay {
  display: none;
}

/* =========================================================
   MOBILE DRAWER
   ========================================================= */
@media (max-width: 768px) {
  .product-archive.with-filters .pa-layout {
    flex-direction: column;
    gap: 12px;
  }
  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .pa-filters-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 20, 45, 0.55);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.35s;
    display: block;
    pointer-events: none;
    backdrop-filter: blur(2px);
  }
  .pa-filters-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .pa-filters {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 92vh;
    height: auto;
    width: 100%;
    border-radius: 30px 30px 0 0;
    border: 1px solid #dbe4ef;
    padding: 26px 22px 0;
    z-index: 10000; /* di atas bottom-nav (9998) */
    transform: translateY(102%);
    transition: transform 0.55s cubic-bezier(0.68, -0.35, 0.25, 1);
    box-shadow: 0 -4px 40px -6px rgba(15, 23, 42, 0.45);
    overflow: hidden; /* outer hidden, inner scroll */
  }
  .pa-filters.active {
    transform: translateY(0);
  }

  /* Drag handle indicator */
  .pa-filters::after {
    content: "";
    display: block;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 4px;
  }
  body.filter-open {
    overflow: hidden;
    touch-action: none;
  }

  /* Restore mobile-friendly input sizes (prevent iOS zoom on focus) */
  .pa-filters input[type="text"],
  .pa-filters input[type="number"],
  .pa-filters select {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
  }
  .pa-filters select {
    padding-right: 32px;
  }

  .filters-scroll {
    flex: 1;
    overflow: auto;
    padding: 0 0 120px; /* ruang di atas bar actions */
    margin: 0;
    -webkit-overflow-scrolling: touch;
  }

  .pa-filters h2 {
    font-size: 19px;
    margin-bottom: 10px;
  }

  .pa-filters .close-drawer {
    display: block;
    position: absolute;
    right: 14px;
    top: 12px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    padding: 7px 14px;
    border: none;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 10px -2px rgba(220, 38, 38, 0.55);
    transition: transform 0.25s, box-shadow 0.3s;
    z-index: 99;
  }
  .pa-filters .close-drawer:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px -4px rgba(220, 38, 38, 0.6);
  }

  .spec-attr {
    border-radius: 18px;
  }
  .spec-attr-options label {
    font-size: 11px;
    padding: 5px 9px;
  }

  /* Actions fixed di viewport bawah */
  .f-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    border-top: 1px solid #d6dee8;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    background: #ffffffea;
    backdrop-filter: blur(6px);
    box-shadow: 0 -4px 22px -6px rgba(15, 23, 42, 0.25);
    justify-content: space-between;
    z-index: 10001; /* di atas pa-filters (10000) dan bottom-nav (9998) */
  }

  /* Sembunyikan bottom-nav saat filter drawer terbuka */
  body.filter-open .bottom-nav {
    display: none !important;
  }
  .f-actions button {
    flex: 1 1 auto;
    justify-content: center;
    padding: 14px 14px;
    font-size: 15px;
    border-radius: 14px;
  }
  .f-actions .reset {
    order: -1;
    font-size: 12px;
    padding: 2px 8px;
  }
}

/* Scrollbar (outer panel desktop only kept for compatibility) */
.pa-filters::-webkit-scrollbar {
  width: 0;
} /* disembunyikan karena inner yang scroll */

/* Utilities */
.hidden {
  display: none !important;
}
.gradient-text {
  background: linear-gradient(90deg, #1d6ce0, #155ab8, #1d6ce0);
  -webkit-background-clip: text;
  color: transparent;
  animation: titleSheen 10s linear infinite;
}
.glow-focus:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(29, 108, 224, 0.4) !important;
  border-color: #1d6ce0 !important;
}

/* Simple fade (opsional) */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
