/* =========================================================
   Twingital Affiliate Pro — Comparator Widget
   ========================================================= */

.tap-comparator {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  max-width: 100%;
  margin: 32px 0;
}

/* ─── Header ──────────────────────────────────────── */
.tap-cmp-header { margin-bottom: 20px; }

.tap-cmp-title {
  font-size: 22px;
  font-weight: 800;
  color: #1a1a1a;
  margin: 0 0 4px;
  line-height: 1.2;
}

.tap-cmp-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* ─── Category filter ─────────────────────────────── */
.tap-cmp-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tap-cmp-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}

.tap-cmp-cat-btn:hover { border-color: #FF6B35; color: #FF6B35; background: #fff8f5; }
.tap-cmp-cat-btn.active { border-color: #FF6B35; background: #FF6B35; color: #fff; }

/* ─── Search ──────────────────────────────────────── */
.tap-cmp-search-wrap { position: relative; margin-bottom: 16px; }

.tap-cmp-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #fff;
  transition: border-color .18s;
}

.tap-cmp-search-box:focus-within { border-color: #FF6B35; box-shadow: 0 0 0 3px rgba(255,107,53,.1); }

.tap-cmp-search-icon { font-size: 16px; flex-shrink: 0; }

.tap-cmp-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: #1a1a1a;
  background: transparent;
}

.tap-cmp-search-spinner { flex-shrink: 0; font-size: 14px; animation: tapSpin .8s linear infinite; }
@keyframes tapSpin { to { transform: rotate(360deg); } }

/* ─── Search results dropdown ─────────────────────── */
.tap-cmp-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 340px;
  overflow-y: auto;
}

.tap-cmp-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid #f5f5f5;
}

