/**
 * BotamorSalud Chatbot - Estilos Frontend
 *
 * Estilos del chatbot conversacional con diseño tipo WhatsApp/Intercom.
 *
 * @package BotamorSalud_Chatbot
 * @since 1.0.0
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --botamorsalud-primary: #e74c3c !important;
    --botamorsalud-primary-dark: #c0392b !important;
    --botamorsalud-primary-light: #ff6b5b !important;
    --botamorsalud-bg: #ffffff !important;
    --botamorsalud-bg-alt: #f5f5f5 !important;
    --botamorsalud-text: #333333 !important;
    --botamorsalud-text-light: #666666 !important;
    --botamorsalud-border: #e0e0e0 !important;
    --botamorsalud-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    --botamorsalud-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    --botamorsalud-radius: 16px !important;
    --botamorsalud-radius-sm: 8px !important;
    --botamorsalud-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
#botamorsalud-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.5;
}

/* ============================================
   BOTÓN FLOTANTE
   ============================================ */
.botamorsalud-chatbot-toggle {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    width: 60px !important;
    height: 60px !important;
    background: #e74c3c !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 999999 !important;
}

.botamorsalud-chatbot-toggle:hover {
    background: #c0392b !important;
    transform: scale(1.05) !important;
}

.botamorsalud-chatbot-toggle:active {
    transform: scale(0.95);
}

.botamorsalud-chatbot-toggle:focus {
    outline: 2px solid var(--botamorsalud-primary);
    outline-offset: 2px;
}

.botamorsalud-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: var(--botamorsalud-transition);
}

.botamorsalud-chatbot-toggle .botamorsalud-icon-close {
    display: none;
}

.botamorsalud-chatbot-toggle.botamorsalud-is-active .botamorsalud-icon-heart {
    display: none;
}

.botamorsalud-chatbot-toggle.botamorsalud-is-active .botamorsalud-icon-close {
    display: block;
}

.botamorsalud-chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #27ae60;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: none;
    animation: botamorsalud-pulse 2s infinite;
}

/* ============================================
   VENTANA DEL CHAT
   ============================================ */
.botamorsalud-chatbot-window {
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--botamorsalud-bg);
    border-radius: var(--botamorsalud-radius);
    box-shadow: var(--botamorsalud-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--botamorsalud-transition);
}

.botamorsalud-chatbot-window.botamorsalud-is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============================================
   HEADER
   ============================================ */
.botamorsalud-chatbot-header {
    background: #e74c3c !important;
    color: #ffffff !important;
    padding: 16px 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
}

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

.botamorsalud-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.botamorsalud-chatbot-avatar svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.botamorsalud-chatbot-title-section {
    flex: 1;
}

.botamorsalud-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

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

.botamorsalud-chatbot-minimize {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--botamorsalud-transition);
}

.botamorsalud-chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

.botamorsalud-chatbot-minimize svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* ============================================
   ÁREA DE MENSAJES
   ============================================ */
.botamorsalud-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: var(--botamorsalud-bg-alt);
}

.botamorsalud-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.botamorsalud-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.botamorsalud-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--botamorsalud-border);
    border-radius: 3px;
}

.botamorsalud-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--botamorsalud-text-light);
}

/* ============================================
   MENSAJES
   ============================================ */
.botamorsalud-chatbot-message {
    display: flex;
    margin-bottom: 16px;
    animation: botamorsalud-fadeIn 0.3s ease;
}

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

.botamorsalud-user-message {
    justify-content: flex-end !important;
}

.botamorsalud-message-avatar {
    width: 32px !important;
    height: 32px !important;
    background: #e74c3c !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin-right: 8px !important;
}

.botamorsalud-message-avatar svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

.botamorsalud-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--botamorsalud-radius-sm);
    position: relative;
}

.botamorsalud-bot-message .botamorsalud-message-content {
    background: #ffffff !important;
    border-top-left-radius: 0 !important;
}

.botamorsalud-user-message .botamorsalud-message-content {
    background: #e74c3c !important;
    color: #ffffff !important;
    border-top-right-radius: 0 !important;
}

.botamorsalud-message-content p {
    margin: 0 0 4px 0;
    word-wrap: break-word;
}

.botamorsalud-message-content p:last-child {
    margin-bottom: 0;
}

.botamorsalud-message-time {
    font-size: 11px;
    opacity: 0.7;
    display: block;
    margin-top: 4px;
}

.botamorsalud-user-message .botamorsalud-message-time {
    color: #ffffff;
}

/* ============================================
   BOTONES EN MENSAJES
   ============================================ */
.botamorsalud-start-btn,
.botamorsalud-restart-btn {
    display: inline-block !important;
    padding: 10px 20px !important;
    background: #e74c3c !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin-top: 8px !important;
}

.botamorsalud-start-btn:hover,
.botamorsalud-restart-btn:hover {
    background: #c0392b !important;
}

/* ============================================
   RESULTADOS
   ============================================ */
.botamorsalud-results-message {
    background: #f9f9f9 !important;
    border-left: 4px solid #e74c3c !important;
    padding: 12px !important;
    border-radius: 4px !important;
}

.botamorsalud-results-message strong {
    color: #e74c3c !important;
    display: block !important;
    margin-bottom: 4px !important;
}

/* ============================================
   INDICADOR DE ESCRITURA
   ============================================ */
.botamorsalud-typing-indicator {
    display: flex;
    align-items: flex-end;
    margin-bottom: 16px;
}

.botamorsalud-typing-indicator .botamorsalud-message-avatar {
    margin-right: 8px;
}

