/* =============================================================
   WowCodes — fake live chat widget
   ============================================================= */

.wc-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, #ffc233, var(--amber));
  color: #0d0d0d;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(240,165,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.wc-chat-launcher:hover { transform: scale(1.06); box-shadow: 0 12px 34px rgba(240,165,0,0.55); }
.wc-chat-launcher:active { transform: scale(0.96); }

.wc-chat-badge {
  position: absolute; top: -2px; right: -2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #e0392c; color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg, #0d0d0d);
  font-family: 'DM Sans', sans-serif;
}

.wc-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 1200;
  width: min(376px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 140px));
  background: var(--bg2, #141414);
  border: 0.5px solid var(--border2, rgba(255,255,255,.13));
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-family: 'DM Sans', sans-serif;
}
.wc-chat-panel.open {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: all;
}

.wc-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 0.5px solid var(--border, rgba(255,255,255,.07));
  flex-shrink: 0;
  background: radial-gradient(ellipse 220px 80px at 20% 0%, rgba(240,165,0,0.08), transparent 70%);
}
.wc-chat-head-info { display: flex; align-items: center; gap: 10px; }
.wc-chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--amber-bg2, rgba(240,165,0,.15));
  color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wc-chat-title { font-family: 'Fraunces', serif; font-size: 15px; color: var(--text); line-height: 1.3; }
.wc-chat-status { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.wc-dot { width: 6px; height: 6px; border-radius: 50%; background: #2ecc71; display: inline-block; box-shadow: 0 0 6px rgba(46,204,113,0.7); }

.wc-chat-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.wc-chat-close, .wc-chat-reset {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg3, #1a1a1a); border: 0.5px solid var(--border2);
  color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.wc-chat-close:hover { color: var(--text); background: var(--bg4, #222); }
.wc-chat-reset:hover { color: var(--amber); background: var(--amber-bg); }

.wc-chat-body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.wc-chat-body::-webkit-scrollbar { width: 6px; }
.wc-chat-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.wc-msg { display: flex; animation: wcMsgIn 0.2s ease both; }
@keyframes wcMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.wc-msg-bot { justify-content: flex-start; }
.wc-msg-user { justify-content: flex-end; }

.wc-bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px; line-height: 1.5;
  /* AI replies (chat.php) can legitimately contain line breaks — e.g.
     listing per-plan values one per line — and textContent (never
     innerHTML, see chat-widget.js) preserves them as real \n characters.
     Without this, the default 'normal' white-space would collapse them
     into a run-on line. */
  white-space: pre-wrap;
}
.wc-msg-bot .wc-bubble {
  background: var(--bg3, #1a1a1a);
  border: 0.5px solid var(--border, rgba(255,255,255,.07));
  color: var(--text2);
  border-bottom-left-radius: 4px;
}
.wc-msg-user .wc-bubble {
  background: linear-gradient(135deg, #ffc233, var(--amber));
  color: #1a1300;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.wc-typing { padding: 12px 14px; display: flex; align-items: center; gap: 4px; }
.wc-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3);
  animation: wcTypingDot 1.1s infinite ease-in-out;
}
.wc-typing span:nth-child(2) { animation-delay: 0.15s; }
.wc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wcTypingDot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.wc-options {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 2px;
}
.wc-opt {
  display: block;
  text-align: start;
  background: transparent;
  border: 0.5px solid var(--border2, rgba(255,255,255,.13));
  color: var(--text2);
  font-size: 12.5px; font-family: 'DM Sans', sans-serif;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.wc-opt:hover { background: var(--amber-bg); border-color: var(--amber); color: var(--text); }
.wc-opt-disabled, .wc-opt:disabled { opacity: 0.4; pointer-events: none; }

.wc-chat-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px;
  border-top: 0.5px solid var(--border, rgba(255,255,255,.07));
  flex-shrink: 0;
}
.wc-chat-menu-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg3, #1a1a1a); border: 0.5px solid var(--border2);
  color: var(--text2); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.wc-chat-menu-btn:hover { color: var(--amber); background: var(--amber-bg); }

#wc-chat-input {
  flex: 1; min-width: 0;
  background: var(--bg3, #1a1a1a);
  border: 0.5px solid var(--border2, rgba(255,255,255,.13));
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px; color: var(--text);
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
#wc-chat-input:focus { border-color: var(--amber); }
#wc-chat-input::placeholder { color: var(--text3); }
#wc-chat-input:disabled { opacity: 0.6; cursor: not-allowed; }

.wc-chat-send {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #ffc233, var(--amber));
  color: #0d0d0d; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.15s, transform 0.1s;
}
.wc-chat-send:hover { filter: brightness(1.08); }
.wc-chat-send:active { transform: scale(0.94); }
.wc-chat-send:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.wc-chat-peek {
  position: fixed;
  right: 86px; bottom: 34px;
  z-index: 1199;
  max-width: 240px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2, #141414);
  border: 0.5px solid var(--border2, rgba(255,255,255,.13));
  border-radius: 14px;
  padding: 11px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px; color: var(--text2);
  box-shadow: 0 14px 34px rgba(0,0,0,0.45);
  opacity: 0; transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  cursor: pointer;
}
.wc-chat-peek.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.wc-peek-dismiss {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg3, #1a1a1a); border: none; color: var(--text3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  order: 2;
}
.wc-peek-dismiss:hover { color: var(--text); }
.wc-peek-text { order: 1; line-height: 1.4; }

/* Mirrors the widget for ar/ur — wc_html_attrs() (includes/i18n.php) puts
   dir="rtl" on <html> for those locales. Everything here is physically
   positioned (right/left), never logical properties, so RTL needs explicit
   overrides rather than falling out automatically. */
html[dir="rtl"] .wc-chat-launcher,
html[dir="rtl"] .wc-chat-panel { right: auto; left: 22px; }
html[dir="rtl"] .wc-chat-badge { right: auto; left: -2px; }
html[dir="rtl"] .wc-chat-peek { right: auto; left: 86px; }
html[dir="rtl"] .wc-msg-bot { justify-content: flex-end; }
html[dir="rtl"] .wc-msg-user { justify-content: flex-start; }
html[dir="rtl"] .wc-msg-bot .wc-bubble { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
html[dir="rtl"] .wc-msg-user .wc-bubble { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }

@media (max-width: 700px) {
  .wc-chat-peek { right: 12px; left: 12px; max-width: none; bottom: calc(160px + env(safe-area-inset-bottom)); }
}

@media (max-width: 700px) {
  .wc-chat-launcher { right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); }
  .wc-chat-panel {
    right: 12px; left: 12px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: auto;
    height: min(70vh, 560px);
  }
  html[dir="rtl"] .wc-chat-launcher { right: auto; left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .wc-msg { animation: none; }
  .wc-chat-panel { transition: none; }
}
