/* Chatbot Widget Styles */
.chatbot-widget {
    position: fixed;
    bottom: 44px;
    right: 20px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Botón flotante */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #229d9b 0%, #197c7a 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(34, 157, 155, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(34, 157, 155, 0.4);
}

.chatbot-toggle i {
    font-size: 24px;
}

.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Ventana del chat */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 750px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chatbot-widget.open .chatbot-window {
    display: flex;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #229d9b 0%, #197c7a 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-header-actions {
    display: flex;
    gap: 10px;
}

.chatbot-language-btn,
.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.chatbot-language-btn:hover,
.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mensajes */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
    height: 0; /* Permite que flex: 1 funcione correctamente */
    min-height: 0; /* Necesario para que el scroll funcione en flex containers */
    max-height: calc(750px - 140px); /* Altura fija menos header e input */
}

.chatbot-message {
    margin-bottom: 15px;
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-message-bot {
    justify-content: flex-start;
}

.chatbot-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.chatbot-message-user .chatbot-message-content {
    background: #229d9b;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-bot .chatbot-message-content {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chatbot-message-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chatbot-message-text a {
    color: inherit;
    text-decoration: underline;
}

.chatbot-message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

/* Input - Fijo en la parte inferior */
.chatbot-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}

.chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chatbot-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    min-height: 44px;
    background: #f8f9fa;
    box-shadow: none;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.chatbot-input::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.chatbot-input:focus {
    border-color: #229d9b;
    background: white;
    box-shadow: 0 0 0 3px rgba(34, 157, 155, 0.1);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #229d9b;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    background: #197c7a;
}

.chatbot-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Indicador de escritura */
.chatbot-typing {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #666;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #229d9b;
    animation: typing 1.4s infinite ease-in-out;
}

.chatbot-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modal de idioma */
.chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.chatbot-modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chatbot-modal-content h3 {
    margin: 0 0 20px 0;
    text-align: center;
    color: #333;
}

.chatbot-language-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.chatbot-language-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.chatbot-language-option:hover {
    border-color: #229d9b;
    background: #f8f9fa;
}

.chatbot-language-option.active {
    border-color: #229d9b;
    background: #f0f9f8;
}

.chatbot-language-option .flag {
    font-size: 24px;
}

.chatbot-language-option span:last-child {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.chatbot-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.chatbot-modal-close:hover {
    background: #f8f9fa;
}

/* Scrollbar personalizada */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 58px;
        right: 10px;
    }
    
    .chatbot-toggle {
        width: 50px;
        height: 50px;
    }
    
    .chatbot-toggle i {
        font-size: 20px;
    }
    
    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
        position: fixed;
        top: 30px;
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        max-height: calc(100vh - 80px);
        min-height: 300px;
    }
    
    .chatbot-messages {
        max-height: calc(100vh - 140px);
        padding: 12px;
        min-height: 200px;
    }
    
    .chatbot-header {
        padding: 12px 15px;
        border-radius: 12px 12px 0 0;
        flex-shrink: 0;
    }
    
    .chatbot-header-info h3 {
        font-size: 14px;
    }
    
    .chatbot-status {
        font-size: 11px;
    }
    
    .chatbot-input-container {
        padding: 12px 15px;
        border-radius: 0 0 12px 12px;
        flex-shrink: 0;
    }
    
    .chatbot-input {
        padding: 8px 12px;
        font-size: 16px; /* Evita zoom en iOS */
        min-height: 40px;
    }
    
    .chatbot-send-btn {
        width: 36px;
        height: 36px;
    }
    
    .chatbot-send-btn i {
        font-size: 14px;
    }
    
    .chatbot-language-options {
        grid-template-columns: 1fr;
    }
    
    .chatbot-modal-content {
        margin: 10px;
        width: calc(100% - 20px);
        padding: 15px;
    }
    
    .chatbot-message-content {
        max-width: 98%;
        padding: 8px 12px;
    }
    
    .chatbot-message-text {
        font-size: 14px;
    }
    
    .chatbot-message-time {
        font-size: 10px;
    }
    
    /* Optimizar botones rápidos en móvil */
    .chatbot-quick-buttons {
        gap: 6px;
        margin-top: 8px;
    }
    
    .chatbot-quick-button {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    /* Optimizar productos en móvil */
    .chatbot-product {
        padding: 8px;
        gap: 8px;
    }
    
    .chatbot-product img {
        width: 40px;
        height: 40px;
    }
    
    .chatbot-product-info h4 {
        font-size: 13px;
    }
    
    .chatbot-product-info p {
        font-size: 11px;
    }
}

