/* ==========================================================================
   ESTILOS GENERALES DEL CHAT DE MÓNICA - WORDPRESS WIDGET
   ========================================================================== */

/* Envoltura principal para evitar conflictos con temas de WordPress */
.afudel-chat-wrapper {
  /* variables de tema claro (por defecto) */
  --primary-deep: hsl(210, 75%, 23%);
  --primary-light: hsl(209, 65%, 35%);
  --accent-gold: hsl(43, 90%, 52%);
  --accent-gold-hover: hsl(43, 95%, 45%);
  --bg-gradient-start: hsl(218, 50%, 93%);
  --bg-gradient-end: hsl(220, 40%, 82%);
  --text-dark: hsl(210, 25%, 15%);
  --text-light: hsl(210, 15%, 98%);
  --bg-card: hsla(0, 0%, 100%, 0.88);
  --border-glass: hsla(0, 0%, 100%, 0.4);
  --shadow-premium: 0 12px 40px -10px rgba(18, 38, 75, 0.15), 0 2px 10px -2px rgba(18, 38, 75, 0.05);
  
  --chat-bg-user: hsl(210, 75%, 23%);
  --chat-bg-monica: hsl(210, 30%, 96%);
  --chat-text-user: hsl(210, 15%, 98%);
  --chat-text-monica: hsl(210, 25%, 15%);
  
  --font-family: 'Outfit', sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;

  /* Estilos del contenedor wrapper en WordPress */
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  background: transparent;
}

/* ==========================================================================
   CONFIGURACIÓN TEMA OSCURO (A nivel de Wrapper)
   ========================================================================== */
.afudel-chat-wrapper.theme-dark {
  --primary-deep: hsl(210, 40%, 12%);
  --primary-light: hsl(210, 25%, 25%);
  --accent-gold: hsl(43, 85%, 45%);
  --accent-gold-hover: hsl(43, 90%, 38%);
  --bg-gradient-start: hsl(210, 35%, 8%);
  --bg-gradient-end: hsl(210, 25%, 13%);
  --text-dark: hsl(210, 15%, 85%);
  --text-light: hsl(210, 10%, 95%);
  --bg-card: hsla(210, 25%, 11%, 0.9);
  --border-glass: hsla(210, 20%, 20%, 0.4);
  --shadow-premium: 0 12px 40px -10px rgba(0, 0, 0, 0.5);
  
  --chat-bg-user: hsl(210, 60%, 25%);
  --chat-bg-monica: hsl(210, 20%, 16%);
  --chat-text-user: hsl(210, 15%, 95%);
  --chat-text-monica: hsl(210, 15%, 85%);
}

/* ==========================================================================
   CONFIGURACIÓN TEMA MEZCLADO (A nivel de Wrapper)
   ========================================================================== */
.afudel-chat-wrapper.theme-mixed {
  --primary-deep: hsl(210, 75%, 23%);
  --primary-light: hsl(209, 65%, 35%);
  --accent-gold: hsl(43, 90%, 52%);
  --accent-gold-hover: hsl(43, 95%, 45%);
  --bg-gradient-start: hsl(218, 50%, 93%);
  --bg-gradient-end: hsl(220, 40%, 82%);
  --text-dark: hsl(210, 25%, 15%);
  --text-light: hsl(210, 15%, 98%);
  --bg-card: hsla(0, 0%, 100%, 0.88);
  --border-glass: hsla(0, 0%, 100%, 0.4);
  --shadow-premium: 0 12px 40px -10px rgba(18, 38, 75, 0.15);
  
  --chat-bg-user: hsl(210, 75%, 23%);
  --chat-bg-monica: hsl(43, 90%, 93%);
  --chat-text-user: hsl(210, 15%, 98%);
  --chat-text-monica: hsl(210, 40%, 15%);
}

/* Encapsular todos los elementos bajo .afudel-chat-wrapper */
.afudel-chat-wrapper * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

/* Contenedor central de la app */
.afudel-chat-wrapper .app-container {
  width: 100%;
  max-width: 480px;
  height: 700px;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* TARJETAS COMUNES */
.afudel-chat-wrapper .login-card, 
.afudel-chat-wrapper .chat-card {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.afudel-chat-wrapper .hidden {
  display: none !important;
  opacity: 0;
}

/* ==========================================================================
   ESTILOS PANTALLA DE LOGIN
   ========================================================================== */
.afudel-chat-wrapper .login-card {
  padding: 30px 24px;
  justify-content: space-between;
  background: linear-gradient(135deg, white 0%, hsl(210, 20%, 97%) 100%);
}

.afudel-chat-wrapper.theme-dark .login-card {
  background: linear-gradient(135deg, hsl(210, 25%, 11%) 0%, hsl(210, 25%, 8%) 100%);
}

.afudel-chat-wrapper .login-header {
  text-align: center;
}

.afudel-chat-wrapper .logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.afudel-chat-wrapper .logo-icon {
  font-size: 2rem;
}

.afudel-chat-wrapper .logo-text {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-deep);
  letter-spacing: 1px;
}

.afudel-chat-wrapper .decoration-bar {
  width: 50px;
  height: 4px;
  background: var(--accent-gold);
  border-radius: 2px;
  margin: 0 auto;
}

.afudel-chat-wrapper .login-body {
  margin: 25px 0;
}

.afudel-chat-wrapper .login-body h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-deep);
  margin-bottom: 8px;
  text-align: center;
}

.afudel-chat-wrapper .login-subtitle {
  font-size: 0.88rem;
  color: hsl(210, 10%, 45%);
  text-align: center;
  line-height: 1.4;
  margin-bottom: 20px;
}

/* Formularios */
.afudel-chat-wrapper .input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  text-align: left;
}

.afudel-chat-wrapper .input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.afudel-chat-wrapper .input-group input {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 2px solid hsl(210, 20%, 90%);
  background: white;
  font-size: 0.95rem;
  transition: all 0.25s ease;
  color: hsl(210, 25%, 15%);
  width: 100%;
}

.afudel-chat-wrapper.theme-dark .input-group input {
  background-color: hsl(210, 25%, 15%);
  border-color: hsl(210, 20%, 25%);
  color: var(--text-dark);
}

.afudel-chat-wrapper .input-group input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px hsla(210, 75%, 23%, 0.1);
}

.afudel-chat-wrapper .input-help {
  font-size: 0.72rem;
  color: hsl(210, 10%, 60%);
}

.afudel-chat-wrapper .btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary-deep);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 10px hsla(210, 75%, 23%, 0.15);
}

.afudel-chat-wrapper .btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.afudel-chat-wrapper .error-msg {
  background: hsl(0, 85%, 97%);
  color: hsl(0, 85%, 40%);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 12px;
  border: 1px solid hsl(0, 85%, 90%);
  animation: afudel-shake 0.4s ease;
}

.afudel-chat-wrapper .login-footer {
  border-top: 1px solid hsl(210, 10%, 90%);
  padding-top: 15px;
}

.afudel-chat-wrapper.theme-dark .login-footer {
  border-top-color: hsl(210, 15%, 20%);
}

.afudel-chat-wrapper .demo-info-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: hsl(210, 10%, 50%);
  margin-bottom: 8px;
  text-align: center;
}

.afudel-chat-wrapper .demo-ruts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.afudel-chat-wrapper .rut-tag {
  background: hsl(210, 20%, 94%);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--primary-light);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  border: 1px dashed hsl(210, 15%, 85%);
}

.afudel-chat-wrapper.theme-dark .rut-tag {
  background: hsl(210, 20%, 15%);
  color: hsl(210, 15%, 80%);
  border-color: hsl(210, 15%, 22%);
}

.afudel-chat-wrapper .rut-tag:hover {
  background: var(--accent-gold);
  color: var(--primary-deep);
  font-weight: 600;
  border-color: transparent;
}

/* ==========================================================================
   ESTILOS DE PANTALLA DE CHAT
   ========================================================================== */
.afudel-chat-wrapper .chat-header {
  padding: 12px 16px;
  background: var(--primary-deep);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--accent-gold);
}

.afudel-chat-wrapper .advisor-info {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.afudel-chat-wrapper .avatar-container {
  position: relative;
  width: 42px;
  height: 42px;
}

.afudel-chat-wrapper .advisor-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
}

.afudel-chat-wrapper .status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 10px;
  height: 10px;
  background-color: #2ec4b6;
  border: 2px solid var(--primary-deep);
  border-radius: 50%;
  animation: afudel-pulseGreen 2s infinite;
}

.afudel-chat-wrapper .advisor-details h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: white;
}

.afudel-chat-wrapper .advisor-details p {
  font-size: 0.7rem;
  color: hsl(209, 45%, 80%);
}

