/* ===================================================================
   MODAL DE EXTRAS — grupos pastel, rejilla amplia y scroll estable
   =================================================================== */

:root {
  /* Verde Kasalia oscuro (chips / iconos) */
  --kasalia-extras-icon: #14532d;
  --kasalia-extras-icon-hover: #166534;
}

.advanced-filter-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1040px, 96vw);
  max-height: min(88vh, 780px);
  height: auto;
  background: #ffffff;
  border-radius: 18px;
  box-shadow:
    0 24px 64px rgba(15, 23, 42, 0.14),
    0 0 0 1px rgba(15, 23, 42, 0.06);
  display: none;
  flex-direction: column;
  flex-wrap: nowrap;
  z-index: 30000 !important;
  font-family: "Inter", sans-serif;
  overflow: hidden;
}
.advanced-filter-dialog.show {
  display: flex;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 29999 !important;
  display: none;
}
.dialog-overlay.show {
  display: block;
}

.dialog-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid #e8edf5;
  background: linear-gradient(185deg, #fafcff 0%, #ffffff 100%);
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-title svg {
  width: 22px;
  height: 22px;
  color: #10b981;
  flex-shrink: 0;
}

.close-dialog {
  appearance: none;
  background: transparent;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748b;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  padding: 0;
}
.close-dialog:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Área scroll: ocupa hueco entre cabecera modal y footer; scroll real */
.filter-sections.kasalia-extras-modal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 18px;
  scrollbar-gutter: stable;
}

.filter-sections.kasalia-extras-modal-scroll::-webkit-scrollbar {
  width: 10px;
}
.filter-sections.kasalia-extras-modal-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}
.filter-sections.kasalia-extras-modal-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  border-radius: 10px;
}

/* Toolbar fija al hacer scroll dentro del modal */
.kasalia-extras-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 14px 0 12px;
  margin: 0 0 6px;
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #ffffff 72%,
    rgba(255, 255, 255, 0.92) 100%
  );
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.kasalia-extras-groups-wrap {
  min-height: min-content;
  width: 100%;
  min-width: 0;
}

.kasalia-extras-intro {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: #0c4a6e;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.kasalia-extras-intro svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  color: #0284c7;
}
.kasalia-extras-intro p {
  margin: 0;
}

/* Fila: búsqueda + borrar selección (apaisada, rellena el ancho) */
.kasalia-extras-toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: 100%;
  margin-bottom: 10px;
}

.kasalia-extras-search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
  max-width: none;
  width: auto;
  margin-bottom: 0;
}

.kasalia-extras-btn-clear {
  flex: 0 0 auto;
  appearance: none;
  margin: 0;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: "Inter", sans-serif;
  cursor: pointer;
  white-space: nowrap;
  color: var(--kasalia-extras-icon);
  background: #f0fdf4;
  border: 1px solid #86efac;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.kasalia-extras-btn-clear:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: var(--kasalia-extras-icon-hover);
}
.kasalia-extras-btn-clear:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.25);
}
.kasalia-extras-search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
  pointer-events: none;
  z-index: 2;
}
.kasalia-extras-search {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  padding: 8px 12px 8px 36px !important;
  height: 38px !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  font-size: 13.5px !important;
  line-height: 1.2 !important;
  font-weight: 500 !important;
  font-family: "Inter", sans-serif !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  color: #1e293b !important;
  background: #fafbfc !important;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.kasalia-extras-search::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.kasalia-extras-search:focus {
  outline: none;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff !important;
}

.kasalia-extras-section-label {
  margin: 6px 0 0;
  flex: 1 1 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.kasalia-extras-section-label span:first-child {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

/*
 * Categorías: UNA columna a todo el ancho del modal (sin tarjetas a la izquierda
 * y hueco vacío a la derecha). Los chips van “apaisados” DENTRO de cada tarjeta.
 */
.kasalia-extras-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  width: 100%;
  max-width: 100%;
  padding: 6px 0 12px;
  box-sizing: border-box;
}

/* Tarjeta de grupo: ancho completo, apilada */
.kasalia-extras-section {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: #fdfefe;
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.06),
    0 10px 28px rgba(15, 23, 42, 0.05);
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}
.kasalia-extras-section:hover {
  border-color: #cbd5e1;
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.07),
    0 14px 32px rgba(15, 23, 42, 0.06);
}

.kasalia-extras-section.is-hidden {
  display: none !important;
}

/* Cabeceras con fondo pastel por categoría */
.kasalia-extras-section__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.kasalia-extras-section__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.kasalia-extras-section__title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex: 1 1 auto;
  line-height: 1.25;
}

.kasalia-extras-section__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

