/* ═══════════════════════════════════════════════════════════
   Widget Xyra — INSTANET Chat
   Header blanco moderno · Cards 2x2 · Banner de bienvenida
   0 dependencias — CSS custom properties
   ═══════════════════════════════════════════════════════════ */

:root {
    --xyra-teal: #075e54;
    --xyra-teal-light: #128c7e;
    --xyra-green: #25d366;
    --xyra-green-dark: #1da851;
    --xyra-accent: #f39c12;
    --xyra-chat-bg: #f8f9fa;
    --xyra-bot-bubble: #ffffff;
    --xyra-user-bubble: #dcf8c6;
    --xyra-text: #303030;
    --xyra-text-muted: #667781;
    --xyra-text-dim: #8696a0;
    --xyra-border: #d1d7db;
    --xyra-input-bg: #ffffff;
    --xyra-input-bar: #f0f2f5;
    --xyra-shadow: 0 16px 48px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.15);
    --xyra-ink: #0f172a;
    --xyra-card-edge: #cbd5e1;
    --xyra-radius: 12px;
    --xyra-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --xyra-transition: cubic-bezier(0.22, 1, 0.36, 1);
    --xyra-z: 9999;
    --xyra-width: 380px;
    --xyra-height: 560px;
    --xyra-fab-size: 60px;
}

/* ─── SINGLE FAB ─────────────────────────────────────── */

.xyra-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 60px;
    width: auto;
    border-radius: 999px;
    background: linear-gradient(160deg, #2b3138 0%, #1a1d21 100%);
    border: 2px solid #f39c12;
    cursor: pointer;
    z-index: var(--xyra-z);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s var(--xyra-transition), box-shadow 0.3s ease;
    animation: xyra-pulse 3s ease-in-out infinite;
}

.xyra-fab:hover {
    transform: translateY(-2px) scale(1.04);
}

.xyra-fab:active {
    transform: scale(0.96);
}

.xyra-fab:focus-visible {
    outline: 3px solid rgba(243, 156, 18, 0.65);
    outline-offset: 3px;
}

.xyra-fab-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 30%, #ffd67a 0%, #f39c12 55%, #b26a06 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35), inset 0 -2px 4px rgba(0, 0, 0, 0.25);
}

.xyra-fab-icon svg {
    width: 28px;
    height: 28px;
    display: block;
    transition: transform 0.3s var(--xyra-transition);
}

.xyra-fab.xyra-open .xyra-fab-icon svg {
    transform: rotate(90deg);
}

.xyra-icon-gear {
    transform-origin: 12px 12px;
    animation: xyra-gear-spin 9s linear infinite;
}

@keyframes xyra-gear-spin {
    to {
        transform: rotate(360deg);
    }
}

.xyra-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--xyra-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: xyra-badge-pulse 2s ease-in-out infinite;
}

.xyra-fab-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 0 2px;
    color: #ffffff;
    font-family: var(--xyra-font);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.xyra-fab-label::before {
    content: '';
    width: 10px;
    height: 26px;
    border-radius: 3px;
    background: repeating-linear-gradient(45deg, #f39c12 0 4px, #1a1d21 4px 8px);
    flex-shrink: 0;
}

.xyra-fab-label-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25d366;
    animation: xyra-status-pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes xyra-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(243, 156, 18, 0.15), 0 8px 32px rgba(243, 156, 18, 0.5);
    }
}

@keyframes xyra-badge-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ─── WIDGET CONTAINER ───────────────────────────────── */

.xyra-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: var(--xyra-width);
    height: var(--xyra-height);
    z-index: var(--xyra-z);
    border-radius: var(--xyra-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: var(--xyra-shadow);
    font-family: var(--xyra-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--xyra-text);
    background: var(--xyra-chat-bg);
    transform: scale(0) translateY(20px);
    opacity: 0;
    transform-origin: bottom right;
    transition: transform 0.4s var(--xyra-transition), opacity 0.3s ease;
    pointer-events: none;
}

.xyra-widget.xyra-visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ─── HEADER (Modern White) ──────────────────── */