.afudel-chat-wrapper .header-actions {
  display: flex;
  gap: 8px;
}

.afudel-chat-wrapper .btn-icon {
  background: hsla(0, 0%, 100%, 0.1);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.afudel-chat-wrapper .btn-icon:hover {
  background: hsla(0, 0%, 100%, 0.25);
  transform: scale(1.05);
}

/* Área de Mensajes del Chat */
.afudel-chat-wrapper .chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.7) 0%, rgba(240,244,248,0.7) 100%);
  scroll-behavior: smooth;
}

.afudel-chat-wrapper.theme-dark .chat-body {
  background: linear-gradient(180deg, hsl(210, 30%, 8%) 0%, hsl(210, 25%, 12%) 100%);
}

.afudel-chat-wrapper.theme-mixed .chat-body {
  background: linear-gradient(180deg, hsl(35, 100%, 98%) 0%, hsl(210, 30%, 95%) 100%);
}

/* Burbujas de Chat */
.afudel-chat-wrapper .msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  animation: afudel-popMessage 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  word-wrap: break-word;
  text-align: left;
}

.afudel-chat-wrapper .msg.monica {
  background: var(--chat-bg-monica);
  color: var(--chat-text-monica);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid hsl(210, 20%, 90%);
}

.afudel-chat-wrapper.theme-dark .msg.monica {
  border-color: hsl(210, 20%, 20%);
}

.afudel-chat-wrapper.theme-mixed .msg.monica {
  border: 1px solid hsl(43, 70%, 75%);
  box-shadow: 0 2px 8px hsla(43, 50%, 50%, 0.08);
}

.afudel-chat-wrapper .msg.user {
  background: var(--chat-bg-user);
  color: var(--chat-text-user);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 8px hsla(210, 75%, 23%, 0.12);
}

/* Formateo interior de burbujas */
.afudel-chat-wrapper .msg p {
  margin-bottom: 6px;
}
.afudel-chat-wrapper .msg p:last-child {
  margin-bottom: 0;
}
.afudel-chat-wrapper .msg ul, 
.afudel-chat-wrapper .msg ol {
  margin-left: 15px;
  margin-bottom: 6px;
}
.afudel-chat-wrapper .msg li {
  margin-bottom: 3px;
}
.afudel-chat-wrapper .msg strong {
  font-weight: 600;
}

/* TARJETA DE SIMULADOR EMBEBIDA */
.afudel-chat-wrapper .calc-card-embedded {
  background: white;
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 14px;
  width: 100%;
  max-width: 290px;
  align-self: flex-start;
  box-shadow: 0 6px 20px rgba(18, 38, 75, 0.08);
  animation: afudel-popMessage 0.4s ease;
  margin: 4px 0;
}

.afudel-chat-wrapper.theme-dark .calc-card-embedded {
  background: hsl(210, 25%, 13%);
  border-color: var(--accent-gold);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.afudel-chat-wrapper .calc-card-embedded h3 {
  font-size: 0.88rem;
  color: var(--primary-deep);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  border-bottom: 1px solid hsl(210, 10%, 90%);
  padding-bottom: 5px;
}

.afudel-chat-wrapper.theme-dark .calc-card-embedded h3 {
  color: var(--accent-gold);
  border-color: hsl(210, 20%, 22%);
}

.afudel-chat-wrapper .calc-form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  text-align: left;
}

.afudel-chat-wrapper .calc-form-row label {
  font-size: 0.7rem;
  font-weight: 600;
  color: hsl(210, 15%, 45%);
}

.afudel-chat-wrapper.theme-dark .calc-form-row label {
  color: hsl(210, 15%, 70%);
}

.afudel-chat-wrapper .calc-form-row input, 
.afudel-chat-wrapper .calc-form-row select {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(210, 15%, 85%);
  font-size: 0.8rem;
  background: white;
  color: var(--text-dark);
}

.afudel-chat-wrapper.theme-dark .calc-form-row input, 
.afudel-chat-wrapper.theme-dark .calc-form-row select {
  background-color: hsl(210, 25%, 15%);
  border-color: hsl(210, 20%, 25%);
  color: var(--text-dark);
}

.afudel-chat-wrapper .calc-form-row input:focus, 
.afudel-chat-wrapper .calc-form-row select:focus {
  outline: none;
  border-color: var(--primary-light);
}

