/**
 * Copyright since 2026 Ecom Experts
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License version 3.0
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 *
 * @author    Ecom Experts <ecomyseo@gmail.com>
 * @copyright Since 2026 Ecom Experts
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
 */

:root {
    --mag-qa-primary: #2563eb;
    --mag-qa-border: #e5e7eb;
    --mag-qa-bg: #f9fafb;
    --mag-qa-text: #1f2937;
    --mag-qa-side-width: 30%;
    /* Skin variables (overridden per-theme via PHP hookDisplayHeader) */
    --mag-qa-container-bg: #ffffff;
    --mag-qa-header-bg: #2563eb;
    --mag-qa-header-text: #ffffff;
    --mag-qa-radius: 12px;
    --mag-qa-item-radius: 8px;
    --mag-qa-shadow: 0 4px 6px -1px rgba(0,0,0,.1);
    --mag-qa-btn-text: #ffffff;
    --mag-qa-font: 'Inter', system-ui, -apple-system, sans-serif;
}

.mag-qa-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--mag-qa-container-bg);
    border: 1px solid var(--mag-qa-border);
    border-radius: var(--mag-qa-radius);
    font-family: var(--mag-qa-font);
    color: var(--mag-qa-text);
    box-shadow: var(--mag-qa-shadow);
}

.mag-qa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--mag-qa-border);
}

.mag-qa-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--mag-qa-text);
}

.mag-qa-status-pill {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: #ecfdf5;
    color: #059669;
    border-radius: 9999px;
    font-weight: 500;
}

.mag-qa-social-proof {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #059669;
    background: #f0fdf4;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid #dcfce7;
}

.mag-qa-social-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    animation: mag-pulse-green 2s infinite;
}

@keyframes mag-pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Accordion */
.mag-qa-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mag-qa-item {
    border: 1px solid var(--mag-qa-border);
    border-radius: var(--mag-qa-item-radius);
    overflow: hidden;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    background: var(--mag-qa-container-bg);
}

.mag-qa-item:hover {
    border-color: var(--mag-qa-primary);
    background: var(--mag-qa-bg);
}

.mag-qa-question-row {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mag-qa-icon {
    width: 24px;
    height: 24px;
    background: var(--mag-qa-primary);
    color: var(--mag-qa-btn-text);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

.mag-qa-text {
    flex: 1;
    font-weight: 600;
    color: var(--mag-qa-text);
    font-size: 0.95rem;
}

/* Search Area */
.mag-qa-input-area {
    margin-top: 1.5rem;
}

.mag-qa-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.mag-qa-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--mag-qa-border);
    border-radius: var(--mag-qa-item-radius);
    outline: none;
    background: var(--mag-qa-container-bg);
    color: var(--mag-qa-text);
}

.mag-qa-input-wrapper button {
    background: var(--mag-qa-primary);
    color: var(--mag-qa-btn-text);
    border: none;
    padding: 0 1.5rem;
    border-radius: var(--mag-qa-item-radius);
    font-weight: 600;
    cursor: pointer;
}

/* Popup / Terminal */
#mag-qa-popup {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 400px;
    height: 550px;
    background: var(--mag-qa-container-bg);
    /* El popup se mueve a <body> por JS: no hereda de .mag-qa-container,
       asi que necesita su propia fuente y color de texto de la skin. */
    font-family: var(--mag-qa-font);
    color: var(--mag-qa-text);
    border-radius: var(--mag-qa-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 2147483647 !important;
    border: 1px solid var(--mag-qa-border);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mag-qa-popup.mag-qa-popup-hidden {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

/* Side Mode Base */
#mag-qa-popup.mag-qa-side-mode {
    top: 0;
    bottom: 0;
    height: 100vh;
    width: var(--mag-qa-side-width);
    border-radius: 0;
}

#mag-qa-popup.mag-qa-side-right {
    right: 0;
    left: auto;
    border-left: 1px solid var(--mag-qa-border);
}