.xyra-header {
    background: #ffffff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-bottom: 2px solid #e2e8f0;
    /* En móvil fullscreen se suma el notch/barra de estado
       para que el botón de cerrar NUNCA quede oculto. */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.xyra-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid #e2e8f0;
}

.xyra-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.xyra-header-avatar-fallback {
    font-size: 18px;
    color: #667781;
    font-weight: 700;
}

.xyra-header-info {
    flex: 1;
    min-width: 0;
}

.xyra-header-title {
    font-weight: 700;
    font-size: 16px;
    color: #1a1a2e;
}

.xyra-header-title span {
    color: var(--xyra-accent); /* Naranja para AI */
}

.xyra-header-subtitle {
    font-size: 12px;
    color: #667781;
    display: flex;
    align-items: center;
    gap: 4px;
}

.xyra-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #25d366;
    display: inline-block;
    animation: xyra-status-pulse 2s ease-in-out infinite;
}

@keyframes xyra-status-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.xyra-header-close {
    width: 32px;
    height: 32px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.14);
}

.xyra-header-close:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: rotate(90deg);
}

.xyra-header-close svg {
    width: 16px;
    height: 16px;
    fill: #334155;
}

/* ─── MESSAGES AREA ──────────────────────────────────── */

.xyra-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    background-color: var(--xyra-chat-bg);
}

/* El área scrollea: ningún hijo (banner, burbujas, botones) debe comprimirse
   con flex-shrink cuando el contenido excede el alto visible. */
.xyra-messages > * {
    flex-shrink: 0;
}

.xyra-messages::-webkit-scrollbar {
    width: 5px;
}

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

.xyra-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
}

/* ─── MESSAGE BUBBLES (WhatsApp-style) ───────────────── */

.xyra-msg {
    max-width: 82%;
    padding: 7px 10px 4px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: xyra-msg-in 0.3s var(--xyra-transition) forwards;
    opacity: 0;
    transform: translateY(6px);
    position: relative;
    font-size: 13.5px;
    line-height: 1.45;
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

@keyframes xyra-msg-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xyra-msg-bot {
    align-self: flex-start;
    background: var(--xyra-bot-bubble);
    color: var(--xyra-text);
    border-radius: 0 8px 8px 8px;
}

.xyra-msg-user {
    align-self: flex-end;
    background: var(--xyra-user-bubble);
    color: var(--xyra-text);
    border-radius: 8px 0 8px 8px;
}

.xyra-msg-time {
    font-size: 10px;
    color: var(--xyra-text-dim);
    margin-top: 2px;
    text-align: right;
    display: block;
}

.xyra-msg b,
.xyra-msg strong {
    font-weight: 600;
    color: inherit;
}

/* ─── TYPING INDICATOR ───────────────────────────────── */

.xyra-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--xyra-bot-bubble);
    border-radius: 0 8px 8px 8px;
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
    animation: xyra-msg-in 0.25s var(--xyra-transition) forwards;
    opacity: 0;
}

.xyra-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a0aeb8;
    animation: xyra-typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes xyra-typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ─── PROGRESS MESSAGE ────────────────────────────────── */

.xyra-progress {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    font-size: 0.85em;
    border-radius: 10px 10px 10px 2px;
    padding: 8px 14px;
    margin-bottom: 4px;
}

.xyra-progress-dots {
    display: inline-block;
    min-width: 24px;
    text-align: left;
    font-weight: bold;
    letter-spacing: 2px;
}

/* ─── QUICK BUTTONS (Cards 2x2) ──────────────────────── */

.xyra-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 6px 0 10px;
    animation: xyra-msg-in 0.35s var(--xyra-transition) forwards;
    opacity: 0;
}

/* Cada categoría define su par de colores (borde/fondo icono + sombra sólida).
   El borde de 2px del color de la categoría remarca el filo de cada card. */