.tap-cmp-result-item:last-child { border-bottom: none; }
.tap-cmp-result-item:hover { background: #fff8f5; }
.tap-cmp-result-item.disabled { opacity: .4; cursor: not-allowed; }

.tap-cmp-result-img {
  width: 48px; height: 48px;
  object-fit: contain;
  border-radius: 6px;
  background: #f5f5f5;
  flex-shrink: 0;
}

.tap-cmp-result-img-placeholder {
  width: 48px; height: 48px;
  background: #f5f5f5;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.tap-cmp-result-info { flex: 1; min-width: 0; }
.tap-cmp-result-name { font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tap-cmp-result-meta { font-size: 12px; color: #888; display: flex; gap: 8px; flex-wrap: wrap; }

.tap-cmp-result-cat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f0f0f0;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  color: #555;
}

.tap-cmp-result-add {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #FF6B35;
  color: #fff;
  border: none;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}

.tap-cmp-result-add:hover { background: #e0541f; }

.tap-cmp-no-results { padding: 20px; text-align: center; color: #888; font-size: 14px; }

/* ─── Selected products ───────────────────────────── */
.tap-cmp-selected { margin-bottom: 16px; }

.tap-cmp-selected-label { font-size: 13px; color: #555; margin-bottom: 10px; font-weight: 600; }

.tap-cmp-chips { display: flex; flex-wrap: wrap; gap: 10px; }

.tap-cmp-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #FF6B35;
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 200px;
  animation: tapChipIn .2s ease;
}

@keyframes tapChipIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

.tap-cmp-chip-img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 4px;
  background: #f5f5f5;
  flex-shrink: 0;
}

.tap-cmp-chip-img-placeholder {
  width: 36px; height: 36px;
  background: #f5f5f5;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tap-cmp-chip-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tap-cmp-chip-remove {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}

.tap-cmp-chip-remove:hover { color: #e53e3e; }

.tap-cmp-hint { font-size: 13px; color: #aaa; padding: 16px; text-align: center; border: 1.5px dashed #e0e0e0; border-radius: 10px; }

/* ─── Actions ─────────────────────────────────────── */
.tap-cmp-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tap-cmp-compare-btn {
  background: #FF6B35;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .1s;
}

.tap-cmp-compare-btn:hover { background: #e0541f; transform: translateY(-1px); }
.tap-cmp-compare-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.tap-cmp-clear-btn {
  background: none;
  border: 1.5px solid #e0e0e0;
  color: #666;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .18s;
}

.tap-cmp-clear-btn:hover { border-color: #e53e3e; color: #e53e3e; }

/* ─── Results ─────────────────────────────────────── */
.tap-cmp-results { animation: tapFadeIn .3s ease; }
@keyframes tapFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tap-cmp-results-inner { overflow-x: auto; }

.tap-cmp-results-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.tap-cmp-new-search-btn {
  background: none;
  border: 1.5px solid #FF6B35;
  color: #FF6B35;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}

.tap-cmp-new-search-btn:hover { background: #FF6B35; color: #fff; }

/* ─── Loading overlay ─────────────────────────────── */
.tap-cmp-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: #555;
  font-size: 15px;
}

.tap-cmp-loading-spinner {
  width: 24px; height: 24px;
  border: 3px solid #f0f0f0;
  border-top-color: #FF6B35;
  border-radius: 50%;
  animation: tapSpin .7s linear infinite;
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  .tap-cmp-filters { gap: 6px; }
  .tap-cmp-cat-btn { font-size: 12px; padding: 5px 10px; }
  .tap-cmp-compare-btn { width: 100%; justify-content: center; display: flex; }
  .tap-cmp-actions { flex-direction: column; }
}

/* ─── Category dropdown (replaces button row) ─────── */
.tap-cmp-cat-dropdown-wrap {
  margin-bottom: 16px;
}

.tap-cmp-cat-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.tap-cmp-cat-select-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 360px;
}

.tap-cmp-cat-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 11px 40px 11px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}

.tap-cmp-cat-select:hover { border-color: #FF6B35; }
.tap-cmp-cat-select:focus { border-color: #FF6B35; box-shadow: 0 0 0 3px rgba(255,107,53,.12); }

.tap-cmp-cat-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #888;
  pointer-events: none;
}

/* ─── Pro gate ────────────────────────────────────── */
.tap-pro-gate {
  background: linear-gradient(135deg, #fff8f5 0%, #fff 100%);
  border: 2px solid #FF6B35;
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 24px 0;
}

.tap-pro-gate-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.tap-pro-gate-title {
  font-size: 22px;
  font-weight: 800;
  color: #1a1a1a;
  margin: 0 0 10px;
}

.tap-pro-gate-desc {
  font-size: 15px;
  color: #555;
  max-width: 480px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.tap-pro-gate-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  margin-bottom: 24px;
}

.tap-pro-gate-feat {
  font-size: 13px;
  color: #16a34a;
  font-weight: 600;
}

.tap-pro-gate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FF6B35;
  color: #fff !important;
  text-decoration: none !important;
  padding: 13px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  transition: background .18s, transform .1s;
}

.tap-pro-gate-btn:hover {
  background: #e0541f;
  transform: translateY(-1px);
}

/* ─── Elementor CSS custom properties theming ─────────── */
/* When Elementor passes --tap-primary etc., these override the defaults */
.tap-el-comparator-wrap .tap-cmp-title {
  color: var(--tap-title-color, #1a1a1a);
}

.tap-el-comparator-wrap .tap-cmp-subtitle {
  color: var(--tap-sub-color, #666);
}

.tap-el-comparator-wrap .tap-cmp-cat-select {
  border-color: var(--tap-search-brd, #e0e0e0);
}

.tap-el-comparator-wrap .tap-cmp-cat-select:hover,
.tap-el-comparator-wrap .tap-cmp-cat-select:focus {
  border-color: var(--tap-primary, #FF6B35);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tap-primary, #FF6B35) 15%, transparent);
}

.tap-el-comparator-wrap .tap-cmp-search-box {
  border-color: var(--tap-search-brd, #e0e0e0);
}

.tap-el-comparator-wrap .tap-cmp-search-box:focus-within {
  border-color: var(--tap-primary, #FF6B35);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tap-primary, #FF6B35) 15%, transparent);
}

.tap-el-comparator-wrap .tap-cmp-chip {
  border-color: var(--tap-primary, #FF6B35);
}

.tap-el-comparator-wrap .tap-cmp-compare-btn {
  background: var(--tap-primary, #FF6B35);
}

.tap-el-comparator-wrap .tap-cmp-result-add {
  background: var(--tap-primary, #FF6B35);
}

.tap-el-comparator-wrap .tap-cmp-new-search-btn {
  border-color: var(--tap-primary, #FF6B35);
  color: var(--tap-primary, #FF6B35);
}

.tap-el-comparator-wrap .tap-cmp-new-search-btn:hover {
  background: var(--tap-primary, #FF6B35);
  color: #fff;
}

.tap-el-comparator-wrap .tap-pro-gate {
  border-color: var(--tap-primary, #FF6B35);
}

.tap-el-comparator-wrap .tap-pro-gate-btn {
  background: var(--tap-primary, #FF6B35);
}