.botamorsalud-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: var(--botamorsalud-radius-sm);
    border-top-left-radius: 0;
}

.botamorsalud-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--botamorsalud-text-light);
    border-radius: 50%;
    animation: botamorsalud-typing 1.4s infinite ease-in-out both;
}

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

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

/* ============================================
   ÁREA DE INPUT
   ============================================ */
.botamorsalud-chatbot-input-area {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid var(--botamorsalud-border);
    flex-shrink: 0;
}

.botamorsalud-chatbot-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.botamorsalud-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--botamorsalud-border);
    border-radius: 24px;
    font-size: 14px;
    transition: var(--botamorsalud-transition);
}

.botamorsalud-chatbot-input:focus {
    outline: none;
    border-color: var(--botamorsalud-primary);
}

.botamorsalud-chatbot-send {
    width: 40px !important;
    height: 40px !important;
    background: #e74c3c !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    flex-shrink: 0 !important;
}

.botamorsalud-chatbot-send:hover {
    background: #c0392b !important;
}

.botamorsalud-chatbot-send svg {
    width: 18px !important;
    height: 18px !important;
    color: #ffffff !important;
    margin-left: 2px !important;
}

/* ============================================
   OPCIONES DE RADIO
   ============================================ */
.botamorsalud-radio-form {
    display: block !important;
}

.botamorsalud-radio-options {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.botamorsalud-radio-option {
    display: flex !important;
    align-items: center !important;
    padding: 12px 16px !important;
    background: #ffffff !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.botamorsalud-radio-option:hover {
    border-color: #ff6b5b !important;
    background: #f5f5f5 !important;
}

.botamorsalud-radio-option.botamorsalud-selected {
    border-color: #e74c3c !important;
    background: rgba(231, 76, 60, 0.05) !important;
}

.botamorsalud-radio-option input[type="radio"] {
    display: none;
}

.botamorsalud-radio-option span {
    font-size: 14px !important;
    color: #333333 !important;
}

.botamorsalud-radio-option.botamorsalud-selected span {
    color: #e74c3c !important;
    font-weight: 500 !important;
}

/* ============================================
   FOOTER
   ============================================ */
.botamorsalud-chatbot-footer {
    padding: 12px 20px;
    background: var(--botamorsalud-bg-alt);
    border-top: 1px solid var(--botamorsalud-border);
    flex-shrink: 0;
}

.botamorsalud-chatbot-footer p {
    margin: 0;
    font-size: 11px;
    color: var(--botamorsalud-text-light);
    text-align: center;
    line-height: 1.4;
}

/* ============================================
   POSICIÓN IZQUIERDA
   ============================================ */
#botamorsalud-chatbot-container.bottom-left .botamorsalud-chatbot-toggle {
    right: auto;
    left: 20px;
}

#botamorsalud-chatbot-container.bottom-left .botamorsalud-chatbot-window {
    right: auto;
    left: 20px;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes botamorsalud-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

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

@keyframes botamorsalud-typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE / MOBILE
   ============================================ */
@media (max-width: 768px) {
    /* Botón */
    .botamorsalud-chatbot-toggle {
        width: 56px;
        height: 56px;
        right: 16px;
        bottom: 16px;
    }

    /* Ventana */
    .botamorsalud-chatbot-window {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .botamorsalud-chatbot-window.botamorsalud-is-open {
        transform: translateY(0);
    }

    /* Header */
    .botamorsalud-chatbot-header {
        padding: 14px 16px;
    }

    .botamorsalud-chatbot-title {
        font-size: 15px;
    }

    /* Mensajes */
    .botamorsalud-chatbot-messages {
        padding: 16px;
    }

    .botamorsalud-message-content {
        max-width: 80%;
    }

    /* Input */
    .botamorsalud-chatbot-input-area {
        padding: 12px 16px;
    }

    /* Footer */
    .botamorsalud-chatbot-footer {
        padding: 10px 16px;
    }

    /* Ajustes para posición izquierda */
    #botamorsalud-chatbot-container.bottom-left .botamorsalud-chatbot-toggle {
        left: 16px;
    }
}

@media (max-width: 480px) {
    .botamorsalud-message-content {
        max-width: 85%;
    }

    .botamorsalud-chatbot-input {
        padding: 10px 14px;
        font-size: 13px;
    }

    .botamorsalud-radio-option {
        padding: 10px 14px;
    }

    .botamorsalud-radio-option span {
        font-size: 13px;
    }
}

/* ============================================
   DARK MODE SUPPORT (opcional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Descomentar si se desea soporte para dark mode
    :root {
        --botamorsalud-bg: #1e1e1e;
        --botamorsalud-bg-alt: #2d2d2d;
        --botamorsalud-text: #e0e0e0;
        --botamorsalud-text-light: #a0a0a0;
        --botamorsalud-border: #404040;
    }

    .botamorsalud-bot-message .botamorsalud-message-content {
        background: #2d2d2d;
        color: #e0e0e0;
    }

    .botamorsalud-chatbot-input {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }

    .botamorsalud-radio-option {
        background: #2d2d2d;
        border-color: #404040;
    }

    .botamorsalud-radio-option:hover {
        background: #3d3d3d;
    }
    */
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
.botamorsalud-chatbot-toggle:focus-visible,
.botamorsalud-chatbot-send:focus-visible,
.botamorsalud-start-btn:focus-visible,
.botamorsalud-restart-btn:focus-visible {
    outline: 3px solid var(--botamorsalud-primary);
    outline-offset: 2px;
}

.botamorsalud-radio-option:focus-within {
    border-color: var(--botamorsalud-primary);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}
