/* ========== CV AI CHAT – FLYOUT PANEL ========== */

/* ---------- OVERLAY ---------- */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  touch-action: none;
  overscroll-behavior: none;
}
.ai-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- BODY LOCK ---------- */
html.ai-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.ai-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* ---------- PANEL ---------- */
.ai-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
  z-index: 9999;
  transition: right .35s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  font-family: 'Titillium Web', Helvetica, sans-serif;
  overscroll-behavior: none;
  touch-action: auto;
}
.ai-panel.open {
  right: 0;
}

/* ---------- HEADER ---------- */
.ai-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #2D2D2D;
  color: #fff;
  flex-shrink: 0;
}
.ai-hdr-back {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-hdr-back.vis {
  display: inline-block;
}
.ai-hdr-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #DF291E;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.ai-hdr-txt {
  flex: 1;
  min-width: 0;
}
.ai-hdr-t {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}
.ai-hdr-s {
  font-size: 12px;
  opacity: .75;
  line-height: 1.3;
}
.ai-hdr-x {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: .8;
  transition: opacity .15s;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-hdr-x:hover {
  opacity: 1;
}

/* ---------- STEP DOTS ---------- */
.ai-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.ai-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d0d0d0;
  transition: background .25s;
}
.ai-dot.on {
  background: #DF291E;
}
.ai-step-lbl {
  font-size: 12px;
  color: #666;
  margin-left: 6px;
  font-family: 'Titillium Web', Helvetica, sans-serif;
  font-weight: 600;
}

/* ---------- BODY (scrollable) ---------- */
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.ai-body::-webkit-scrollbar { width: 4px; }
.ai-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ---------- LOADING ---------- */
.ai-loading {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}
.ai-spin {
  width: 36px;
  height: 36px;
  border: 4px solid #e8e8e8;
  border-top-color: #DF291E;
  border-radius: 50%;
  animation: aiSpin .7s linear infinite;
}
@keyframes aiSpin {
  to { transform: rotate(360deg); }
}