/* Móviles con teclado visible - altura reducida */
@media (max-width: 480px) and (max-height: 600px) {
    .chatbot-window {
        height: calc(100vh - 60px);
        top: 20px;
        bottom: 5px;
        max-height: calc(100vh - 40px);
    }
    
    .chatbot-messages {
        max-height: calc(100vh - 100px);
        min-height: 150px;
    }
    
    .chatbot-header {
        padding: 8px 12px;
    }
    
    .chatbot-header-info h3 {
        font-size: 13px;
    }
    
    .chatbot-input-container {
        padding: 8px 12px;
    }
    
    .chatbot-input {
        padding: 6px 10px;
        min-height: 36px;
    }
    
    .chatbot-send-btn {
        width: 32px;
        height: 32px;
    }
}

/* Móviles muy pequeños */
@media (max-width: 360px) {
    .chatbot-window {
        width: calc(100vw - 10px);
        left: 5px;
        right: 5px;
        height: calc(100vh - 80px);
        top: 15px;
        bottom: 5px;
    }
    
    .chatbot-messages {
        padding: 8px;
        max-height: calc(100vh - 120px);
    }
    
    .chatbot-header {
        padding: 8px 10px;
    }
    
    .chatbot-input-container {
        padding: 8px 10px;
    }
    
    .chatbot-message-content {
        max-width: 99%;
        padding: 6px 10px;
    }
    
    .chatbot-message-text {
        font-size: 13px;
    }
}

/* Orientación landscape en móviles */
@media (max-width: 480px) and (orientation: landscape) {
    .chatbot-window {
        height: calc(100vh - 40px);
        top: 10px;
        bottom: 5px;
        max-height: calc(100vh - 20px);
    }
    
    .chatbot-messages {
        max-height: calc(100vh - 80px);
        min-height: 120px;
    }
    
    .chatbot-header {
        padding: 6px 10px;
    }
    
    .chatbot-header-info h3 {
        font-size: 12px;
    }
    
    .chatbot-input-container {
        padding: 6px 10px;
    }
    
    .chatbot-input {
        padding: 4px 8px;
        min-height: 32px;
    }
    
    .chatbot-send-btn {
        width: 28px;
        height: 28px;
    }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .chatbot-window {
        width: 400px;
        height: 600px;
    }
    
    .chatbot-messages {
        max-height: calc(600px - 140px);
    }
}

/* Estados de carga */
.chatbot-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

.chatbot-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #229d9b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animaciones adicionales */
.chatbot-message {
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botones rápidos */
.chatbot-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chatbot-quick-button {
    background: #e9ecef;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.chatbot-quick-button:hover {
    background: #229d9b;
    color: white;
    border-color: #229d9b;
}

/* Productos en el chat */
.chatbot-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.chatbot-product {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    align-items: center;
}

.chatbot-product img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

.chatbot-product-info {
    flex: 1;
}

.chatbot-product-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
}

.chatbot-product-info p {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: #229d9b;
    font-weight: 600;
}

.chatbot-product button {
    background: #229d9b;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-product button:hover {
    background: #197c7a;
}

/* Estados del chat */
.chatbot-status.connecting {
    color: #ffc107;
}

.chatbot-status.agent-mode {
    color: #17a2b8;
    font-weight: 600;
}

.chatbot-status.offline {
    color: #dc3545;
}

/* Animaciones mejoradas */
.chatbot-message.new-message {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Estados de error */
.chatbot-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 12px;
}

/* Estados de éxito */
.chatbot-success {
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    color: #38a169;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 12px;
} 

/* Mensajes del agente */
.chatbot-message-agent {
    justify-content: flex-start;
}

.chatbot-message-agent .chatbot-message-content {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: 2px solid #17a2b8;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}

.chatbot-message-agent .chatbot-message-text {
    color: white;
}

.chatbot-message-agent .chatbot-message-time {
    color: rgba(255, 255, 255, 0.7);
}

.chatbot-agent-icon {
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chatbot-agent-icon i {
    margin-right: 4px;
    color: #ffd700;
}

/* Animación especial para mensajes del agente */
.chatbot-message-agent {
    animation: agentMessageSlideIn 0.4s ease;
}

@keyframes agentMessageSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
    }
    50% {
        transform: translateX(5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Indicador de agente en línea */
.chatbot-widget.bot-disabled .chatbot-header {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

.chatbot-widget.bot-disabled .chatbot-status {
    color: #ffd700;
    font-weight: 600;
    animation: gentle-pulse 2s infinite;
}

.chatbot-status.connecting {
    color: #ffd700 !important;
    font-weight: 600;
    animation: gentle-pulse 2s infinite;
}

@keyframes gentle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Mensaje de bot deshabilitado - Estilo amigable */
.chatbot-message-bot .chatbot-message-content.bot-disabled-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.chatbot-message-bot .chatbot-message-content.bot-disabled-message .chatbot-message-time {
    color: #856404;
}

/* Indicador de agente */
.chatbot-agent-indicator {
    font-size: 11px;
    color: #28a745;
    font-weight: 600;
    margin-top: 2px;
}

.chatbot-agent-indicator i {
    margin-right: 4px;
} 

/* Quick reply buttons base */
.chatbot-quick-reply-btn {
    background: #e9ecef;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #229d9b;
    margin: 0 6px 6px 0;
    box-shadow: 0 2px 8px rgba(34,157,155,0.08);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.chatbot-quick-reply-btn:hover {
    background: #229d9b;
    color: #fff;
    border-color: #229d9b;
}

/* Quick reply with URL */
.chatbot-quick-reply-btn.quick-reply-url {
    background: #e6f4ff;
    border: 1.5px solid #3399ff;
    color: #0066cc;
    box-shadow: 0 2px 12px rgba(0, 102, 204, 0.1);
    text-decoration: underline;
}

.chatbot-quick-reply-btn.quick-reply-url:hover {
    background: #cce6ff;
    color: #004a99;
    border-color: #3399ff;
    cursor: pointer;
}

.chatbot-quick-reply-btn.quick-reply-url i {
    margin-right: 6px;
    color: #3399ff;
    font-size: 15px;
}

/* Estilos para imágenes en el chat */
.chatbot-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

.chatbot-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chatbot-image-expanded {
    max-width: 100% !important;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Ajustes para móviles */
@media (max-width: 480px) {
    .chatbot-image {
        max-width: 200px;
        max-height: 170px;
    }
}

/* Estilos para texto en negrita */
.chatbot-message-text strong {
    font-weight: 700;
    color: inherit;
}

.chatbot-message-user .chatbot-message-text strong {
    color: white;
}

.chatbot-message-bot .chatbot-message-text strong {
    color: #333;
}

/* Mejoras para enlaces en el chat */
.chatbot-message-text a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.chatbot-message-user .chatbot-message-text a {
    color: rgba(255, 255, 255, 0.9);
}

.chatbot-message-bot .chatbot-message-text a {
    color: #229d9b;
}

.chatbot-message-text a:hover {
    opacity: 0.8;
} 