#mag-qa-popup.mag-qa-side-left {
    left: 0;
    right: auto;
    border-right: 1px solid var(--mag-qa-border);
}

.mag-qa-popup-header {
    padding: 1rem;
    background: var(--mag-qa-header-bg);
    color: var(--mag-qa-header-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mag-qa-popup-title {
    font-weight: 700;
    font-size: 1rem;
}

#mag-qa-close-popup {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--mag-qa-header-text);
    width: 56px;
    /* Exactamente el doble de 28px */
    height: 56px;
    font-size: 2.2rem;
    /* El doble de tamaño visual */
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#mag-qa-close-popup:hover {
    background: rgba(255, 255, 255, 0.4);
}

.mag-qa-popup-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--mag-qa-bg);
    color: var(--mag-qa-text);
}

.mag-qa-msg {
    max-width: 80%;
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
    line-height: 1.5;
    /* El prompt pide saltos de linea REALES para listar medidas y precios,
       y los mensajes de error de depuracion tambien son multilinea. */
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.mag-msg-user {
    align-self: flex-end;
    background: var(--mag-qa-primary);
    color: var(--mag-qa-btn-text);
    border-radius: 20px 20px 4px 20px;
    margin-left: 20%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mag-msg-ai {
    align-self: flex-start;
    background: var(--mag-qa-container-bg);
    color: var(--mag-qa-text);
    border-radius: 20px 20px 20px 4px;
    margin-right: 20%;
    border: 1px solid var(--mag-qa-border);
}

.mag-msg-system {
    align-self: center;
    background: var(--mag-qa-container-bg);
    color: var(--mag-qa-text);
    opacity: .85;
    font-size: 0.8rem;
    text-align: center;
    max-width: 90%;
    padding: 0.5rem 1rem;
    border-radius: var(--mag-qa-item-radius);
    border: 1px dashed var(--mag-qa-border);
    box-shadow: none;
    font-style: italic;
}

.mag-qa-buy-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: #22c55e;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mag-qa-popup-footer {
    padding: 1rem;
    background: var(--mag-qa-container-bg);
    border-top: 1px solid var(--mag-qa-border);
}

.mag-qa-popup-input-group {
    display: flex;
    gap: 0.5rem;
}

.mag-qa-popup-input-group input {
    flex: 1;
    border: 1px solid var(--mag-qa-border);
    padding: 0.6rem;
    border-radius: var(--mag-qa-item-radius);
    outline: none;
    background: var(--mag-qa-container-bg);
    color: var(--mag-qa-text);
}

.mag-qa-popup-input-group button {
    background: var(--mag-qa-primary);
    color: var(--mag-qa-btn-text);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mag-qa-popup-input-group button:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.mag-qa-popup-input-group button svg {
    width: 20px;
    height: 20px;
    transform: translateX(1px) translateY(-1px);
}

/* Mobile Optimization & Font Fixes */
@media screen and (max-width: 768px) {
    .mag-qa-container {
        padding: 1rem;
        font-size: 14px !important;
    }

    .mag-qa-title {
        font-size: 16px !important;
        /* Force px to avoid huge rem scaling */
    }

    .mag-qa-text {
        font-size: 14px !important;
    }

    .mag-qa-answer-content {
        font-size: 14px !important;
        line-height: 1.5;
    }

    .mag-qa-status-pill {
        font-size: 11px !important;
    }

    .mag-qa-input-wrapper input,
    .mag-qa-popup-input-group input,
    .mag-qa-msg {
        font-size: 14px !important;
    }

    /* Popup on Mobile: Adaptive Size */
    #mag-qa-popup {
        width: 94% !important;
        left: 3% !important;
        right: 3% !important;
        bottom: 10px !important;
        height: 70vh !important;
        border-radius: 12px !important;
    }

    /* Reset Side Mode on Mobile to behave like a bottom sheet or full modal */
    #mag-qa-popup.mag-qa-side-mode {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
    }

    .mag-qa-popup-header {
        padding: 0.8rem;
    }
}