/* Variantes pastel (título / franja) */
.kasalia-extras-section--pastel-emerald .kasalia-extras-section__head {
  background: linear-gradient(135deg, #ecfdf5 0%, #a7f3d0 55%, #6ee7b7 100%);
}
.kasalia-extras-section--pastel-emerald .kasalia-extras-section__title {
  color: #065f46;
}
.kasalia-extras-section--pastel-emerald .kasalia-extras-section__icon {
  color: #047857;
}

.kasalia-extras-section--pastel-violet .kasalia-extras-section__head {
  background: linear-gradient(135deg, #f5f3ff 0%, #ddd6fe 60%, #c4b5fd 100%);
}
.kasalia-extras-section--pastel-violet .kasalia-extras-section__title {
  color: #5b21b6;
}
.kasalia-extras-section--pastel-violet .kasalia-extras-section__icon {
  color: #6d28d9;
}

.kasalia-extras-section--pastel-peach .kasalia-extras-section__head {
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 55%, #fdba74 100%);
}
.kasalia-extras-section--pastel-peach .kasalia-extras-section__title {
  color: #9a3412;
}
.kasalia-extras-section--pastel-peach .kasalia-extras-section__icon {
  color: #c2410c;
}

.kasalia-extras-section--pastel-sky .kasalia-extras-section__head {
  background: linear-gradient(135deg, #f0f9ff 0%, #bae6fd 55%, #7dd3fc 100%);
}
.kasalia-extras-section--pastel-sky .kasalia-extras-section__title {
  color: #075985;
}
.kasalia-extras-section--pastel-sky .kasalia-extras-section__icon {
  color: #0369a1;
}

.kasalia-extras-section--pastel-amber .kasalia-extras-section__head {
  background: linear-gradient(135deg, #fffbeb 0%, #fde68a 55%, #fcd34d 100%);
}
.kasalia-extras-section--pastel-amber .kasalia-extras-section__title {
  color: #92400e;
}
.kasalia-extras-section--pastel-amber .kasalia-extras-section__icon {
  color: #b45309;
}

.kasalia-extras-section--pastel-rose .kasalia-extras-section__head {
  background: linear-gradient(135deg, #fff1f2 0%, #fecdd3 55%, #fda4af 100%);
}
.kasalia-extras-section--pastel-rose .kasalia-extras-section__title {
  color: #9f1239;
}
.kasalia-extras-section--pastel-rose .kasalia-extras-section__icon {
  color: #be123c;
}

.kasalia-extras-section--pastel-coral .kasalia-extras-section__head {
  background: linear-gradient(135deg, #fff7ed 0%, #fecaca 55%, #fca5a5 100%);
}
.kasalia-extras-section--pastel-coral .kasalia-extras-section__title {
  color: #991b1b;
}
.kasalia-extras-section--pastel-coral .kasalia-extras-section__icon {
  color: #b91c1c;
}

.kasalia-extras-section--pastel-azure .kasalia-extras-section__head {
  background: linear-gradient(135deg, #eff6ff 0%, #bfdbfe 55%, #93c5fd 100%);
}
.kasalia-extras-section--pastel-azure .kasalia-extras-section__title {
  color: #1e3a8a;
}
.kasalia-extras-section--pastel-azure .kasalia-extras-section__icon {
  color: #1d4ed8;
}

.kasalia-extras-section--pastel-sage .kasalia-extras-section__head {
  background: linear-gradient(135deg, #f7fee7 0%, #d9f99d 55%, #bef264 100%);
}
.kasalia-extras-section--pastel-sage .kasalia-extras-section__title {
  color: #365314;
}
.kasalia-extras-section--pastel-sage .kasalia-extras-section__icon {
  color: #4d7c0f;
}

.kasalia-extras-section--pastel-stone .kasalia-extras-section__head {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 60%, #cbd5e1 100%);
}
.kasalia-extras-section--pastel-stone .kasalia-extras-section__title {
  color: #334155;
}
.kasalia-extras-section--pastel-stone .kasalia-extras-section__icon {
  color: #475569;
}

/* Destacados: mismo pastel esmeralda pero más énfasis */
.kasalia-extras-section.is-featured {
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.14),
    0 14px 36px rgba(16, 185, 129, 0.14);
}

/*
 * Rejilla de chips: columnas fluidas que rellenan cada fila al 100%
 * (auto-fill + minmax evita el “agujero” a la derecha dentro de la tarjeta).
 */
.kasalia-extras-section__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px 12px;
  padding: 14px 16px 16px;
  align-content: start;
  justify-items: stretch;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
}

.kasalia-extras-empty {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 18px;
  color: #64748b;
  text-align: center;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
}
.kasalia-extras-empty svg {
  color: #94a3b8;
}
.kasalia-extras-empty p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.kasalia-extra-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  justify-content: flex-start;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  background: #ffffff;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease,
    background 0.18s ease;
  position: relative;
}
.kasalia-extra-chip:hover {
  border-color: #94a3b8;
  background: #fafafa;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.kasalia-extra-chip.selected {
  border-color: #10b981;
  background: linear-gradient(145deg, #ecfdf5 0%, #d1fae5 100%);
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.2),
    0 4px 14px rgba(16, 185, 129, 0.18);
  color: #065f46;
}
.kasalia-extra-chip.selected .kasalia-extra-ic {
  color: #047857;
}
.kasalia-extra-chip .kasalia-extra-ic {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  color: var(--kasalia-extras-icon);
}
.kasalia-extra-chip:hover .kasalia-extra-ic {
  color: var(--kasalia-extras-icon-hover);
}
.kasalia-extra-chip span {
  line-height: 1.3;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kasalia-extra-chip.is-dimmed {
  opacity: 0.32;
  filter: grayscale(0.45);
  pointer-events: none;
}
.kasalia-extra-chip.is-hidden {
  display: none !important;
}

.kasalia-extras-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  margin-left: 8px;
}

.filter-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e8edf5;
  background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.filter-btn {
  appearance: none;
  border: none;
  padding: 11px 22px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: "Inter", sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.filter-btn.reset-filters {
  background: #ffffff;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.filter-btn.reset-filters:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}
.filter-btn.apply-filters {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.25);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
}
.filter-btn.apply-filters:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .advanced-filter-dialog {
    width: min(96vw, 100%);
    max-height: 92vh;
    border-radius: 14px;
  }

  .filter-sections.kasalia-extras-modal-scroll {
    padding: 0 12px 14px;
  }

  .kasalia-extras-grid {
    gap: 14px;
  }

  .kasalia-extras-section__grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
    gap: 8px 10px;
    padding: 12px 12px 14px;
  }

  .kasalia-extras-toolbar-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .kasalia-extras-btn-clear {
    width: 100%;
    text-align: center;
  }
}
