/* ============================================================
   ICA Chat Widget — Frontend Styles
   Scoped to #icaWidget to prevent any site style bleed
   ============================================================ */

#icaWidget,
#icaWidget * {
  box-sizing: border-box;
  font-family: 'DM Sans', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#icaWidget {
  position: fixed;
  z-index: 2147483647;
  bottom: 24px;
}

#icaWidget.ica-widget--bottom-right { right: 24px; }
#icaWidget.ica-widget--bottom-left  { left: 24px; }

/* ── Launcher ─────────────────────────────────────────────── */
.ica-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ica-primary, #6c63ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(108,99,255,0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  outline: none;
  z-index: 2;
}

.ica-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(108,99,255,0.6);
}
.ica-launcher:active { transform: scale(0.96); }

.ica-launcher-icon {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ica-launcher-icon .dashicons {
  font-size: 24px;
  width: 24px;
  height: 24px;
  line-height: 1;
  color: #fff;
}

.ica-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff4d6d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: ica-pulse-badge 2s infinite;
}

@keyframes ica-pulse-badge {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ── Chat Window ──────────────────────────────────────────── */
.ica-window {
  position: absolute;
  bottom: 72px;
  width: 380px;
  max-height: 580px;
  background: #13151c;
  border: 1px solid #2a2e3e;
  border-radius: 16px;
  display: none;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.ica-window.ica-open {
  display: flex;
  animation: ica-win-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.ica-widget--bottom-right .ica-window { right: 0; transform-origin: bottom right; }
.ica-widget--bottom-left  .ica-window { left: 0;  transform-origin: bottom left; }

@keyframes ica-win-in {
  from { opacity: 0; transform: scale(0.85) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

@media (max-width: 480px) {
  .ica-window {
    width: calc(100vw - 16px);
    max-height: 70vh;
  }
  #icaWidget.ica-widget--bottom-right { right: 8px; }
  #icaWidget.ica-widget--bottom-left  { left: 8px; }
}

/* ── Header ───────────────────────────────────────────────── */
.ica-window-header {
  background: linear-gradient(135deg, #1a1d26, #21253a);
  border-bottom: 1px solid #2a2e3e;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ica-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(108,99,255,0.2);
  border: 2px solid rgba(108,99,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ica-avatar-img { width: 100%; height: 100%; object-fit: cover; }

.ica-avatar-default {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ica-avatar-default .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
  color: #6c63ff;
}

.ica-header-info { flex: 1; min-width: 0; }
.ica-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #e8eaf0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ica-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #7b8198;
  margin-top: 2px;
}
.ica-status-dot {
  width: 7px;
  height: 7px;
  background: #00d4aa;
  border-radius: 50%;
  flex-shrink: 0;
  animation: ica-status-blink 2.5s infinite;
}
@keyframes ica-status-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.ica-header-actions { display: flex; gap: 4px; }

.ica-window .ica-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #7b8198;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ica-window .ica-icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #e8eaf0;
}
.ica-window .ica-icon-btn .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

/* ── Messages ─────────────────────────────────────────────── */
.ica-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ica-messages::-webkit-scrollbar { width: 4px; }
.ica-messages::-webkit-scrollbar-thumb { background: #2a2e3e; border-radius: 2px; }

.ica-message { display: flex; max-width: 88%; }
.ica-message--user      { align-self: flex-end; flex-direction: row-reverse; }
.ica-message--assistant { align-self: flex-start; }

.ica-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  max-width: 100%;
}
.ica-message--user .ica-bubble {
  background: var(--ica-primary, #6c63ff);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ica-message--assistant .ica-bubble {
  background: #1a1d26;
  color: #e8eaf0;
  border: 1px solid #2a2e3e;
  border-bottom-left-radius: 4px;
}

/* Typing dots */
.ica-typing .ica-bubble {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ica-dot {
  width: 7px; height: 7px;
  background: #7b8198;
  border-radius: 50%;
  animation: ica-bounce 1.2s infinite;
}
.ica-dot:nth-child(2) { animation-delay: 0.2s; }
.ica-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ica-bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.5; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* Action chip */
.ica-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(0,212,170,0.1);
  border: 1px solid rgba(0,212,170,0.3);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #00d4aa;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
  text-decoration: none;
}
.ica-action-chip:hover { background: rgba(0,212,170,0.2); }

/* ── Suggestions ──────────────────────────────────────────── */
.ica-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid #2a2e3e;
  flex-shrink: 0;
  background: #13151c;
  min-height: 0;
}
.ica-suggestion-chip {
  padding: 5px 10px;
  background: #1a1d26;
  border: 1px solid #2a2e3e;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: #7b8198;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ica-suggestion-chip:hover {
  background: #21253a;
  border-color: #6c63ff;
  color: #6c63ff;
}

/* ── Input area ───────────────────────────────────────────── */
.ica-input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  background: #1a1d26;
  border-top: 1px solid #2a2e3e;
  flex-shrink: 0;
}
.ica-chat-textarea {
  flex: 1;
  background: #13151c;
  border: 1px solid #2a2e3e;
  border-radius: 10px;
  color: #e8eaf0;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  padding: 8px 12px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
}
.ica-chat-textarea:focus  { border-color: #6c63ff; }
.ica-chat-textarea::placeholder { color: #4a5070; }

.ica-send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--ica-primary, #6c63ff);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  outline: none;
}
.ica-send-btn:hover    { background: #7d75ff; }
.ica-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ica-send-btn .dashicons { font-size: 18px; width: 18px; height: 18px; }

.ica-voice-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #2a2e3e;
  color: #7b8198;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  outline: none;
}
.ica-voice-btn:hover    { border-color: #6c63ff; color: #6c63ff; }
.ica-voice-btn.ica-recording { border-color: #ff4d6d; color: #ff4d6d; }
.ica-voice-btn .dashicons { font-size: 15px; width: 15px; height: 15px; }

/* ── Lead form ────────────────────────────────────────────── */
.ica-lead-form {
  background: #1a1d26;
  border-top: 1px solid #2a2e3e;
  padding: 16px;
  flex-shrink: 0;
}
.ica-lead-form-inner { display: flex; flex-direction: column; gap: 8px; }
.ica-lead-title { font-size: 13px; font-weight: 600; color: #e8eaf0; margin: 0 0 6px; }
.ica-lead-form .ica-input {
  background: #13151c;
  border: 1px solid #2a2e3e;
  border-radius: 8px;
  color: #e8eaf0;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.ica-lead-form .ica-input:focus { border-color: #6c63ff; }
.ica-lead-form .ica-input::placeholder { color: #4a5070; }

/* Buttons inside widget */
.ica-window .ica-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  width: 100%;
  outline: none;
}
.ica-window .ica-btn-teal  { background: var(--ica-secondary, #00d4aa); color: #0d0e12; }
.ica-window .ica-btn-ghost { background: transparent; color: #7b8198; border-color: #2a2e3e; }
.ica-window .ica-btn-sm    { padding: 6px 12px; font-size: 12px; }

/* ── Escalation bar ───────────────────────────────────────── */
.ica-escalation-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 14px;
  background: #0d0e12;
  border-top: 1px solid #2a2e3e;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ica-escalation-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #4a5070;
  text-decoration: none;
  transition: color 0.15s;
}
.ica-escalation-link:hover { color: #e8eaf0; }
.ica-escalation-link .dashicons { font-size: 13px; width: 13px; height: 13px; }

/* ── GDPR overlay ─────────────────────────────────────────── */
.ica-gdpr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,14,18,0.96);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ica-gdpr-box { text-align: center; }
.ica-gdpr-box p { color: #e8eaf0; font-size: 13px; margin: 0 0 12px; line-height: 1.6; }
.ica-gdpr-box strong { color: #fff; }
.ica-gdpr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.ica-gdpr-actions .ica-btn { width: auto; }
.ica-gdpr-actions .ica-btn-teal  { background: #00d4aa; color: #0d0e12; border: none; }
.ica-gdpr-actions .ica-btn-ghost { background: transparent; color: #7b8198; border: 1px solid #2a2e3e; }

/* ── Lead form note ───────────────────────────────────────── */
.ica-lead-note {
  font-size: 11px;
  color: #4a5070;
  margin: 0;
  line-height: 1.5;
}

/* ── Lead form v2 improvements ────────────────────────────── */
.ica-lead-subtitle {
  font-size: 12px;
  color: #7b8198;
  margin: 0 0 10px;
  line-height: 1.5;
}

.ica-lead-or {
  text-align: center;
  font-size: 11px;
  color: #4a5070;
  margin: 4px 0;
  position: relative;
}

.ica-lead-or::before,
.ica-lead-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: #2a2e3e;
}
.ica-lead-or::before { left: 0; }
.ica-lead-or::after  { right: 0; }

/* Highlight invalid fields */
.ica-lead-form .ica-input.ica-error {
  border-color: #ff4d6d !important;
  animation: ica-shake 0.3s ease;
}

@keyframes ica-shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ── SVG icon sizing (replaces dashicons) ─────────────────── */
#icaWidget svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.ica-launcher svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
  fill: none;
}

.ica-window .ica-icon-btn svg {
  width: 18px;
  height: 18px;
}

.ica-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
}

.ica-voice-btn svg {
  width: 16px;
  height: 16px;
}
.ica-voice-btn.ica-recording svg {
  stroke: #ff4d6d;
}

.ica-avatar-default svg {
  width: 20px;
  height: 20px;
  stroke: #6c63ff;
  fill: none;
}

.ica-escalation-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* WhatsApp icon uses fill not stroke */
.ica-escalation-link svg[fill="currentColor"] {
  stroke: none;
}