/* ---------- MESSAGE BUBBLE ---------- */
.ai-msg {
  background: #f0f0f0;
  border-radius: 14px 14px 14px 4px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: #2D2D2D;
  margin-bottom: 16px;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* ---------- CATEGORY CARDS ---------- */
.ai-cats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.ai-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 8px;
  background: #fff;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  text-align: center;
}
.ai-cat:hover {
  border-color: #DF291E;
  box-shadow: 0 2px 12px rgba(223,41,30,0.12);
  transform: translateY(-2px);
}
.ai-cat-i {
  font-size: 28px;
  line-height: 1;
}
.ai-cat-n {
  font-size: 12px;
  font-weight: 600;
  color: #2D2D2D;
  line-height: 1.3;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* ---------- OPTION PILLS ---------- */
.ai-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.ai-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #2D2D2D;
  transition: border-color .2s, background .2s;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-opt:hover {
  border-color: #DF291E;
  background: rgba(223,41,30,0.04);
}
.ai-opt-i {
  font-size: 18px;
}

/* ---------- BUDGET BUTTONS ---------- */
.ai-budgets {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.ai-bud {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: #fff;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #2D2D2D;
  text-align: center;
  transition: border-color .2s, background .2s, color .2s;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-bud:hover {
  border-color: #DF291E;
  background: #DF291E;
  color: #fff;
}

/* ---------- PRODUCT RESULT CARDS ---------- */
.ai-recs {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 4px;
}
.ai-rec {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: relative;
}
.ai-rec-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 0 0 8px 0;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-badge.best {
  background: #DF291E;
  color: #fff;
}
.ai-rec-badge.value {
  background: #2D2D2D;
  color: #fff;
}
.ai-rec-badge.prem {
  background: linear-gradient(135deg, #2D2D2D, #505050);
  color: #fff;
}
.ai-rec-top {
  display: flex;
  gap: 12px;
  padding: 14px;
}
.ai-rec-img {
  width: 100px;
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  font-size: 32px;
}
.ai-rec-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ai-rec-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-rec-brand {
  font-size: 11px;
  font-weight: 700;
  color: #DF291E;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-title {
  font-size: 14px;
  font-weight: 700;
  color: #2D2D2D;
  line-height: 1.3;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* Product specs inside card */
.ai-rec-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 0 14px 8px;
}
.ai-rec-spec {
  font-size: 12px;
  color: #505050;
  line-height: 1.4;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-spec strong {
  font-weight: 600;
  color: #2D2D2D;
}

/* Price */
.ai-rec-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.ai-rec-old {
  font-size: 12px;
  color: #999;
  text-decoration: line-through;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-now {
  font-size: 16px;
  font-weight: 700;
  color: #2D2D2D;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-now.sale {
  color: #DF291E;
}
.ai-rec-now.inquiry {
  font-size: 14px;
  color: #DF291E;
  font-weight: 600;
}
.ai-rec-disc {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #DF291E;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* Why / reason */
.ai-rec-why {
  padding: 6px 14px 10px;
  font-size: 12px;
  color: #666;
  line-height: 1.45;
  border-top: 1px solid #f0f0f0;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* Card buttons */
.ai-rec-btns {
  display: flex;
  gap: 6px;
  padding: 0 14px 14px;
}
.ai-rec-inquiry {
  flex: 1;
  padding: 9px 10px;
  background: #DF291E;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
  text-align: center;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-inquiry:hover {
  opacity: .9;
}
.ai-rec-view {
  padding: 9px 14px;
  background: none;
  color: #2D2D2D;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-rec-view:hover {
  border-color: #DF291E;
  color: #DF291E;
}

/* ---------- ACTION CHIPS ---------- */
.ai-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.ai-act {
  padding: 8px 16px;
  background: #2D2D2D;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
.ai-act:hover {
  background: #DF291E;
}

/* ---------- CART CONFIRM TOAST ---------- */
.ai-cart-ok {
  background: #2D2D2D;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  animation: aiFadeIn .3s ease;
  font-family: 'Titillium Web', Helvetica, sans-serif;
}
@keyframes aiFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- FOOTER INPUT ---------- */
.ai-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e0e0e0;
  background: #fff;
  flex-shrink: 0;
}
.ai-inp {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  font-family: 'Titillium Web', Helvetica, sans-serif;
  transition: border-color .2s;
}
.ai-inp:focus {
  border-color: #DF291E;
}
.ai-send {
  width: 40px;
  height: 40px;
  background: #DF291E;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s;
  flex-shrink: 0;
}
.ai-send:hover {
  opacity: .85;
}
.ai-send svg {
  width: 18px;
  height: 18px;
}

/* ---------- HEADER TOGGLE BUTTON ---------- */
.ai-toggle-btn {
  display: inline-flex;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: none;
  border: none;
  position: relative;
  transition: opacity .2s;
}
.ai-toggle-btn:hover {
  opacity: .8;
}
.ai-toggle-btn .ai-toggle-icon {
  width: 24px;
  height: 24px;
}
.ai-toggle-btn .ai-toggle-label {
  font-family: 'Titillium Web', Helvetica, sans-serif;
  font-weight: 600;
  color: #fff;
  font-size: 16px;
  letter-spacing: 0.5px;
  line-height: 16px;
  white-space: nowrap;
}
.ai-toggle-pulse {
  position: absolute;
  top: 6px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: #DF291E;
  border-radius: 50%;
  animation: aiPulse 2s ease-in-out infinite;
}
@keyframes aiPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: .6; }
}

/* ---------- USER MESSAGE BUBBLE ---------- */
.ai-user-msg {
  margin: 12px 0;
  padding: 12px 16px;
  background: #DF291E;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 80%;
  margin-left: auto;
  text-align: right;
  word-wrap: break-word;
  animation: aiFadeIn .3s ease;
  box-shadow: 0 1px 4px rgba(223,41,30,0.25);
  font-family: 'Titillium Web', Helvetica, sans-serif;
}

/* ---------- MOBILE ---------- */
@media (max-width: 768px) {
  .ai-panel {
    width: 100%;
    right: -100%;
  }
  .ai-panel.open {
    right: 0;
  }
  .ai-toggle-btn .ai-toggle-label {
    display: none;
  }
  .ai-cats {
    grid-template-columns: repeat(2, 1fr);
  }
  .ai-rec-specs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .ai-cats {
    grid-template-columns: 1fr;
  }
}
