/* ==========================================================
   MER-IA · Asistente de MercadoRioja
   Mejora exclusivamente visual.
   Mantiene las mismas clases y no modifica la lógica existente.
   ========================================================== */

.meria-assistant {
    --meria-primary: #01bfa6;
    --meria-primary-dark: #009f8a;
    --meria-primary-soft: #e8fbf7;
    --meria-dark: #172033;
    --meria-dark-2: #0f1727;
    --meria-text: #243044;
    --meria-muted: #6b7280;
    --meria-border: rgba(15, 23, 39, 0.10);
    --meria-surface: #ffffff;
    --meria-background: #f4f7f9;

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: var(--meria-text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.meria-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 18px 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--meria-dark), var(--meria-dark-2));
    color: #fff;
    box-shadow:
        0 18px 40px rgba(15, 23, 39, 0.28),
        0 0 0 4px rgba(1, 191, 166, 0.10);
    cursor: pointer;
    font-weight: 800;
    letter-spacing: -0.01em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.meria-launcher::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 5px;
    width: 9px;
    height: 9px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--meria-primary);
    box-shadow: 0 0 0 3px rgba(1, 191, 166, 0.22);
}

.meria-launcher:hover {
    transform: translateY(-2px);
    border-color: rgba(1, 191, 166, 0.45);
    box-shadow:
        0 22px 48px rgba(15, 23, 39, 0.34),
        0 0 0 5px rgba(1, 191, 166, 0.13);
}

.meria-launcher:focus-visible {
    outline: 3px solid rgba(1, 191, 166, 0.35);
    outline-offset: 3px;
}

.meria-launcher__mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(145deg, #35dbc5, var(--meria-primary));
    color: #082f2a;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        0 7px 16px rgba(1, 191, 166, 0.28);
    font-weight: 900;
}

.meria-launcher__text {
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
}

.meria-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: min(380px, calc(100vw - 28px));
    max-height: min(680px, calc(100vh - 110px));
    overflow: hidden;
    border: 1px solid var(--meria-border);
    border-radius: 22px;
    background: var(--meria-surface);
    box-shadow:
        0 30px 70px rgba(15, 23, 39, 0.26),
        0 8px 24px rgba(1, 191, 166, 0.09);
    transform-origin: bottom right;
    animation: meria-panel-in 0.22s ease-out;
}

.meria-panel[hidden] {
    display: none;
}

@keyframes meria-panel-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.meria-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 72px;
    padding: 15px 16px 15px 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(1, 191, 166, 0.34), transparent 38%),
        linear-gradient(135deg, var(--meria-dark), var(--meria-dark-2));
    color: #fff;
}

.meria-header::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--meria-primary), #6ce8d8, transparent);
}

.meria-header strong,
.meria-header span {
    position: relative;
    display: block;
    letter-spacing: 0;
}

.meria-header strong {
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.meria-header span {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.76);
}

.meria-close {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
    transition: background 0.18s ease, transform 0.18s ease;
}

.meria-close:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: rotate(5deg);
}

.meria-close:focus-visible {
    outline: 3px solid rgba(108, 232, 216, 0.40);
    outline-offset: 2px;
}

.meria-messages {
    display: flex;
    flex-direction: column;
    gap: 11px;
    max-height: 320px;
    overflow-y: auto;
    padding: 18px 16px;
    background:
        radial-gradient(circle at 10% 10%, rgba(1, 191, 166, 0.07), transparent 28%),
        var(--meria-background);
    scrollbar-width: thin;
    scrollbar-color: rgba(1, 191, 166, 0.45) transparent;
}

.meria-messages::-webkit-scrollbar {
    width: 7px;
}

.meria-messages::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(1, 191, 166, 0.40);
}

.meria-message {
    position: relative;
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.48;
    box-shadow: 0 5px 14px rgba(15, 23, 39, 0.06);
    overflow-wrap: anywhere;
}

.meria-message--bot {
    align-self: flex-start;
    border: 1px solid rgba(15, 23, 39, 0.08);
    border-bottom-left-radius: 5px;
    background: #fff;
    color: var(--meria-text);
}

.meria-message--bot::before {
    content: "MER-IA";
    display: block;
    margin-bottom: 5px;
    color: var(--meria-primary-dark);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.meria-message--user {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: linear-gradient(135deg, var(--meria-primary), #19cdb6);
    color: #063e36;
    font-weight: 750;
    box-shadow: 0 8px 18px rgba(1, 191, 166, 0.22);
}

.meria-actions {
    display: grid;
    gap: 9px;
    padding: 14px 16px 16px;
    background: #fff;
}

.meria-option {
    position: relative;
    width: 100%;
    min-height: 44px;
    border: 1px solid #dce5e7;
    border-radius: 13px;
    background: #fff;
    color: var(--meria-dark);
    cursor: pointer;
    padding: 11px 38px 11px 13px;
    text-align: left;
    font-size: 14px;
    font-weight: 750;
    line-height: 1.3;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.meria-option::after {
    content: "›";
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-52%);
    color: var(--meria-primary-dark);
    font-size: 23px;
    font-weight: 400;
    line-height: 1;
}

.meria-option:hover,
.meria-option:focus {
    border-color: rgba(1, 191, 166, 0.62);
    background: var(--meria-primary-soft);
    box-shadow: 0 7px 16px rgba(1, 191, 166, 0.09);
    outline: none;
    transform: translateY(-1px);
}

.meria-option:focus-visible {
    outline: 3px solid rgba(1, 191, 166, 0.20);
    outline-offset: 2px;
}

.meria-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid rgba(1, 191, 166, 0.24);
    border-radius: 13px;
    background: linear-gradient(135deg, var(--meria-primary), var(--meria-primary-dark));
    color: #fff !important;
    box-shadow: 0 9px 20px rgba(1, 191, 166, 0.22);
    text-decoration: none;
    font-size: 14px;
    font-weight: 850;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.meria-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(1, 191, 166, 0.28);
    filter: brightness(1.02);
}

.meria-link:focus-visible {
    outline: 3px solid rgba(1, 191, 166, 0.28);
    outline-offset: 3px;
}

.meria-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0 16px 15px;
    background: #fff;
}

.meria-reset {
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--meria-muted);
    cursor: pointer;
    padding: 5px 2px;
    font-size: 12px;
    font-weight: 750;
    transition: color 0.18s ease, background 0.18s ease;
}

.meria-reset:hover {
    color: var(--meria-primary-dark);
}

.meria-reset:focus-visible {
    outline: 2px solid rgba(1, 191, 166, 0.28);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .meria-panel,
    .meria-launcher,
    .meria-close,
    .meria-option,
    .meria-link {
        animation: none;
        transition: none;
    }
}

@media (max-width: 520px) {
    .meria-assistant {
        right: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    .meria-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(146px + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-height: calc(100vh - 168px);
        border-radius: 20px;
    }

    .meria-header {
        min-height: 68px;
        padding: 14px 14px 14px 16px;
    }

    .meria-messages {
        max-height: min(320px, calc(100vh - 330px));
        padding: 15px 13px;
    }

    .meria-actions {
        padding: 12px 13px 14px;
    }

    .meria-footer {
        padding: 0 13px 12px;
    }

    .meria-launcher__text {
        display: none;
    }

    .meria-launcher {
        min-width: 58px;
        min-height: 58px;
        padding: 10px;
        box-shadow:
            0 18px 42px rgba(15, 23, 39, 0.36),
            0 0 0 5px rgba(1, 191, 166, 0.18);
    }

    .meria-launcher__mark {
        width: 38px;
        height: 38px;
    }
}
