/* ════════════════════════════════════════════════════════════════
   T2B CHATBOT WIDGET STYLES (Phase A: Atención & Phase B: Soporte IA)
   ════════════════════════════════════════════════════════════════ */

/* Floating Launcher Bubble */
.t2b-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #111544;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 36px;
  padding: 10px 18px 10px 14px;
  box-shadow: 0 8px 24px rgba(17, 21, 68, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-family: inherit;
}
.t2b-chat-launcher:hover {
  transform: translateY(-2px);
  background: #1a205a;
  box-shadow: 0 12px 28px rgba(17, 21, 68, 0.45);
}
.t2b-chat-launcher-icon {
  width: 28px;
  height: 28px;
  background: #2563eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.t2b-chat-launcher-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.t2b-chat-launcher-badge {
  background: #10b981;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #111544;
}

/* Chat Drawer Window */
.t2b-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(17, 21, 68, 0.3), 0 1px 3px rgba(0, 0, 0, 0.05);
  display: none;
  flex-direction: column;
  z-index: 9995;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: t2bChatFadeIn 0.25s ease-out;
}
.t2b-chat-window.open {
  display: flex;
}

@keyframes t2bChatFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.t2b-chat-header {
  background: #111544;
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.t2b-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.t2b-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.t2b-chat-title-wrap {}
.t2b-chat-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  letter-spacing: -0.01em;
}
.t2b-chat-status {
  font-size: 11px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.t2b-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}
.t2b-chat-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.t2b-chat-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Subheader / Mode Indicator */
.t2b-chat-mode-bar {
  background: #f8fafc;
  border-bottom: 1px solid #edf2f7;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #475569;
}
.t2b-chat-mode-pill {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0284c7;
}
.t2b-chat-mode-pill.human {
  background: #fef3c7;
  color: #b45309;
}
.t2b-chat-human-switch {
  background: transparent;
  border: none;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* View 1: Auth & Intake Form */
.t2b-chat-auth-view {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.t2b-chat-intro {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
}
.t2b-chat-form-group {
  margin-bottom: 12px;
}
.t2b-chat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}
.t2b-chat-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t2b-chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.t2b-chat-turnstile-wrap {
  margin: 12px 0;
  display: flex;
  justify-content: center;
  min-height: 65px;
}
.t2b-chat-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.btn-chat-primary {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-chat-primary:hover {
  background: #1d4ed8;
}
.btn-chat-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.btn-chat-secondary {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-chat-secondary:hover {
  background: #e2e8f0;
}
.t2b-chat-error {
  color: #dc2626;
  font-size: 11px;
  margin-top: 8px;
  text-align: center;
  display: none;
}
.t2b-chat-error.visible {
  display: block;
}

/* View 2: Conversation View */
.t2b-chat-convo-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.t2b-chat-convo-view.active {
  display: flex;
}
.t2b-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fdfdfd;
}

/* Speech Bubbles */
.t2b-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: t2bMsgSlide 0.2s ease-out;
}
@keyframes t2bMsgSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.t2b-msg.bot {
  align-self: flex-start;
}
.t2b-msg.user {
  align-self: flex-end;
}
.t2b-msg-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.t2b-msg.bot .t2b-msg-content {
  background: #f1f5f9;
  color: #0f172a;
  border-bottom-left-radius: 2px;
  border: 1px solid #e2e8f0;
}
.t2b-msg.user .t2b-msg-content {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}
.t2b-msg-content strong {
  font-weight: 700;
  color: #0f172a;
}
.t2b-msg.user .t2b-msg-content strong {
  color: #ffffff;
}
.t2b-chat-ul {
  margin: 6px 0;
  padding-left: 18px;
}
.t2b-chat-li {
  margin-bottom: 4px;
}
.t2b-chat-spacer {
  height: 8px;
}
.t2b-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}
.t2b-msg.user .t2b-msg-time {
  align-self: flex-end;
}

/* Typing Indicator */
.t2b-typing-indicator {
  display: none;
  align-self: flex-start;
  background: #f8fafc;
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  padding: 8px 14px;
  gap: 5px;
  border: 1px solid #e2e8f0;
  align-items: center;
}
.t2b-typing-indicator.active {
  display: flex;
}
.t2b-dot {
  width: 6px;
  height: 6px;
  background: #2563eb;
  border-radius: 50%;
  animation: t2bBounce 1.4s infinite ease-in-out both;
}
.t2b-dot:nth-child(1) { animation-delay: -0.32s; }
.t2b-dot:nth-child(2) { animation-delay: -0.16s; }
.t2b-dot:nth-child(3) { animation-delay: 0s; }
.t2b-typing-label {
  font-size: 11px;
  color: #64748b;
  margin-left: 4px;
  font-style: italic;
}
@keyframes t2bBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Input Bar */
.t2b-chat-input-bar {
  padding: 10px 14px;
  border-top: 1px solid #edf2f7;
  background: #ffffff;
  display: flex;
  gap: 8px;
  align-items: center;
}
.t2b-chat-msg-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.t2b-chat-msg-input:focus {
  border-color: #2563eb;
}
.t2b-chat-send-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.t2b-chat-send-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}
.t2b-chat-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Closing Card */
.t2b-closing-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  color: #166534;
  margin-top: 8px;
  text-align: center;
}

/* Quick Action Buttons (Follow-up & Consultation Options) - Compact 2-column grid */
.t2b-chat-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 6px 0 2px 0;
  animation: t2bFadeIn 0.25s ease;
}
.t2b-action-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.t2b-action-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}
.t2b-action-btn.email {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #f8fafc;
}
.t2b-action-btn.email:hover {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}
.t2b-action-btn.human {
  border-color: #c7d2fe;
  color: #4338ca;
  background: #fdfcff;
}
.t2b-action-btn.human:hover {
  border-color: #4f46e5;
  background: #4f46e5;
  color: #ffffff;
}
.t2b-action-btn.phone {
  border-color: #a7f3d0;
  color: #047857;
  background: #f0fdf4;
}
.t2b-action-btn.phone:hover {
  border-color: #059669;
  background: #059669;
  color: #ffffff;
}
.t2b-action-btn.whatsapp {
  border-color: #86efac;
  color: #15803d;
  background: #f0fdf4;
}
.t2b-action-btn.whatsapp:hover {
  border-color: #22c55e;
  background: #22c55e;
  color: #ffffff;
}
.t2b-action-btn.secondary {
  grid-column: span 2;
  border-color: #e2e8f0;
  color: #64748b;
  background: #f8fafc;
}
.t2b-action-btn.secondary:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #334155;
}

/* Timeout Notice */
.t2b-timeout-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 11px;
  text-align: center;
  margin: 6px 0;
}

/* Human Advisor Live Message Styles */
.t2b-msg.human-advisor-msg {
  align-self: flex-start;
  max-width: 90%;
  animation: t2bMsgSlide 0.25s ease-out;
}
.t2b-advisor-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 4px;
  padding-left: 2px;
}
.t2b-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  display: inline-block;
}
.t2b-msg-content.human-live-bubble {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%) !important;
  color: #0f172a !important;
  border: 1.5px solid #93c5fd !important;
  border-bottom-left-radius: 3px !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .t2b-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}
