/* ════════════════════════════════════════════════════
   LEIB AI — Chat Widget
   Premium dark theme · Gold accents
   ════════════════════════════════════════════════════ */

:root {
  --lai-gold:        #C9A96E;
  --lai-gold-dim:    rgba(201,169,110,0.12);
  --lai-gold-border: rgba(201,169,110,0.28);
  --lai-bg:          #0c0c0c;
  --lai-surface:     rgba(255,255,255,0.045);
  --lai-text:        rgba(255,255,255,0.9);
  --lai-text-dim:    rgba(255,255,255,0.42);
  --lai-border:      rgba(255,255,255,0.07);
  --lai-radius:      20px;
  --lai-radius-msg:  14px;
}

/* ─── Root container ───────────────────────────── */
#leib-ai-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Trigger pill button ──────────────────────── */
#lai-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--lai-bg);
  border: 1px solid var(--lai-gold-border);
  color: var(--lai-gold);
  padding: 11px 17px 11px 13px;
  border-radius: 100px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(201,169,110,0.08);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
}

#lai-trigger::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(201,169,110,0.1) 0%, transparent 65%);
  opacity: 0;
  transition: opacity 0.25s;
}
#lai-trigger:hover::before { opacity: 1; }
#lai-trigger:hover {
  border-color: rgba(201,169,110,0.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.65), 0 0 24px rgba(201,169,110,0.1);
  transform: translateY(-1px);
}

/* Pulsing green online dot */
.lai-trigger-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.lai-trigger-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(74,222,128,0.3);
  animation: lai-pulse 2.2s ease-in-out infinite;
}
@keyframes lai-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.8); opacity: 0; }
}

.lai-trigger-arrow {
  opacity: 0.55;
  transition: transform 0.25s ease, opacity 0.2s;
  flex-shrink: 0;
}
#lai-trigger.lai-trigger-active .lai-trigger-arrow {
  transform: rotate(180deg);
  opacity: 0.8;
}

/* ─── Chat panel ───────────────────────────────── */
#lai-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 352px;
  height: 510px;
  background: var(--lai-bg);
  border: 1px solid var(--lai-gold-border);
  border-radius: var(--lai-radius);
  box-shadow: 0 32px 96px rgba(0,0,0,0.85), 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4,0,0.2,1),
              transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
#lai-panel.lai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── Header ───────────────────────────────────── */
.lai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 13px;
  border-bottom: 1px solid var(--lai-border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(201,169,110,0.055) 0%, transparent 100%);
}
.lai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A96E 0%, #7a5c30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #0c0c0c;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.lai-header-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--lai-text);
  letter-spacing: 0.05em;
}
.lai-header-sub {
  font-size: 10.5px;
  color: var(--lai-text-dim);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.lai-header-sub::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}
#lai-close {
  background: none;
  border: none;
  color: var(--lai-text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
#lai-close:hover {
  background: var(--lai-surface);
  color: var(--lai-text);
}

/* ─── Messages area ────────────────────────────── */
#lai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
#lai-messages::-webkit-scrollbar { width: 3px; }
#lai-messages::-webkit-scrollbar-track { background: transparent; }
#lai-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.09);
  border-radius: 10px;
}

/* ─── Message bubbles ──────────────────────────── */
.lai-msg {
  display: flex;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lai-msg.lai-msg-visible {
  opacity: 1;
  transform: translateY(0);
}
.lai-msg-bot  { justify-content: flex-start; }
.lai-msg-user { justify-content: flex-end; }

.lai-bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: var(--lai-radius-msg);
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}
.lai-msg-bot .lai-bubble {
  background: var(--lai-surface);
  color: var(--lai-text);
  border-radius: 3px var(--lai-radius-msg) var(--lai-radius-msg) var(--lai-radius-msg);
  border-left: 2px solid rgba(201,169,110,0.35);
}
.lai-msg-user .lai-bubble {
  background: var(--lai-gold-dim);
  color: var(--lai-text);
  border-radius: var(--lai-radius-msg) 3px var(--lai-radius-msg) var(--lai-radius-msg);
  border: 1px solid rgba(201,169,110,0.2);
}

