/* ============================================================
   Meilisearch CODE-WP — Live Search Modal
   ============================================================ */

/* ── Trigger button ──────────────────────────────────────── */
.mscwp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  transition:
    background 0.15s,
    color 0.15s,
    opacity 0.15s;
  line-height: 1;
}

.mscwp-trigger:hover {
  opacity: 0.75;
}
input#mscwpLiveInput {
  margin: 0px;
}
button#mscwpClearInput {
  margin: 0px;
}
.mscwp-trigger-icon {
  display: block;
  flex-shrink: 0;
}
button.mscwp-modal-close {
  margin: 0px;
}
.mscwp-trigger-label {
  font-size: 14px;
  font-weight: 500;
}

/* ── Modal backdrop ──────────────────────────────────────── */
.mscwp-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
}

.mscwp-modal.is-open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
}

.mscwp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: mscwpFadeIn 0.2s ease;
}

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

/* ── Modal panel ─────────────────────────────────────────── */
.mscwp-modal-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.18),
    0 4px 16px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mscwpSlideDown 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes mscwpSlideDown {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header ──────────────────────────────────────────────── */
.mscwp-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.mscwp-modal-search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 0 12px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.mscwp-modal-search-box:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  background: #fff;
}

.mscwp-icon-search {
  color: #94a3b8;
  flex-shrink: 0;
}

.mscwp-modal-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-size: 16px !important;
  color: #0f172a !important;
  padding: 12px 0 !important;
  box-shadow: none !important;
  line-height: 1.4;
  min-width: 0;
}

.mscwp-modal-input::placeholder {
  color: #94a3b8;
}

.mscwp-input-clear {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.mscwp-input-clear:hover {
  background: #f1f5f9;
  color: #475569;
}
.mscwp-input-clear.visible {
  display: flex;
}

.mscwp-modal-close {
  background: none;
  border: none;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  width: 80px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

/* ── Filters ─────────────────────────────────────────────── */
.mscwp-filters {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mscwp-keyword-block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.mscwp-keyword-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.mscwp-keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mscwp-keyword-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0px 14px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}

.mscwp-keyword-chip:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
}

.mscwp-live-keyword-block {
  padding: 12px 16px 0;
}

.mscwp-live-keyword-block .mscwp-keyword-label {
  line-height: 34px;
}

.mscwp-live-keyword-chip {
  appearance: none;
  margin: 0;
  cursor: pointer;
}

.mscwp-filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #94a3b8;
  display: block;
  margin-bottom: 7px;
}

/* Category pills */
.mscwp-cat-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mscwp-cat-list.is-collapsed .mscwp-cat-btn-extra {
  display: none;
}

.mscwp-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1.5px solid transparent;
  border-radius: 5px;
  padding: 0px 10px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: 500;
  margin: 0px;
}
input#mscwpPriceMax,
input#mscwpPriceMin {
  margin: 0px;
}
.mscwp-cat-btn:hover {
  background: #e0e7ff;
  color: #3730a3;
}

.mscwp-cat-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.mscwp-cat-count {
  font-size: 11px;
  opacity: 0.7;
}

.mscwp-cat-toggle {
  margin: 8px 0 0;
  padding: 0;
  background: none;
  border: none;
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.mscwp-cat-toggle:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Price filter */
.mscwp-price-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: baseline;
}

.mscwp-price-input-wrap {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
  flex: 1;
  min-width: 100px;
  max-width: 160px;
}

.mscwp-price-input-wrap:focus-within {
  border-color: #3b82f6;
}

.mscwp-price-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  padding: 7px 10px !important;
  font-size: 13px !important;
  color: #1e293b !important;
  box-shadow: none !important;
  width: 100%;
  min-width: 0;
}

.mscwp-price-unit {
  padding: 0 8px 0 2px;
  font-size: 13px;
  color: #94a3b8;
  flex-shrink: 0;
}

.mscwp-price-sep {
  color: #cbd5e1;
  font-size: 14px;
  flex-shrink: 0;
}

.mscwp-price-reset {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 0px 12px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.mscwp-price-reset:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Price presets */
.mscwp-price-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mscwp-preset-btn {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 5px;
  padding: 0px 15px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: 500;
  margin: 0px;
}

.mscwp-preset-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}
.mscwp-preset-btn.active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

/* ── Results area ────────────────────────────────────────── */
.mscwp-results {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  min-height: 200px;
  scroll-behavior: smooth;
}

.mscwp-results::-webkit-scrollbar {
  width: 5px;
}
.mscwp-results::-webkit-scrollbar-track {
  background: transparent;
}
.mscwp-results::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 10px;
}

/* Idle state */
.mscwp-results-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #cbd5e1;
  gap: 10px;
}

.mscwp-results-idle p {
  margin: 0;
  font-size: 14px;
}

/* Loading */
.mscwp-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 10px;
  color: #94a3b8;
  font-size: 14px;
}

.mscwp-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: mscwpSpin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes mscwpSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Live result grid ────────────────────────────────────── */
.mscwp-live-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mscwp-live-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition:
    background 0.15s,
    transform 0.1s;
  border: 1px solid transparent;
}

.mscwp-live-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  transform: translateX(2px);
}

.mscwp-live-thumb {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mscwp-live-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s;
}

.mscwp-live-item:hover .mscwp-live-thumb img {
  transform: scale(1.05);
}

.mscwp-live-no-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mscwp-live-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mscwp-live-cat {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mscwp-live-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.4;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mscwp-live-item:hover .mscwp-live-title {
  color: #3b82f6;
}

.mscwp-live-price {
  font-size: 14px;
  font-weight: 700;
  color: #ef4444;
  margin-top: 2px;
}

.mscwp-live-arrow {
  color: #cbd5e1;
  flex-shrink: 0;
  transition:
    color 0.15s,
    transform 0.15s;
}

.mscwp-live-item:hover .mscwp-live-arrow {
  color: #3b82f6;
  transform: translateX(2px);
}

/* Empty state */
.mscwp-live-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  gap: 8px;
  color: #94a3b8;
}

.mscwp-live-empty span {
  font-size: 32px;
}
.mscwp-live-empty p {
  margin: 0;
  font-size: 14px;
}

/* ── Footer ──────────────────────────────────────────────── */
.mscwp-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: #fafafa;
}

#mscwpResultCount {
  font-size: 13px;
  color: #64748b;
}

.mscwp-view-all {
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.15s;
}

.mscwp-view-all:hover {
  color: #1d4ed8;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .mscwp-modal.is-open {
    padding: 0;
    align-items: flex-end;
  }

  .mscwp-modal-panel {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
  }

  .mscwp-price-inputs {
    flex-wrap: wrap;
  }
  .mscwp-price-input-wrap {
    max-width: 100%;
  }
}
