/* ===== CHATBOT WIDGET STYLES ===== */

/* Widget Container */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Estilos por defecto para desktop - NO cambiar posición del widget */

/* Chat Button */
.chat-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #C9A876, #b8985a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(201, 169, 118, 0.4);
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
    padding: 5px;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(201, 169, 118, 0.5);
}

.chat-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.chat-button i {
    font-size: 24px;
    color: white;
    transition: all 0.3s ease;
    display: none; /* Ocultar icono cuando se use imagen */
}

.chat-button.active img {
    transform: rotate(5deg) scale(1.1);
}

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

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

/* Chat Window - DESKTOP por defecto - Tamaño optimizado */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    animation: slideUp 0.3s ease-out;
    z-index: 10000;
}

.chat-window.active {
    display: flex;
}

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

/* Animación específica para móviles - centrado en pantalla */
@keyframes slideUpMobile {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #C9A876, #b8985a);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

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

.chat-avatar i {
    color: white;
}

.chat-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Body */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f8f9fa;
}

/* Messages */
.message {
    display: flex;
    gap: 10px;
    animation: fadeInMessage 0.3s ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

/* Message Avatar */
.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #C9A876, #b8985a);
    color: white;
    border: 1px solid rgba(201, 169, 118, 0.3);
}

.message.bot .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message.user .message-avatar {
    background: #e3f2fd;
    color: #1976d2;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.message.bot .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: linear-gradient(135deg, #C9A876, #b8985a);
    color: white;
    border-bottom-right-radius: 8px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-action {
    padding: 8px 12px;
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    color: #333;
}

.quick-action:hover {
    background: #C9A876;
    color: white;
    border-color: #C9A876;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

/* Chat Input */
.chat-input {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.input-container input:focus {
    border-color: #C9A876;
}

.send-button {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #C9A876, #b8985a);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.send-button:hover {
    transform: scale(1.1);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* MÓVIL: Widget se mantiene en esquina inferior derecha */
    .chatbot-widget {
        bottom: 20px;
        right: 20px;
        /* NO centrar el widget, mantener en esquina */
    }
    
    .chat-button {
        width: 60px;
        height: 60px;
        box-shadow: 0 4px 20px rgba(201, 169, 118, 0.5);
    }
    
    /* MÓVIL: Chat window se centra en pantalla */
    .chat-window {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        height: 75vh;
        max-width: 400px;
        max-height: 580px;
        min-height: 480px;
        bottom: auto;
        right: auto;
        border-radius: 20px;
        animation: slideUpMobile 0.4s ease-out;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    }
    
    .chat-header {
        padding: 20px;
        gap: 15px;
        border-radius: 20px 20px 0 0;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .chat-info h4 {
        font-size: 16px;
    }
    
    .chat-info p {
        font-size: 12px;
    }
    
    .chat-body {
        padding: 20px;
        gap: 15px;
        flex: 1;
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 16px;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .quick-actions {
        gap: 8px;
        margin-top: 10px;
    }
    
    .quick-action {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 18px;
    }
    
    .message-option {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 12px;
    }
    
    .whatsapp-redirect {
        padding: 12px 16px;
        font-size: 13px;
        border-radius: 12px;
    }
    
    .typing-indicator {
        padding: 10px 14px;
    }
    
    .typing-dot {
        width: 6px;
        height: 6px;
    }
    
    .chat-input {
        padding: 20px;
        border-radius: 0 0 20px 20px;
    }
    
    .input-container input {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 25px;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .chat-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
        /* Mantener en esquina inferior derecha */
    }
    
    .chat-button {
        width: 55px;
        height: 55px;
    }
    
    .chat-window {
        width: 95vw;
        height: 80vh;
        max-width: none;
        min-height: 450px;
        border-radius: 15px;
        /* Mantener centrado en pantalla */
    }
    
    .chat-header {
        padding: 15px;
        gap: 12px;
        border-radius: 15px 15px 0 0;
    }
    
    .chat-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .chat-info h4 {
        font-size: 15px;
        font-weight: 600;
    }
    
    .chat-info p {
        font-size: 11px;
    }
    
    .chat-body {
        padding: 15px;
        gap: 12px;
    }
    
    .message {
        gap: 8px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 13px;
        line-height: 1.3;
        border-radius: 15px;
    }
    
    .message.bot .message-content {
        border-bottom-left-radius: 6px;
    }
    
    .message.user .message-content {
        border-bottom-right-radius: 6px;
    }
    
    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .quick-actions {
        gap: 6px;
        margin-top: 8px;
    }
    
    .quick-action {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 15px;
    }
    
    .message-options {
        gap: 8px;
        margin-top: 8px;
    }
    
    .message-option {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 10px;
    }
    
    .whatsapp-redirect {
        padding: 10px 14px;
        font-size: 12px;
        border-radius: 10px;
        margin-top: 8px;
    }
    
    .typing-indicator {
        padding: 8px 12px;
    }
    
    .typing-dots {
        gap: 3px;
    }
    
    .typing-dot {
        width: 5px;
        height: 5px;
    }
    
    .chat-input {
        padding: 15px;
        border-radius: 0 0 15px 15px;
    }
    
    .input-container {
        gap: 10px;
    }
    
    .input-container input {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 20px;
    }
    
    .send-button {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .chat-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
}

@media (max-width: 360px) {
    .chat-window {
        width: 98vw;
        height: 85vh;
        min-height: 420px;
        border-radius: 12px;
        /* Mantener centrado en pantalla */
    }
    
    .chat-header {
        padding: 12px;
        border-radius: 12px 12px 0 0;
    }
    
    .chat-body {
        padding: 12px;
    }
    
    .message-content {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .quick-action {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .chat-input {
        padding: 12px;
        border-radius: 0 0 12px 12px;
    }
    
    .input-container input {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .send-button {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

/* Overlay SOLO para móviles cuando el chat está abierto */
.chat-overlay {
    display: none; /* Por defecto oculto en desktop */
}

@media (max-width: 768px) {
    .chat-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 9999;
        display: none;
        backdrop-filter: blur(3px);
    }
    
    .chat-overlay.active {
        display: block;
    }
    
    .chat-window {
        z-index: 10001;
    }
    
    .chatbot-widget {
        z-index: 10002;
    }
}

/* Mejoras específicas para la imagen del bot */
.chat-button img,
.chat-avatar img,
.message-avatar img {
    transition: all 0.3s ease;
    background: white;
    padding: 2px;
}

.chat-button:hover img {
    transform: scale(1.05) rotate(2deg);
}

/* Fallback para cuando no carga la imagen */
.chat-button i.fallback,
.chat-avatar i.fallback,
.message-avatar i.fallback {
    display: flex !important;
}
@media (hover: none) and (pointer: coarse) {
    .chat-button:hover {
        transform: scale(1.05);
    }
    
    .quick-action:hover,
    .message-option:hover {
        background: #C9A876;
        color: white;
        transform: none;
    }
    
    .contact-method:hover,
    .send-button:hover,
    .chat-close:hover {
        transform: none;
    }
}

/* Accessibility */
.chat-button:focus,
.quick-action:focus,
.send-button:focus,
.chat-close:focus {
    outline: 2px solid #C9A876;
    outline-offset: 2px;
}

/* Special Message Types */
.message-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.message-option {
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
    font-size: 14px;
}

.message-option:hover {
    background: #C9A876;
    color: white;
    border-color: #C9A876;
}

.whatsapp-redirect {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    text-align: center;
    margin-top: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.whatsapp-redirect:hover {
    transform: translateY(-2px);
}

.whatsapp-redirect i {
    margin-right: 8px;
}

/* ===== NUEVOS ESTILOS PARA BOTÓN WHATSAPP PERMANENTE ===== */

.permanent-whatsapp-btn {
    margin: 15px 0;
    text-align: center;
    position: sticky;
    bottom: 10px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 8px;
    border: 2px solid #25D366;
    box-shadow: 0 2px 10px rgba(37, 211, 102, 0.2);
}

.whatsapp-sticky-button {
    background: linear-gradient(135deg, #25D366, #20c157);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    outline: none;
}

.whatsapp-sticky-button:hover {
    background: linear-gradient(135deg, #20c157, #1eb855);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.whatsapp-sticky-button i {
    font-size: 18px;
    animation: pulse 2s infinite;
}

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

/* ===== ESTILOS MEJORADOS PARA BOTONES DE MENÚ ===== */

.chat-button-enhanced {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px solid #C9A876;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    min-height: 55px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

.chat-button-enhanced:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #C9A876;
    transition: all 0.3s ease;
}

.chat-button-enhanced:hover {
    background: linear-gradient(135deg, #C9A876, #b8985a);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(201, 169, 118, 0.3);
}

.chat-button-enhanced:hover:before {
    width: 100%;
    z-index: -1;
}

.chat-button-icon {
    font-size: 18px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button-content {
    flex: 1;
}

.chat-button-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 3px;
    line-height: 1.2;
}

.chat-button-description {
    font-size: 11px;
    opacity: 0.7;
    line-height: 1.3;
}

/* ===== ESTILOS PARA MENSAJES CON BOTONES MEJORADOS ===== */

.message.bot .message-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 6px;
}

.message.bot .message-buttons.menu-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

/* Responsive para botones de menú */
@media (max-width: 768px) {
    .message.bot .message-buttons.menu-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .chat-button-enhanced {
        min-height: 55px;
        padding: 12px 14px;
        margin: 5px;
        gap: 12px;
    }
    
    .chat-button-icon {
        font-size: 18px;
        min-width: 22px;
    }
    
    .chat-button-title {
        font-size: 14px;
        margin-bottom: 3px;
    }
    
    .chat-button-description {
        font-size: 12px;
        line-height: 1.3;
    }
    
    .chat-button-title {
        font-size: 13px;
    }
    
    .chat-button-description {
        font-size: 11px;
    }
    
    .permanent-whatsapp-btn {
        margin: 10px 0;
        padding: 6px;
    }
    
    .whatsapp-sticky-button {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .chat-button-enhanced {
        min-height: 45px;
        padding: 8px 12px;
        margin: 3px;
    }
    
    .chat-button-icon {
        font-size: 18px;
        min-width: 20px;
    }
}

/* ===== ANIMACIONES PARA BOTONES ===== */

.chat-button-enhanced {
    animation: slideInUp 0.3s ease-out;
}

.chat-button-enhanced:nth-child(1) { animation-delay: 0.1s; }
.chat-button-enhanced:nth-child(2) { animation-delay: 0.2s; }
.chat-button-enhanced:nth-child(3) { animation-delay: 0.3s; }
.chat-button-enhanced:nth-child(4) { animation-delay: 0.4s; }
.chat-button-enhanced:nth-child(5) { animation-delay: 0.5s; }
.chat-button-enhanced:nth-child(6) { animation-delay: 0.6s; }

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