/**
 * Estilos Oficiales del Chatbot "Pregúntame"
 * Club de Pesca Mar-Sport (Port d'Arenys de Mar)
 * Estética Náutica Elegante (Azul Marino y Dorado)
 */

/* ==========================================================================
   1. CONTENEDOR RAÍZ Y BOTÓN LANZADOR FLOTANTE (LADO IZQUIERDO)
   ========================================================================== */
.ms-chatbot-root {
    position: fixed !important;
    bottom: 24px !important;
    left: 24px !important;
    right: auto !important;
    z-index: 999990 !important;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.ms-chatbot-launcher-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
}

/* Tooltip / Globo de Bienvenida */
.ms-chatbot-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 0 !important;
    right: auto !important;
    background: #091636;
    color: #ffffff;
    padding: 8px 14px 8px 16px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 25px rgba(9, 22, 54, 0.35);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    animation: msBounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ms-chatbot-tooltip:hover {
    transform: translateY(-2px);
    border-color: #f6d860;
}

.ms-chatbot-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 26px !important;
    right: auto !important;
    width: 12px;
    height: 12px;
    background: #091636;
    transform: rotate(45deg);
    border-right: 1px solid rgba(212, 175, 55, 0.4);
    border-bottom: 1px solid rgba(212, 175, 55, 0.4);
}

.ms-tooltip-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 50%;
    transition: color 0.2s ease;
}

.ms-tooltip-close:hover {
    color: #ffffff;
}

/* Botón Lanzador Circular Náutico */
.ms-chatbot-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px 10px 14px;
    background: linear-gradient(135deg, #091636 0%, #0e2352 60%, #d4af37 150%);
    color: #ffffff;
    border: 2px solid rgba(246, 216, 96, 0.4);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(9, 22, 54, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.ms-chatbot-launcher:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: #f6d860;
    box-shadow: 0 18px 40px rgba(9, 22, 54, 0.5), 0 0 20px rgba(212, 175, 55, 0.35);
}

.ms-chatbot-launcher:active {
    transform: translateY(0) scale(0.98);
}

/* Pulso animado */
.ms-launcher-pulse {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 999px;
    border: 2px solid #d4af37;
    animation: msPulseWave 2.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
    pointer-events: none;
    opacity: 0.75;
}

/* Badge de mensajes nuevos */
.ms-launcher-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e76f51;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    animation: msBadgeBounce 1s infinite alternate ease-in-out;
}

.ms-launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #f6d860;
    transition: transform 0.3s ease;
}

.ms-launcher-icon svg {
    display: block;
}

.ms-launcher-label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
}

/* Toggle de iconos (abrir/cerrar) */
.ms-chatbot-launcher .ms-icon-close {
    display: none;
}

.ms-chatbot-root.ms-chat-active .ms-chatbot-launcher .ms-icon-open {
    display: none;
}

.ms-chatbot-root.ms-chat-active .ms-chatbot-launcher .ms-icon-close {
    display: flex;
}

.ms-chatbot-root.ms-chat-active .ms-launcher-pulse {
    display: none;
}


/* ==========================================================================
   2. VENTANA PRINCIPAL DE CHAT
   ========================================================================== */
.ms-chatbot-window {
    position: absolute;
    bottom: calc(100% + 16px);
    left: 0 !important;
    right: auto !important;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 24px 55px -8px rgba(4, 13, 26, 0.45), 0 0 0 1px rgba(9, 22, 54, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left !important;
    animation: msChatScaleIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
    z-index: 999991;
}

/* Cabecera del Chat Náutico */
.ms-chat-header {
    background: linear-gradient(135deg, #040d1a 0%, #091636 60%, #0e2352 100%);
    border-bottom: 2px solid #d4af37;
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
}

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

.ms-chat-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    padding: 2px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

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

.ms-chat-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid #091636;
    border-radius: 50%;
    box-shadow: 0 0 6px #10b981;
}

.ms-chat-header-titles {
    display: flex;
    flex-direction: column;
}

.ms-chat-name {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: #f6d860;
    line-height: 1.2;
    letter-spacing: -0.2px;
    font-family: 'Outfit', sans-serif;
}

.ms-chat-subtitle {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: #cbd5e1;
    font-weight: 500;
}

.ms-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ms-chat-btn-text,
.ms-chat-btn-header {
    background: rgba(255, 255, 255, 0.16) !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    color: #ffffff !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    padding: 5px 9px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
    font-family: inherit !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15) !important;
}

.ms-chat-btn-text:hover,
.ms-chat-btn-header:hover {
    background: rgba(255, 255, 255, 0.28) !important;
    color: #f6d860 !important;
    border-color: #f6d860 !important;
    transform: translateY(-1px) !important;
}


/* ==========================================================================
   3. CUERPO DE MENSAJES Y BURBUJAS
   ========================================================================== */
.ms-chat-body {
    flex: 1;
    padding: 16px;
    background: #f8fafc;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ms-chat-body::-webkit-scrollbar {
    width: 5px;
}

.ms-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Filas de Mensaje */
.ms-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 90%;
    animation: msMsgFadeIn 0.25s ease-out both;
}

.ms-msg-row.ms-msg-bot {
    align-self: flex-start;
}

.ms-msg-row.ms-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ms-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #091636;
    color: #f6d860;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(9, 22, 54, 0.2);
}

.ms-msg-row.ms-msg-user .ms-msg-avatar {
    background: #0284c7;
    color: #ffffff;
}

/* Burbujas de contenido */
.ms-msg-bubble {
    padding: 12px 15px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.ms-msg-bot .ms-msg-bubble {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.ms-msg-user .ms-msg-bubble {
    background: linear-gradient(135deg, #091636 0%, #1e3a5f 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(9, 22, 54, 0.25);
}

.ms-msg-text {
    margin: 0;
}

.ms-msg-text p {
    margin: 0 0 8px;
}

.ms-msg-text p:last-child {
    margin-bottom: 0;
}

.ms-msg-text strong {
    color: #091636;
    font-weight: 700;
}

.ms-msg-user .ms-msg-text strong {
    color: #f6d860;
}

.ms-msg-text ul {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.ms-msg-text li {
    margin-bottom: 4px;
}

.ms-msg-time {
    display: block;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 5px;
    text-align: right;
}

.ms-msg-user .ms-msg-time {
    color: rgba(255, 255, 255, 0.65);
}

/* Botones de acción integrados en respuestas del bot */
.ms-msg-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.ms-msg-btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #091636;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ms-msg-btn-action:hover {
    background: #d4af37;
    color: #091636;
    border-color: #d4af37;
    transform: translateY(-1px);
}

.ms-msg-btn-action.ms-btn-action-primary {
    background: #d4af37;
    color: #091636;
    border-color: #b89428;
}

.ms-msg-btn-action.ms-btn-action-primary:hover {
    background: #f6d860;
}

/* Tarjetas miniatura de barcos en venta */
.ms-bot-boat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    margin-top: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    transition: border-color 0.2s ease;
}

.ms-bot-boat-card:hover {
    border-color: #d4af37;
}

.ms-bot-boat-img {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #091636;
}

.ms-bot-boat-details {
    flex: 1;
    min-width: 0;
}

.ms-bot-boat-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #091636;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Outfit', sans-serif;
}

.ms-bot-boat-meta {
    font-size: 11px;
    color: #64748b;
    margin: 2px 0 0;
}

.ms-bot-boat-price {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    margin-top: 4px;
}


/* ==========================================================================
   4. CHIPS DE PREGUNTAS FRECUENTES SUGERIDAS
   ========================================================================== */
.ms-quick-suggestions {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    margin-top: 4px;
}

.ms-suggestions-title {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

.ms-suggestions-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ms-suggestion-btn {
    text-align: left !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #091636 !important;
    padding: 10px 14px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    line-height: 1.35 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03) !important;
}

.ms-suggestion-btn:hover {
    background: #fef9c3 !important;
    border-color: #f6d860 !important;
    color: #854d0e !important;
    transform: translateX(4px) !important;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.25) !important;
}


/* ==========================================================================
   5. INDICADOR DE ESCRIBIENDO
   ========================================================================== */
.ms-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    color: #64748b;
}

.ms-typing-dot {
    width: 6px;
    height: 6px;
    background: #d4af37;
    border-radius: 50%;
    animation: msTypingBounce 1.2s infinite ease-in-out;
}

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

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

.ms-typing-text {
    margin-left: 6px;
    font-size: 11.5px;
    font-weight: 500;
}


/* ==========================================================================
   6. ÁREA INFERIOR DE ENTRADA Y FORMULARIO
   ========================================================================== */
.ms-chat-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 14px 10px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

.ms-chat-form {
    margin: 0;
}

.ms-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    padding: 6px 8px 6px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ms-chat-input-wrap:focus-within {
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
    background: #ffffff;
}

.ms-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    color: #0f172a;
    resize: none;
    max-height: 80px;
    min-height: 24px;
    padding: 4px 0;
    line-height: 1.4;
    outline: none;
}

.ms-chat-input::placeholder {
    color: #94a3b8;
}

.ms-chat-send-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 10px !important;
    border: none !important;
    background: linear-gradient(135deg, #091636 0%, #d4af37 100%) !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 3px 8px rgba(212, 175, 55, 0.4) !important;
}

.ms-chat-send-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 5px 14px rgba(212, 175, 55, 0.5) !important;
}

.ms-chat-send-btn:active {
    transform: scale(0.96) !important;
}

.ms-chat-send-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.ms-chat-send-btn svg {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    fill: #ffffff !important;
    stroke: none !important;
    color: #ffffff !important;
}

.ms-chat-send-btn svg path {
    fill: #ffffff !important;
    stroke: none !important;
}

.ms-chat-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
}

.ms-chat-wa-direct {
    color: #10b981;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.ms-chat-wa-direct:hover {
    color: #059669;
    text-decoration: underline;
}


/* ==========================================================================
   7. ANIMACIONES Y MEDIA QUERIES RESPONSIVAS
   ========================================================================== */
@keyframes msChatScaleIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes msBounceIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(-4px) scale(1.02);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes msPulseWave {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.12);
        opacity: 0.15;
    }
    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

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

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

@keyframes msTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-5px);
    }
}

/* Adaptación para pantallas móviles */
@media (max-width: 600px) {
    .ms-chatbot-root {
        bottom: 16px !important;
        left: 16px !important;
        right: auto !important;
    }

    .ms-launcher-label {
        display: none !important;
    }

    .ms-chatbot-launcher {
        padding: 12px !important;
        border-radius: 50% !important;
        width: 56px !important;
        height: 56px !important;
        justify-content: center !important;
    }

    .ms-chatbot-window {
        position: fixed !important;
        top: auto !important;
        left: 12px !important;
        right: 12px !important;
        bottom: 84px !important;
        width: calc(100% - 24px) !important;
        max-width: none !important;
        height: calc(100vh - 110px) !important;
        max-height: 580px !important;
        border-radius: 18px !important;
        transform-origin: bottom center !important;
    }

    .ms-chatbot-tooltip {
        display: none !important;
    }
}