/* ─── Typing indicator ─────────────────────────── */
.lai-typing-bubble {
  display: flex !important;
  align-items: center;
  gap: 5px;
  padding: 13px 16px !important;
  min-width: 54px;
  max-width: 64px !important;
}
.lai-typing-bubble span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(201,169,110,0.55);
  animation: lai-bounce 1.2s ease-in-out infinite;
}
.lai-typing-bubble span:nth-child(2) { animation-delay: 0.18s; }
.lai-typing-bubble span:nth-child(3) { animation-delay: 0.36s; }
@keyframes lai-bounce {
  0%,60%,100% { transform: translateY(0);   opacity: 0.4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* ─── Quick replies ────────────────────────────── */
#lai-quick-replies {
  padding: 2px 12px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.lai-quick-reply {
  background: transparent;
  border: 1px solid var(--lai-gold-border);
  color: var(--lai-gold);
  padding: 6px 13px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
}
.lai-quick-reply:hover {
  background: rgba(201,169,110,0.1);
  border-color: rgba(201,169,110,0.55);
  transform: translateY(-1px);
}
.lai-quick-reply:active { transform: translateY(0); }

/* ─── Input row ────────────────────────────────── */
.lai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 11px;
  border-top: 1px solid var(--lai-border);
  flex-shrink: 0;
}
#lai-input {
  flex: 1;
  background: var(--lai-surface);
  border: 1px solid var(--lai-border);
  border-radius: 100px;
  padding: 8px 14px;
  color: var(--lai-text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
#lai-input::placeholder { color: rgba(255,255,255,0.22); }
#lai-input:focus { border-color: rgba(201,169,110,0.4); }

#lai-send {
  width: 33px;
  height: 33px;
  background: var(--lai-gold);
  border: none;
  border-radius: 50%;
  color: #0c0c0c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
#lai-send:hover   { background: #d6b478; transform: scale(1.06); }
#lai-send:active  { transform: scale(0.95); }
#lai-send:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ─── Footer ───────────────────────────────────── */
.lai-footer {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.16);
  padding: 0 12px 9px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ─── Mobile ───────────────────────────────────── */
@media (max-width: 500px) {
  #leib-ai-root {
    bottom: 16px;
    right: 12px;
  }
  #lai-panel {
    position: fixed;
    bottom: 78px;
    left: 10px;
    right: 10px;
    width: auto;
    height: calc(100dvh - 110px);
    max-height: 540px;
  }
}

/* ─── Online dot en header ─────────────────────── */
.lai-online-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  margin-right: 2px;
}

/* ─── Action Cards ─────────────────────────────── */
.lai-card {
  width: 100%;
  max-width: calc(84%);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.lai-calendly-card {
  background: linear-gradient(135deg, rgba(201,169,110,0.15) 0%, rgba(201,169,110,0.06) 100%);
  border: 1px solid rgba(201,169,110,0.35);
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.lai-callback-card {
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25);
}

.lai-card-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.lai-card-body {
  flex: 1;
  min-width: 0;
}

.lai-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--lai-text);
  line-height: 1.3;
}

.lai-card-sub {
  font-size: 11.5px;
  color: var(--lai-text-dim);
  margin-top: 2px;
}

.lai-card-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  background: var(--lai-gold);
  color: #0c0c0c;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  border-radius: 100px;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.lai-card-btn:hover {
  background: #d6b478;
  transform: translateY(-1px);
}

/* ─── Notification badges ───────────────────────── */
.lai-badge {
  align-self: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  letter-spacing: 0.05em;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}
.lai-badge.lai-badge-visible {
  opacity: 1;
  transform: scale(1);
}
.lai-badge-saved {
  background: rgba(201,169,110,0.1);
  color: var(--lai-gold);
  border: 1px solid rgba(201,169,110,0.25);
}
.lai-badge-escalado {
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
}
