/**
 * Chat Widget Styles
 * Diseño moderno y responsivo
 */

/* Reset y variables */
:root {
    --chat-primary: #084582;
    --chat-bg: #ffffff;
    --chat-text: #084582;
    --chat-text-light: #666666;
    --chat-border: rgba(0, 0, 0, 0.05);
    --chat-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --chat-radius: 24px;
    --chat-spacing: 16px;
  }
  
  /* Contenedor principal */
  #chat-widget-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  }
  
  /* Botón flotante */
  .chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    width: 60px;
    height: 60px;
    background: #ffffff;
    border: 3px solid var(--chat-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chat-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000000;
    overflow: hidden;
    padding: 0;
  }
  
  .chat-toggle-btn.chat-right {
    right: 24px;
  }
  
  .chat-toggle-btn.chat-left {
    left: 24px;
  }
  
  .chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 132, 255, 0.4);
  }
  
  .chat-toggle-btn:active {
    transform: scale(0.95);
  }
  
  .chat-toggle-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
  
  /* Badge de notificación */
  .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4444;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
  }
  
  /* Ventana del chat */
  .chat-window {
    position: fixed;
    bottom: 24px;
    width: 400px;
    height: 60vh;
    max-height: calc(100vh - 48px);
    backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    z-index: 1000000;
  }
  
  .chat-window.chat-right {
    right: 24px;
  }
  
  .chat-window.chat-left {
    left: 24px;
  }
  
  @keyframes slideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Header */
  .chat-header {
    padding: 16px 20px 30px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    position: relative;
  }
  
  .chat-header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .chat-bot-avatar {
    width: 60px;
    height: 60px;
    background: #ffffff;
    border-radius: 50%;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
  }
  
  .chat-header-text {
    text-align: center;
  }
  
  .chat-header-text h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
  }
  
  .chat-status {
    font-size: 12px;
    opacity: 0.9;
  }
  
  .chat-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    position: absolute;
    top: 16px;
    right: 20px;
  }
  
  .chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  
  /* Área de mensajes */
  .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--chat-spacing);
    background: rgba(255, 255, 255, 0.95);
    scroll-behavior: smooth;
  }
  
  .chat-messages::-webkit-scrollbar {
    width: 6px;
  }
  
  .chat-messages::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
  }
  
  .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
  }
  
  /* Mensaje individual */
  .chat-message {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease-out;
  }
  
  @keyframes messageSlide {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .chat-message.user {
    flex-direction: row-reverse;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
  }
  
  .message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
    backdrop-filter: blur(8px);
  }
  
  .chat-message.bot .message-bubble {
    background: rgba(8, 69, 130, 0.1);
    color: var(--chat-text);
    border-bottom-left-radius: 0;
  }
  
  .chat-message.user .message-bubble {
    background: rgba(8, 69, 130, 0.15);
    color: var(--chat-primary);
    border-bottom-right-radius: 0;
  }
  
  .chat-message.error .message-bubble {
    background: #ffe5e5;
    color: #cc0000;
    border: 1px solid #ffcccc;
  }
  
  .message-time {
    font-size: 11px;
    color: var(--chat-text-light);
    margin-top: 4px;
    padding: 0 8px;
  }
  
  /* Indicador de escritura */
  .typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
  }
  
  .typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
  }
  
  .typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
  }
  
  .typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
  }
  
  @keyframes typingBounce {
    0%, 80%, 100% {
      transform: scale(0);
      opacity: 0.5;
    }
    40% {
      transform: scale(1);
      opacity: 1;
    }
  }
  
  /* Input de mensaje */
  .chat-input-container {
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
  }
  
  .chat-input {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.05);
    color: var(--chat-text);
    resize: none;
    max-height: 100px;
    outline: none;
    transition: all 0.2s;
  }
  
  .chat-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
  }
  
  .chat-input:focus {
    background: rgba(0, 0, 0, 0.08);
  }
  
  .chat-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
  }
  
  .chat-send-btn:hover:not(:disabled) {
    filter: brightness(0.9);
  }
  
  .chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
  }
  
  .chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  /* Footer */
  .chat-footer {
    padding: 8px var(--chat-spacing);
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--chat-border);
    display: flex;
    justify-content: center;
  }
  
  .chat-footer-btn {
    background: transparent;
    border: 1px solid var(--chat-border);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    color: var(--chat-text-light);
    transition: all 0.2s;
  }
  
  .chat-footer-btn:hover {
    background: white;
    color: var(--chat-primary);
    border-color: var(--chat-primary);
  }
  
  /* Notificaciones */
  .chat-notification {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: var(--chat-shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
    z-index: 1000001;
  }
  
  .chat-notification.show {
    opacity: 1;
    transform: translateY(0);
  }
  
  .chat-notification.success {
    background: #4caf50;
  }
  
  .chat-notification.error {
    background: #f44336;
  }
  
  /* Responsive */
  @media (max-width: 768px) {
    .chat-window {
      width: calc(100vw - 32px);
      height: 60vh;
      max-width: 100%;
      bottom: 16px;
    }
    
    .chat-window.chat-right {
      right: 16px;
    }
    
    .chat-window.chat-left {
      left: 16px;
    }
    
    .chat-toggle-btn {
      bottom: 16px;
    }
    
    .chat-toggle-btn.chat-right {
      right: 16px;
    }
    
    .chat-toggle-btn.chat-left {
      left: 16px;
    }
    
    .chat-bot-avatar {
      width: 50px;
      height: 50px;
    }
  }
  
  @media (max-width: 600px) {
    .chat-bot-avatar {
      width: 48px;
      height: 48px;
    }
  }
  
  /* Accesibilidad */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }