/**
 * Estilos Oficiales del Chatbot "Pregúntame"
 * Associació Catalana de Guies de Pesca (ACGP)
 * Diseño Moderno, Accesible y Adaptativo (Mobile-First)
 */

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

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

/* Tooltip / Globo de Bienvenida */
.acgp-chatbot-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 0 !important;
    right: auto !important;
    background: #0a2540;
    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(10, 37, 64, 0.28);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(0, 168, 150, 0.35);
    animation: acgpBounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.acgp-chatbot-tooltip:hover {
    transform: translateY(-2px);
    border-color: #38bdf8;
}

.acgp-chatbot-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 26px !important;
    right: auto !important;
    width: 12px;
    height: 12px;
    background: #0a2540;
    transform: rotate(45deg);
    border-right: 1px solid rgba(0, 168, 150, 0.35);
    border-bottom: 1px solid rgba(0, 168, 150, 0.35);
}

.acgp-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;
}

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

/* Botón Lanzador Circular */
.acgp-chatbot-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px 10px 14px;
    background: linear-gradient(135deg, #0a2540 0%, #061829 50%, #00a896 150%);
    color: #ffffff;
    border: 2px solid rgba(56, 189, 248, 0.35);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(10, 37, 64, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.acgp-chatbot-launcher:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: #38bdf8;
    box-shadow: 0 18px 40px rgba(0, 168, 150, 0.4), 0 0 20px rgba(56, 189, 248, 0.25);
}

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

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

/* Badge de mensajes nuevos */
.acgp-launcher-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    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: acgpBadgeBounce 1s infinite alternate ease-in-out;
}

.acgp-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: #38bdf8;
    transition: transform 0.3s ease;
}

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

.acgp-launcher-label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
}

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

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

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

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


/* ==========================================================================
   2. VENTANA PRINCIPAL DE CHAT
   ========================================================================== */
.acgp-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(6, 24, 41, 0.38), 0 0 0 1px rgba(10, 37, 64, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left !important;
    animation: acgpChatScaleIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
    z-index: 999991;
}

/* Cabecera del Chat */
.acgp-chat-header {
    background: linear-gradient(135deg, #061829 0%, #0a2540 60%, #00a896 150%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 2;
}

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

.acgp-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.25);
    flex-shrink: 0;
}

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

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

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

.acgp-chat-name {
    margin: 0;
    font-size: 16.5px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.acgp-chat-subtitle {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: #94a3b8;
    font-weight: 500;
}

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

.acgp-chat-btn-text,
.acgp-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;
}

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


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

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

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

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

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

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

.acgp-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0a2540;
    color: #ffffff;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(10, 37, 64, 0.15);
}

.acgp-msg-row.acgp-msg-user .acgp-msg-avatar {
    background: #00a896;
}

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

.acgp-msg-bot .acgp-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);
}

.acgp-msg-user .acgp-msg-bubble {
    background: linear-gradient(135deg, #0a2540 0%, #1e3a5f 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(10, 37, 64, 0.2);
}

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

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

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

.acgp-msg-text strong {
    color: #0a2540;
    font-weight: 700;
}

.acgp-msg-user .acgp-msg-text strong {
    color: #38bdf8;
}

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

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

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

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

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

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

.acgp-msg-btn-action:hover {
    background: #00a896;
    color: #ffffff;
    border-color: #00a896;
    transform: translateY(-1px);
}

.acgp-msg-btn-action.acgp-btn-action-primary {
    background: #00a896;
    color: #ffffff;
    border-color: #00a896;
}

.acgp-msg-btn-action.acgp-btn-action-primary:hover {
    background: #008f80;
}

/* Tarjetas miniatura de guías encontrados */
.acgp-bot-guide-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    margin-top: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.acgp-bot-guide-img {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #e2e8f0;
}

.acgp-bot-guide-details {
    flex: 1;
    min-width: 0;
}

.acgp-bot-guide-name {
    font-size: 13px;
    font-weight: 700;
    color: #0a2540;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.acgp-bot-guide-ropec {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    margin-top: 3px;
}


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

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

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

.acgp-suggestion-btn {
    text-align: left !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #0a2540 !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;
}

.acgp-suggestion-btn:hover {
    background: #e0f2fe !important;
    border-color: #38bdf8 !important;
    color: #0369a1 !important;
    transform: translateX(4px) !important;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.18) !important;
}


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

.acgp-typing-dot {
    width: 6px;
    height: 6px;
    background: #00a896;
    border-radius: 50%;
    animation: acgpTypingBounce 1.2s infinite ease-in-out;
}

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

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

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


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

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

.acgp-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;
}

.acgp-chat-input-wrap:focus-within {
    border-color: #00a896;
    box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.15);
    background: #ffffff;
}

.acgp-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;
}

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

.acgp-chat-send-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 10px !important;
    border: none !important;
    background: linear-gradient(135deg, #00a896 0%, #0a2540 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(0, 168, 150, 0.4) !important;
}

.acgp-chat-send-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 5px 14px rgba(0, 168, 150, 0.5) !important;
}

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

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

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

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

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

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

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


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

@keyframes acgpBounceIn {
    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 acgpPulseWave {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.12);
        opacity: 0.15;
    }
    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

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

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

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

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

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

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

    .acgp-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;
    }

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