.afudel-chat-wrapper .btn-calc {
  width: 100%;
  padding: 8px;
  background: var(--accent-gold);
  color: var(--primary-deep);
  border: none;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.afudel-chat-wrapper .btn-calc:hover {
  background: var(--accent-gold-hover);
}

/* Indicador de Escritura */
.afudel-chat-wrapper .typing-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  margin-bottom: 8px;
  align-self: flex-start;
}

.afudel-chat-wrapper .avatar-mini {
  width: 26px;
  height: 26px;
}

.afudel-chat-wrapper .avatar-mini img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.afudel-chat-wrapper .typing-bubble {
  background: var(--chat-bg-monica);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  border: 1px solid hsl(210, 20%, 90%);
  display: flex;
  align-items: center;
  gap: 4px;
}

.afudel-chat-wrapper.theme-dark .typing-bubble {
  border-color: hsl(210, 20%, 20%);
}

.afudel-chat-wrapper .typing-bubble .dot {
  width: 6px;
  height: 6px;
  background-color: hsl(210, 15%, 60%);
  border-radius: 50%;
  animation: afudel-typingBounce 1.4s infinite ease-in-out;
}

.afudel-chat-wrapper .typing-bubble .dot:nth-child(1) { animation-delay: 0s; }
.afudel-chat-wrapper .typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.afudel-chat-wrapper .typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }

/* Sugerencias Rápidas */
.afudel-chat-wrapper .quick-replies-container {
  padding: 8px 12px;
  background: transparent;
  border-top: 1px solid rgba(0,0,0,0.03);
}

.afudel-chat-wrapper .quick-replies-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
}

.afudel-chat-wrapper .quick-replies-scroll::-webkit-scrollbar {
  height: 4px;
}

.afudel-chat-wrapper .quick-replies-scroll::-webkit-scrollbar-thumb {
  background: hsl(210, 10%, 80%);
  border-radius: 2px;
}

.afudel-chat-wrapper .quick-btn {
  background: white;
  border: 1px solid hsl(210, 15%, 85%);
  color: var(--primary-light);
  padding: 6px 12px;
  border-radius: 30px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.afudel-chat-wrapper.theme-dark .quick-btn {
  background: hsl(210, 20%, 15%);
  border-color: hsl(210, 15%, 25%);
  color: hsl(210, 15%, 80%);
}

.afudel-chat-wrapper .quick-btn:hover {
  background: var(--primary-deep);
  color: white;
  border-color: var(--primary-deep);
}

.afudel-chat-wrapper.theme-dark .quick-btn:hover {
  background: var(--accent-gold);
  color: var(--primary-deep);
  border-color: var(--accent-gold);
}

/* Pie del Chat (Input) */
.afudel-chat-wrapper .chat-footer {
  padding: 10px 15px;
  background: white;
  border-top: 1px solid hsl(210, 10%, 90%);
}

.afudel-chat-wrapper.theme-dark .chat-footer,
.afudel-chat-wrapper.theme-dark #chat-form {
  background-color: hsl(210, 25%, 11%);
}

.afudel-chat-wrapper #chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.afudel-chat-wrapper #chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 30px;
  border: 2px solid hsl(210, 10%, 90%);
  font-size: 0.9rem;
  transition: border-color 0.2s;
  color: var(--text-dark);
  background: white;
}

.afudel-chat-wrapper.theme-dark #chat-input {
  background-color: hsl(210, 25%, 15%);
  border-color: hsl(210, 20%, 22%);
  color: var(--text-dark);
}

.afudel-chat-wrapper #chat-input:focus {
  outline: none;
  border-color: var(--primary-light);
}

.afudel-chat-wrapper.theme-dark #chat-input:focus {
  border-color: var(--accent-gold);
}

.afudel-chat-wrapper .btn-send {
  background: var(--primary-deep);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 3px 8px hsla(210, 75%, 23%, 0.15);
}

.afudel-chat-wrapper.theme-dark .btn-send {
  background-color: var(--accent-gold);
  color: var(--primary-deep);
}

.afudel-chat-wrapper .btn-send:hover {
  background: var(--primary-light);
  transform: scale(1.05);
}

.afudel-chat-wrapper.theme-dark .btn-send:hover {
  background-color: var(--accent-gold-hover);
}

/* ==========================================================================
   ANIMACIONES (PREFIJADAS)
   ========================================================================== */