/* Typing / Loading Animation */
.mag-qa-typing-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mag-qa-typing-text {
    font-size: 0.8rem;
    color: var(--mag-qa-text);
    opacity: .7;
    font-style: italic;
}

.mag-qa-typing-dots {
    display: flex;
    gap: 4px;
}

.mag-qa-dot {
    width: 6px;
    height: 6px;
    background: var(--mag-qa-primary);
    border-radius: 50%;
    animation: mag-typing-bounce 1.4s infinite ease-in-out both;
}

.mag-qa-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.mag-qa-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes mag-typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}
/* =========================================================================
   DISEÑOS DE PRESENTACIÓN (LAYOUTS)
   Se aplican con la clase mag-layout-* sobre .mag-qa-container.
   Todos reutilizan las variables de skin, no fijan colores propios.
   ========================================================================= */

/* Icono de destello: oculto por defecto, visible en los diseños modernos */
.mag-qa-spark {
    display: none;
    width: 1.1em;
    height: 1.1em;
    flex-shrink: 0;
    color: var(--mag-qa-primary);
}

.mag-qa-spark svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Área CTA: oculta por defecto (solo la usan pills, banner y cards) */
.mag-qa-cta-area {
    display: none;
    margin-top: 1rem;
}

.mag-qa-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--mag-qa-primary);
    color: var(--mag-qa-btn-text);
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: filter .2s ease, transform .2s ease;
}

.mag-qa-cta-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.mag-qa-cta-btn .mag-qa-spark {
    display: inline-block;
    color: var(--mag-qa-btn-text);
}

/* -------------------------------------------------------------------------
   1) CLASSIC — Caja separada con acordeón (comportamiento histórico)
   ------------------------------------------------------------------------- */
/* Sin reglas: es el estilo base del fichero. */

/* -------------------------------------------------------------------------
   2) PILLS — Caja separada, preguntas como píldoras + CTA (estilo Doofinder)
   ------------------------------------------------------------------------- */
.mag-layout-pills {
    padding: 1.25rem 1.5rem;
    box-shadow: none;
    background: var(--mag-qa-bg);
}

.mag-layout-pills .mag-qa-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 1rem;
}

.mag-layout-pills .mag-qa-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.15rem;
}

.mag-layout-pills .mag-qa-title .mag-qa-spark {
    display: inline-block;
}

.mag-layout-pills .mag-qa-accordion {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.mag-layout-pills .mag-qa-item {
    flex: 0 0 auto;
    border: 1px solid var(--mag-qa-primary);
    border-radius: 9999px;
    background: var(--mag-qa-container-bg);
    overflow: visible;
}

.mag-layout-pills .mag-qa-item:hover {
    background: var(--mag-qa-primary);
}

.mag-layout-pills .mag-qa-item:hover .mag-qa-text {
    color: var(--mag-qa-btn-text);
}

.mag-layout-pills .mag-qa-question-row {
    padding: 0.5rem 1.1rem;
}

.mag-layout-pills .mag-qa-icon,
.mag-layout-pills .mag-qa-chevron,
.mag-layout-pills .mag-qa-answer-block,
.mag-layout-pills .mag-qa-input-area {
    display: none !important;
}

.mag-layout-pills .mag-qa-text {
    font-weight: 500;
    font-size: 0.88rem;
    white-space: nowrap;
}

.mag-layout-pills .mag-qa-cta-area {
    display: block;
}

/* -------------------------------------------------------------------------
   3) INLINE — Caja DENTRO de la caja de producto (sin marco propio)
   ------------------------------------------------------------------------- */
.mag-layout-inline {
    margin: 1rem 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.mag-layout-inline .mag-qa-header {
    margin-bottom: 0.9rem;
    padding-bottom: 0.6rem;
}

.mag-layout-inline .mag-qa-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.mag-layout-inline .mag-qa-title .mag-qa-spark {
    display: inline-block;
}

.mag-layout-inline .mag-qa-accordion {
    gap: 0.4rem;
}

.mag-layout-inline .mag-qa-item {
    border-width: 0 0 0 3px;
    border-left-style: solid;
    border-left-color: var(--mag-qa-border);
    border-radius: 0;
    background: transparent;
}

.mag-layout-inline .mag-qa-item:hover {
    border-left-color: var(--mag-qa-primary);
    background: transparent;
}

.mag-layout-inline .mag-qa-question-row {
    padding: 0.55rem 0.9rem;
}

.mag-layout-inline .mag-qa-icon {
    display: none;
}

.mag-layout-inline .mag-qa-input-area {
    margin-top: 1rem;
}

/* -------------------------------------------------------------------------
   4) BANNER — Barra compacta de una línea: título + CTA
   ------------------------------------------------------------------------- */
.mag-layout-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.25rem 0;
    padding: 0.9rem 1.25rem;
}

.mag-layout-banner .mag-qa-accordion-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
}