.xyra-btn {
    --xyra-cat: var(--xyra-teal-light);
    --xyra-cat-dark: var(--xyra-teal);

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border: 2px solid var(--xyra-cat);
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fb 100%);
    color: var(--xyra-text);
    border-radius: 16px;
    cursor: pointer;
    font-family: var(--xyra-font);
    text-align: left;
    box-shadow:
        0 4px 0 var(--xyra-cat-dark),
        0 12px 24px -8px rgba(15, 23, 42, 0.35),
        0 3px 8px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.xyra-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 7px 0 var(--xyra-cat-dark),
        0 20px 32px -10px rgba(15, 23, 42, 0.42),
        0 6px 12px rgba(15, 23, 42, 0.15);
}

.xyra-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow:
        0 1px 0 var(--xyra-cat-dark),
        0 6px 12px -6px rgba(15, 23, 42, 0.3);
}

.xyra-btn:focus-visible {
    outline: 3px solid var(--xyra-cat);
    outline-offset: 3px;
}

/* Botones sin icono (LOPDP, reintentos, botones que envía el backend):
   fila centrada, estilo pill compacto con filo y sombra sólida teal */
.xyra-btn--simple {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    box-shadow:
        0 3px 0 var(--xyra-cat-dark),
        0 10px 18px -8px rgba(15, 23, 42, 0.3);
}

.xyra-btn--simple .xyra-btn-label {
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    color: var(--xyra-teal);
}

