/* ============================================
   STRAHLKRAFT40+ CHATBOT WIDGET STYLES
   Versión Centralizada - 2026-01-06
   ============================================ */

.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D4AF37 0%, #C5A059 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(212, 175, 55, 0.5);
}

.chatbot-toggle-icon,
.chatbot-toggle-close {
    font-size: 24px;
    transition: all 0.3s ease;
}

.chatbot-toggle-close {
    display: none;
    color: #121212;
    font-weight: bold;
}

/* Ocultar botón toggle completamente cuando el chat está abierto */
.chatbot-widget.open .chatbot-toggle {
    display: none;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100% - 48px);
    height: 520px;
    background: #1a1a1a;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #0E3A28 0%, #1a1a1a 100%);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #D4AF37, #C5A059);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-name {
    color: #FAFAF5;
    font-weight: 600;
    font-size: 14px;
}

.chatbot-status {
    color: #7CB342;
    font-size: 14px;
}

.chatbot-minimize {
    background: none;
    border: none;
    color: #FAFAF5;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-minimize:hover {
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
}

/* Messages Area */
.chatbot-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #121212;
}

.chat-message {
    display: flex;
    max-width: 85%;
}

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.bot .chat-bubble {
    background: #1e1e1e;
    color: #FAFAF5;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-bottom-left-radius: 4px;
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, #D4AF37 0%, #C5A059 100%);
    color: #121212;
    border-bottom-right-radius: 4px;
}

/* Quick Actions */
.chatbot-quick-actions {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #1a1a1a;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.quick-action {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #D4AF37;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #D4AF37;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    background: #1a1a1a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    background: #121212;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 12px 16px;
    color: #FAFAF5;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: rgba(212, 175, 55, 0.5);
}

#chatbot-input::placeholder {
    color: #666;
}

#chatbot-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #D4AF37 0%, #C5A059 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #121212;
    transition: transform 0.2s;
}

#chatbot-send:hover {
    transform: scale(1.05);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #D4AF37;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Backdrop oscuro detrás del chat */
.chatbot-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

/* Mostrar backdrop cuando el chat está abierto */
.chatbot-backdrop.show {
    display: block;
}

/* Bloquear scroll del body cuando chat está abierto (solo móviles) */
body.chatbot-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Tablet/Desktop - El JavaScript maneja los estilos inline */
@media (min-width: 481px) {
    .chatbot-window {
        width: 440px;
        height: 520px;
    }

    /* Ocultar backdrop en desktop */
    .chatbot-backdrop {
        display: none !important;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 16px;
        right: 16px;
        z-index: 10000;
    }

    .chatbot-widget.open .chatbot-window {
        /* Posicionamiento optimizado para máximo espacio vertical */
        position: fixed !important;
        top: 8px !important;
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
        transform: none !important;

        /* Tamaño: máximo aprovechamiento del viewport */
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;

        /* Resetear posicionamiento de desktop */
        margin: 0 !important;

        /* Z-index por encima del backdrop */
        z-index: 10001 !important;

        /* Display flex asegurado con expansión completa */
        display: flex !important;
        flex-direction: column !important;

        /* iOS Safari fixes */
        -webkit-overflow-scrolling: touch;
    }

    .chatbot-toggle {
        width: 54px;
        height: 54px;
        z-index: 10002;
        /* iOS Safari fix para better touch response */
        -webkit-tap-highlight-color: transparent;
    }

    .chatbot-messages {
        /* iOS smooth scrolling */
        -webkit-overflow-scrolling: touch;
        overflow-y: auto !important;
        max-height: none !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }

    #chatbot-input {
        /* Prevenir zoom en iOS */
        font-size: 16px !important;
    }

    .chatbot-backdrop {
        z-index: 9999;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iPhone X+ safe area */
    .chatbot-widget {
        bottom: max(16px, env(safe-area-inset-bottom));
        right: max(16px, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .chatbot-widget.open .chatbot-window {
            top: max(8px, env(safe-area-inset-top)) !important;
            bottom: max(8px, env(safe-area-inset-bottom)) !important;
            left: 8px !important;
            right: 8px !important;
        }
    }

    @media (min-width: 481px) {
        .chatbot-window {
            bottom: 80px;
        }
    }

    /* Fix para cuando el teclado aparece en iOS */
    .chatbot-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}