@keyframes afudel-popMessage {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes afudel-typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

@keyframes afudel-pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(46, 196, 182, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 196, 182, 0); }
}

@keyframes afudel-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* Responsive para dispositivos móviles */
@media (max-width: 500px) {
  .afudel-chat-wrapper {
    padding: 0;
  }
  .afudel-chat-wrapper .app-container {
    height: 100vh;
    border-radius: 0;
  }
  .afudel-chat-wrapper .login-card, 
  .afudel-chat-wrapper .chat-card {
    border-radius: 0;
    border: none;
  }
}

/* ==========================================================================
   BURBUJA FLOTANTE — Mónica AFUDEL v2.1
   ========================================================================== */

#afudel-bubble-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Panel del chat */
.afudel-bubble-panel {
  width: 390px;
  border-radius: 20px;
  box-shadow: 0 20px 60px -10px rgba(18,38,75,0.32), 0 4px 16px rgba(0,0,0,0.14);
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}

.afudel-bubble-panel.afudel-bubble-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.afudel-bubble-panel.afudel-bubble-hidden {
  transform: scale(0.72) translateY(30px);
  opacity: 0;
  pointer-events: none;
}

/* El wrapper del chat dentro del panel ocupa todo */
.afudel-bubble-panel .afudel-chat-wrapper {
  padding: 0;
  height: 600px;
}

.afudel-bubble-panel .app-container {
  max-width: 100%;
  height: 600px;
  border-radius: 20px;
}

/* ---- Botón burbuja: imagen circular del avatar ---- */
#afudel-bubble-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  /* Sin fondo azul: la imagen ES el botón */
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s ease;
  /* Sombra que da sensación de flotación */
  box-shadow: 0 6px 22px rgba(18,38,75,0.38), 0 2px 8px rgba(0,0,0,0.20);
  overflow: hidden;
  flex-shrink: 0;
}

#afudel-bubble-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 30px rgba(18,38,75,0.50);
}

#afudel-bubble-btn:active {
  transform: scale(0.94);
}

/* Avatar: la foto de Mónica llena todo el botón */
.afudel-bubble-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid #fff;
  transition: opacity 0.18s ease, transform 0.22s ease;
  position: absolute;
  top: 0; left: 0;
}

/* Ícono ✕ de cerrar (superpuesto, invisible cuando el chat está cerrado) */
.afudel-bubble-close {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0) rotate(-90deg);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.22s ease;
  line-height: 1;
  z-index: 2;
}

/* Fondo semitransparente para el ✕ cuando el chat está abierto */
#afudel-bubble-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(12,28,60,0.55);
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 1;
}

/* Estado: chat ABIERTO */
#afudel-bubble-btn.afudel-btn-open::before {
  opacity: 1;
}

#afudel-bubble-btn.afudel-btn-open .afudel-bubble-close {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

/* Badge de notificación */
.afudel-bubble-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: hsl(4,90%,55%);
  border: 2px solid #fff;
  z-index: 3;
  animation: afudel-badge-pulse 2s infinite;
  display: none;
}

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

/* Tooltip de bienvenida */
.afudel-bubble-tooltip {
  position: absolute;
  bottom: 78px;
  right: 0;
  background: #fff;
  color: hsl(210,25%,15%);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,0.16);
  border: 1px solid hsl(210,30%,88%);
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.afudel-bubble-tooltip.afudel-tooltip-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---- Responsive móvil ---- */
@media (max-width: 480px) {
  #afudel-bubble-wrapper {
    bottom: 16px;
    right: 16px;
  }

  .afudel-bubble-panel {
    width: calc(100vw - 32px);
  }

  .afudel-bubble-panel .afudel-chat-wrapper,
  .afudel-bubble-panel .app-container {
    height: 82vh;
    max-width: 100%;
    border-radius: 16px;
  }

  #afudel-bubble-btn {
    width: 58px;
    height: 58px;
  }
}

/* ==========================================================================
   SIMULADOR v2.3 — Tabla de tramos y resultado
   ========================================================================== */

/* Tarjeta del simulador más ancha para alojar la tabla */
.afudel-chat-wrapper .calc-card-embedded {
  max-width: 330px;
}

/* ---- Caja de tramos (ayuda) ---- */
.afudel-chat-wrapper .sim-tramos-box,
.afudel-chat-wrapper .sim-result-tramos {
  background: var(--bg-gradient-start);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: .75rem;
}