.xyra-btn-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--xyra-cat) 0%, var(--xyra-cat-dark) 100%);
    border: 2px solid #ffffff;
    box-shadow:
        0 4px 10px -2px rgba(15, 23, 42, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.xyra-btn-icon-wrapper svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.xyra-btn-text-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.xyra-btn-label {
    font-size: 14px;
    font-weight: 800;
    color: var(--xyra-ink);
    line-height: 1.2;
    letter-spacing: 0.1px;
}

.xyra-btn-desc {
    font-size: 11px;
    font-weight: 500;
    color: #475569;
    line-height: 1.35;
}

/* Category Accent Colors */
.xyra-btn[data-category="issue"]   { --xyra-cat: #2563eb; --xyra-cat-dark: #1d4ed8; } /* Blue */
.xyra-btn[data-category="payment"] { --xyra-cat: #16a34a; --xyra-cat-dark: #15803d; } /* Green */
.xyra-btn[data-category="support"] { --xyra-cat: #ea580c; --xyra-cat-dark: #c2410c; } /* Orange */
.xyra-btn[data-category="visit"]   { --xyra-cat: #7c3aed; --xyra-cat-dark: #6d28d9; } /* Purple */
.xyra-btn[data-category="promise"] { --xyra-cat: #f59e0b; --xyra-cat-dark: #b45309; } /* Gold */
.xyra-btn[data-category="account"] { --xyra-cat: #0891b2; --xyra-cat-dark: #0e7490; } /* Teal */

/* ─── BANNER CARD & MENU ─────────────────────────────── */

.xyra-banner-card {
    background: linear-gradient(135deg, #0248e8 0%, #0093ff 100%);
    border-radius: 16px;
    padding: 24px 20px 24px 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 6px;
    box-shadow: 0 10px 28px rgba(2, 72, 232, 0.35);
    animation: xyra-msg-in 0.3s var(--xyra-transition) forwards;
}

.xyra-banner-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xyra-banner-title-hand {
    display: inline-block;
    animation: xyra-wave 2.5s infinite;
    transform-origin: bottom right;
}

@keyframes xyra-wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60%, 100% { transform: rotate(0deg); }
}

.xyra-banner-text {
    font-size: 13.5px;
    line-height: 1.45;
    max-width: 65%;
    opacity: 0.95;
    margin: 0;
}

.xyra-banner-robot {
    position: absolute;
    right: -10px;
    bottom: -15px;
    width: 155px;
    height: 155px;
    object-fit: cover;
    /* El JPG trae fondo gris claro: recorte circular con anillo para que
       se lea como insignia y no como parche sobre el gradiente. */
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    background: #fff;
    box-shadow: 0 10px 28px rgba(2, 72, 232, 0.35);
    pointer-events: none;
    z-index: 1;
}

.xyra-banner-waves {
    position: absolute;
    right: 0;
    top: 0;
    width: 150px;
    height: 100%;
    opacity: 0.15;
    pointer-events: none;
}

.xyra-menu-subtitle {
    font-size: 15px;
    font-weight: 800;
    color: var(--xyra-ink);
    margin: 12px 0 8px;
    letter-spacing: 0.2px;
}

/* ─── Single-column mobile ───────────────────────── */
@media (max-width: 480px) {
    .xyra-buttons {
        gap: 10px;
        padding: 4px 0 10px;
    }
    .xyra-btn {
        padding: 12px;
    }
    .xyra-banner-card {
        padding: 20px 16px;
    }
    .xyra-banner-robot {
        width: 140px;
        height: 140px;
        right: -15px;
        bottom: -10px;
    }
    .xyra-banner-title {
        font-size: 24px;
    }
}

/* ─── INPUT AREA ─────────────────────────────────────── */

.xyra-input-area {
    padding: 8px 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    background: var(--xyra-input-bar);
}

.xyra-input-hidden {
    display: none !important;
}

.xyra-input {
    flex: 1;
    border: none;
    background: var(--xyra-input-bg);
    color: var(--xyra-text);
    border-radius: 22px;
    padding: 9px 14px;
    font-family: var(--xyra-font);
    font-size: 14px;
    outline: none;
    min-width: 0;
    box-shadow: inset 0 0 0 1px #dfe5e7;
    transition: box-shadow 0.2s ease;
}

.xyra-input::placeholder {
    color: var(--xyra-text-dim);
}

.xyra-input:focus {
    box-shadow: inset 0 0 0 1px var(--xyra-teal-light);
}

.xyra-send-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #054d46;
    background: linear-gradient(135deg, var(--xyra-teal-light) 0%, var(--xyra-teal) 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px -2px rgba(7, 94, 84, 0.55);
}

.xyra-send-btn:hover {
    background: linear-gradient(135deg, #16a394 0%, #0a6e62 100%);
    transform: scale(1.05);
    box-shadow: 0 6px 16px -2px rgba(7, 94, 84, 0.65);
}

.xyra-send-btn:active {
    transform: scale(0.92);
}

.xyra-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.xyra-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ─── POWERED BY ─────────────────────────────────────── */

.xyra-powered {
    text-align: center;
    padding: 5px 16px 8px;
    font-size: 10px;
    color: var(--xyra-text-dim);
    flex-shrink: 0;
    background: var(--xyra-input-bar);
    letter-spacing: 0.2px;
}

.xyra-powered strong {
    color: var(--xyra-text);
    font-weight: 600;
}

.xyra-powered a {
    color: var(--xyra-teal-light);
    text-decoration: none;
    font-weight: 500;
}

/* ─── WELCOME SCREEN ─────────────────────────────────── */

.xyra-welcome {
    text-align: center;
    padding: 24px 16px 14px;
    background: #fff;
    border-radius: 0 8px 8px 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 14px -4px rgba(15, 23, 42, 0.16);
    margin-bottom: 4px;
}

.xyra-welcome-avatar {
    width: 68px;
    height: 68px;
    margin: 0 auto 10px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(7, 94, 84, 0.25);
    border: 3px solid var(--xyra-teal-light);
}

.xyra-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.xyra-welcome-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--xyra-text);
    margin-bottom: 4px;
}

.xyra-welcome-text {
    font-size: 13px;
    color: var(--xyra-text-muted);
    margin-bottom: 2px;
}

.xyra-welcome-subtitle {
    font-size: 11px;
    color: var(--xyra-text-dim);
    letter-spacing: 0.5px;
}

/* ─── WA LINK INSIDE WIDGET ──────────────────────────── */

.xyra-wa-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    margin: 4px 14px 8px;
    background: #f0fdf4;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid #25d366;
    font-family: var(--xyra-font);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--xyra-text);
    text-decoration: none;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 14px -4px rgba(37, 211, 102, 0.55);
}

.xyra-wa-link:hover {
    background: #dcfce7;
    transform: translateY(-1px);
    box-shadow: 0 7px 18px -5px rgba(37, 211, 102, 0.65);
}

.xyra-wa-link svg {
    width: 20px;
    height: 20px;
    fill: #25d366;
    flex-shrink: 0;
}

.xyra-wa-link span {
    font-weight: 500;
    color: #128c7e;
}

/* ─── RESPONSIVE: MOBILE Z-INDEX FIX ─────────────────── */
/* El hamburger toggle tiene z-index: 100000. Subimos el widget
   por encima en móvil para que el botón de cerrar sea tappable.
   El FAB se queda en --xyra-z (9999) para que se oculte detrás
   del overlay del menú (z-index: 99998) cuando el menú está abierto. */
@media (max-width: 768px) {
    .xyra-widget {
        z-index: 100001;
    }
}

/* ─── RESPONSIVE: MOBILE FULLSCREEN ──────────────────── */

@media (max-width: 480px) {
    .xyra-widget {
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        /* height: 100% — en Android, el layout viewport se reduce al abrir
           el teclado virtual, por lo que 100% redimensiona el widget
           correctamente sin necesidad de JS.
           iOS Safari NO reduce el layout viewport al abrir el teclado;
           ahí actúa el listener de visualViewport en widget-xyra.js. */
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform-origin: bottom center;
    }

    /* Botón de cerrar 44x44 (iOS HIG) con margen para separarlo
       del borde de la pantalla y del hamburger toggle. */
    .xyra-header-close {
        width: 44px;
        height: 44px;
        background: #f8fafc;
        margin-right: 4px;
        flex-shrink: 0;
    }

    .xyra-header-close svg {
        width: 22px;
        height: 22px;
    }

    /* Padding lateral adecuado para que el contenido no toque bordes */
    .xyra-header {
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
        gap: 12px;
    }

    .xyra-messages {
        padding: 14px 16px;
    }

    .xyra-input-area {
        padding: 10px 12px;
    }

    .xyra-powered {
        padding: 5px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .xyra-fab {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: 16px;
    }

    .xyra-fab {
        height: 54px;
        padding: 4px;
        gap: 8px;
    }

    .xyra-fab-icon {
        width: 42px;
        height: 42px;
    }

    .xyra-fab-label {
        font-size: 12px;
        padding-right: 12px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    :root {
        --xyra-width: 340px;
        --xyra-height: 500px;
    }
}

/* ─── REDUCE MOTION ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {

    .xyra-fab,
    .xyra-widget,
    .xyra-msg,
    .xyra-typing,
    .xyra-buttons,
    .xyra-btn,
    .xyra-fab-badge,
    .xyra-status-dot,
    .xyra-icon-gear,
    .xyra-fab-label-dot {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }

    .xyra-msg {
        opacity: 1;
        transform: none;
    }

    .xyra-typing {
        opacity: 1;
    }

    .xyra-buttons {
        opacity: 1;
    }
}

/* ─── CLICK TO COPY V9.0 ─────────────────────────────── */

.xyra-msg-bot.xyra-clickable {
    user-select: none;
    -webkit-user-select: none;
}

.xyra-copy-toast {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--xyra-teal-light);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: xyra-toast-in 1.5s ease forwards;
}

@keyframes xyra-toast-in {
    0%   { opacity: 0; transform: translateX(-50%) translateY(4px); }
    15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    75%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-4px); }
}

.xyra-msg-bot.xyra-copied {
    box-shadow: 0 0 0 2px var(--xyra-green), 0 1px 1px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

/* ─── File input (hidden) ──────────────────────────── */

.xyra-file-input {
    display: none !important;
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ─── Image preview in chat ────────────────────────── */

.xyra-img-preview {
    padding: 4px !important;
    background: transparent !important;
    border-radius: var(--xyra-bubble-radius) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
}

.xyra-img-preview img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    image-rendering: auto;
}

.xyra-upload-preview {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
}
