/* ═════════════════════════════════════════════════════════════════════════
 * UNIVERSAL CHAT AI & EMPATHIC LISTENER — LUXURY GLASSMORPHISM STYLESHEET
 * ═════════════════════════════════════════════════════════════════════════ */
:root {
  --u-chat-primary: #10b981;
  --u-chat-secondary: #0284c7;
  --u-chat-bg: rgba(15, 23, 42, 0.95);
  --u-chat-border: rgba(255, 255, 255, 0.12);
  --u-chat-text: #f8fafc;
  --u-chat-muted: #94a3b8;
}

.u-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--u-chat-primary), var(--u-chat-secondary));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  z-index: 999990;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.u-chat-trigger:hover {
  transform: scale(1.08);
}

.u-chat-pulse {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--u-chat-primary);
  animation: u-chat-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes u-chat-ping {
  75%, 100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.u-chat-online-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid #0b0f19;
  border-radius: 50%;
}

.u-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--u-chat-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--u-chat-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  z-index: 999999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.u-chat-collapsed {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.u-chat-header {
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--u-chat-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.u-chat-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.u-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--u-chat-primary), var(--u-chat-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.u-chat-title {
  color: var(--u-chat-text);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.u-chat-subtitle {
  color: var(--u-chat-muted);
  font-size: 11px;
}

.u-chat-btn-icon {
  background: transparent;
  border: none;
  color: var(--u-chat-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.u-chat-btn-icon:hover {
  color: #ffffff;
}

.u-chat-pills {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  scrollbar-width: none;
}

.u-chat-pills::-webkit-scrollbar {
  display: none;
}

.u-chat-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--u-chat-border);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.u-chat-pill:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--u-chat-primary);
  color: #ffffff;
}

.u-chat-history {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.u-chat-msg {
  display: flex;
}

.u-chat-user {
  justify-content: flex-end;
}

.u-chat-bot {
  justify-content: flex-start;
}

.u-chat-bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.u-chat-user .u-chat-bubble {
  background: linear-gradient(135deg, var(--u-chat-primary), var(--u-chat-secondary));
  color: #ffffff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.u-chat-bot .u-chat-bubble {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border-bottom-left-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.u-chat-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.u-chat-action-btn {
  display: block;
  text-align: center;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.u-chat-btn-checkout {
  background: #10b981;
  color: #ffffff;
}

.u-chat-btn-whatsapp {
  background: #25d366;
  color: #ffffff;
}

.u-chat-btn-link, .u-chat-btn-legal, .u-chat-btn-lead_modal {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.u-chat-action-btn:hover {
  filter: brightness(1.1);
}

.u-chat-form {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--u-chat-border);
  display: flex;
  gap: 8px;
}

.u-chat-form input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--u-chat-border);
  border-radius: 10px;
  padding: 9px 14px;
  color: #ffffff;
  font-size: 13px;
  outline: none;
}

.u-chat-form input:focus {
  border-color: var(--u-chat-primary);
}

.u-chat-send {
  background: linear-gradient(135deg, var(--u-chat-primary), var(--u-chat-secondary));
  border: none;
  border-radius: 10px;
  color: #ffffff;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.u-chat-footer {
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 10px;
  color: var(--u-chat-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.u-chat-wa-direct {
  color: #25d366;
  text-decoration: none;
  font-weight: 600;
}

.u-chat-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  margin-right: 4px;
  animation: u-dots 1.4s infinite both;
}

.u-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.u-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes u-dots {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ==========================================================================
   MOBILE-FIRST ELEVATED POSITIONING (NON COPRE PARLA ED SOS CALMA)
   ========================================================================== */
@media (max-width: 768px) {
  .u-chat-trigger {
    bottom: calc(76px + env(safe-area-inset-bottom, 10px)) !important;
    right: 14px !important;
    width: 52px !important;
    height: 52px !important;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.65) !important;
  }
  .u-chat-window {
    bottom: calc(136px + env(safe-area-inset-bottom, 10px)) !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 155px) !important;
  }
}