.afudel-chat-wrapper .sim-tramos-header {
  font-size: .76rem;
  margin-bottom: 6px;
  color: var(--text-dark);
  line-height: 1.3;
}

.afudel-chat-wrapper .sim-tramos-header span {
  color: hsl(210,15%,50%);
}

/* Tabla de tramos */
.afudel-chat-wrapper .sim-tramos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .74rem;
}

.afudel-chat-wrapper .sim-tramos-table th {
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  color: hsl(210,15%,50%);
  padding: 2px 4px 4px;
  border-bottom: 1px solid var(--border-glass);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.afudel-chat-wrapper .sim-tramos-table td {
  padding: 4px 4px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-dark);
  vertical-align: middle;
}

.afudel-chat-wrapper .sim-tramos-table tr:last-child td {
  border-bottom: none;
}

/* Fila activa (tramo seleccionado) */
.afudel-chat-wrapper .sim-tramos-table tr.sim-tramo-activo td {
  background: hsla(43, 90%, 52%, 0.15);
  border-left: 3px solid var(--accent-gold);
  font-weight: 600;
  color: var(--text-dark);
}

/* Nota al pie de la tabla */
.afudel-chat-wrapper .sim-tramos-nota {
  font-size: .7rem;
  color: hsl(210,15%,50%);
  margin-top: 5px;
  line-height: 1.4;
}

/* ---- Caja de resultado ---- */
.afudel-chat-wrapper .sim-result-box {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-size: .83rem;
}

.afudel-chat-wrapper .sim-result-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.afudel-chat-wrapper .sim-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-dark);
}

.afudel-chat-wrapper .sim-result-val {
  font-weight: 700;
  white-space: nowrap;
  color: var(--primary-light);
}

.afudel-chat-wrapper .sim-result-detail {
  font-size: .71rem;
  color: hsl(210,15%,50%);
  margin: 1px 0 6px;
  line-height: 1.4;
}

.afudel-chat-wrapper .sim-result-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid var(--accent-gold);
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text-dark);
}

.afudel-chat-wrapper .sim-result-total span:last-child {
  color: var(--primary-light);
  font-size: 1.05rem;
}

/* Nota de prorrateo */
.afudel-chat-wrapper .sim-nota-prorr {
  font-size: .7rem;
  color: hsl(210,15%,55%);
  font-style: italic;
}

/* Aviso legal debajo del resultado */
.afudel-chat-wrapper .sim-aviso {
  font-size: .73rem;
  color: hsl(210,15%,55%);
  line-height: 1.4;
  margin-top: -2px;
}

/* Tema oscuro — ajustes de contraste */
.afudel-chat-wrapper.theme-dark .sim-tramos-box,
.afudel-chat-wrapper.theme-dark .sim-result-tramos {
  background: hsl(210,25%,11%);
  border-color: hsl(210,20%,20%);
}

.afudel-chat-wrapper.theme-dark .sim-tramos-table tr.sim-tramo-activo td {
  background: hsla(43, 70%, 40%, 0.18);
}

.afudel-chat-wrapper.theme-dark .sim-result-box {
  background: hsl(210,25%,13%);
  border-color: hsl(210,20%,22%);
}

/* ---- Hint de edad en el simulador ---- */
.afudel-chat-wrapper .sim-edad-hint {
  display: block;
  font-size: .68rem;
  line-height: 1.4;
  margin-top: 3px;
  padding: 4px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.afudel-chat-wrapper .sim-edad-hint--info {
  background: hsla(210, 60%, 94%, 0.9);
  color: hsl(210, 50%, 35%);
  border: 1px solid hsl(210, 40%, 80%);
}

.afudel-chat-wrapper .sim-edad-hint--ok {
  background: hsla(140, 55%, 93%, 0.9);
  color: hsl(140, 45%, 28%);
  border: 1px solid hsl(140, 40%, 75%);
}

.afudel-chat-wrapper.theme-dark .sim-edad-hint--info {
  background: hsla(210, 40%, 18%, 0.9);
  color: hsl(210, 60%, 75%);
  border-color: hsl(210, 30%, 30%);
}

.afudel-chat-wrapper.theme-dark .sim-edad-hint--ok {
  background: hsla(140, 30%, 16%, 0.9);
  color: hsl(140, 50%, 65%);
  border-color: hsl(140, 30%, 28%);
}