.mag-layout-banner .mag-qa-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
    flex: 1 1 auto;
    justify-content: flex-start;
    gap: 0.9rem;
}

.mag-layout-banner .mag-qa-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.mag-layout-banner .mag-qa-title .mag-qa-spark {
    display: inline-block;
}

.mag-layout-banner .mag-qa-accordion,
.mag-layout-banner .mag-qa-input-area {
    display: none !important;
}

.mag-layout-banner .mag-qa-cta-area {
    display: block;
    margin-top: 0;
    flex: 0 0 auto;
}

/* -------------------------------------------------------------------------
   5) CARDS — Preguntas en rejilla de tarjetas
   ------------------------------------------------------------------------- */
.mag-layout-cards .mag-qa-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mag-layout-cards .mag-qa-title .mag-qa-spark {
    display: inline-block;
}

.mag-layout-cards .mag-qa-accordion {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.75rem;
}

.mag-layout-cards .mag-qa-item {
    display: flex;
    align-items: stretch;
}

.mag-layout-cards .mag-qa-question-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 1rem;
    width: 100%;
}

.mag-layout-cards .mag-qa-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 0.9rem;
}

.mag-layout-cards .mag-qa-chevron {
    display: none;
}

.mag-layout-cards .mag-qa-text {
    font-size: 0.9rem;
    line-height: 1.35;
}

.mag-layout-cards .mag-qa-cta-area {
    display: block;
}

/* Responsive de los layouts */
@media screen and (max-width: 768px) {
    .mag-layout-pills .mag-qa-text {
        white-space: normal;
    }

    .mag-layout-banner,
    .mag-layout-banner .mag-qa-accordion-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .mag-layout-cards .mag-qa-accordion {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   CORRECCIÓN DE COLOCACIÓN SEGÚN EL HOOK
   Varios hooks de la ficha caen DENTRO de un contenedor flex o grid del tema
   (el formulario de añadir al carrito, la fila de botones...). Sin esto el
   bloque se convierte en una columna más y se ve pegado a la derecha del
   botón de comprar, en vez de debajo y a todo el ancho.
   ========================================================================= */
.mag-qa-container.mag-hook-displayProductActions,
.mag-qa-container.mag-hook-displayProductButtons,
.mag-qa-container.mag-hook-displayProductCartRight,
.mag-qa-container.mag-hook-displayProductVariants,
.mag-qa-container.mag-hook-displayProductPriceBlock,
.mag-qa-container.mag-hook-displayReassurance {
    /* Si el padre es flex: ocupar toda la fila y colocarse el último */
    flex: 1 1 100% !important;
    order: 99;
    /* Si el padre es grid: abarcar todas las columnas */
    grid-column: 1 / -1;
    /* Si el padre usa floats: romper la línea */
    clear: both;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* En columna lateral el ancho lo manda el tema, no forzamos nada */
.mag-qa-container.mag-hook-displayLeftColumnProduct,
.mag-qa-container.mag-hook-displayRightColumnProduct {
    margin: 1rem 0;
}

/* Dentro de la pestaña propia no hace falta marco doble ni margen superior */
.mag-qa-container.mag-hook-displayProductExtraContent {
    margin-top: 0;
}
