/* ============================================================
   MINI CARPINCHO — Agente IA Flotante
   Design System: Anexit Premium
   Reference: 05_CAPINCHO_MINI_AGENTE.md · 01_ESTILO_IDENTIDAD.md
   Fase 1: UI Visual (Sin lógica IA)
   ============================================================ */

/* ----------------------------------------------------------
   VARIABLES LOCALES (por si se usa fuera de index.html)
   ---------------------------------------------------------- */
.capincho-widget {
    --capincho-primary: #3b82f6;
    /* Azul Celeste Vibrante (Un paso más claro que el accent de Anexit) */
    --capincho-primary-dark: #1d4ed8;
    /* Azul Profundo Eléctrico */
    --capincho-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --capincho-glass: rgba(255, 255, 255, 0.97);
    --capincho-border: rgba(59, 130, 246, 0.12);
    --capincho-shadow: 0 20px 40px rgba(59, 130, 246, 0.15);
    --capincho-text: #1a1a2e;
    --capincho-text-light: #6c7a94;
    --capincho-success-bg: rgba(16, 185, 129, 0.08);
    --capincho-success-border: rgba(16, 185, 129, 0.25);
    --capincho-user-bg: rgba(13, 0, 158, 0.08);
    --capincho-error-bg: rgba(220, 38, 38, 0.07);
    --capincho-error-border: rgba(220, 38, 38, 0.2);
    --capincho-easing-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --capincho-easing-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ============================================================
   FAB — BOTÓN FLOTANTE
   ============================================================ */
.capincho-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9000;
    width: 48px;
    height: 48px;
    border-radius: 18px;
    /* Squircle más suave */
    background: #0D009E;
    /* Fondo Azul Anexit para que entone con el aura y el celeste */
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.3s var(--capincho-easing-elastic),
        box-shadow 0.3s ease;
    animation: capinchoFabEntry 0.6s var(--capincho-easing-elastic) both;
    animation-delay: 0.8s;
    transform: scale(0);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow: hidden;
    /* Importante para el recorte del aura */
}

/* --- EFECTO AURA DE ENERGÍA (Anillo de luz) --- */
.capincho-fab::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent,
            #60a5fa,
            /* Celeste vibrante */
            #a855f7,
            /* Violeta eléctrico (purpurina) */
            #60a5fa,
            transparent 40%);
    animation: capinchoAuraRotate 3s linear infinite;
    /* Un poco más rápido por defecto */
    z-index: 1;
    filter: blur(1px);
    /* Suaviza el haz de luz */
}

/* El "cristal" interior que tapa el centro del gradiente */
.capincho-fab::after {
    content: '';
    position: absolute;
    inset: 2.5px;
    background: var(--capincho-gradient);
    border-radius: 16px;
    z-index: 2;
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.4),
        0 0 18px rgba(59, 130, 246, 0.6);
    /* Glow celeste */
}

@keyframes capinchoAuraRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes capinchoFabEntry {
    0% {
        transform: scale(0) rotate(-15deg);
        opacity: 0;
    }

    70% {
        transform: scale(1.08) rotate(3deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.capincho-fab:hover {
    transform: translateY(-5px) scale(1.08);
    box-shadow:
        0 18px 40px rgba(59, 130, 246, 0.4),
        0 8px 20px rgba(29, 78, 216, 0.3);
}

.capincho-fab:hover::before {
    animation-duration: 1.5s;
    /* Acelera al pasar el mouse (sensación de energía) */
}

.capincho-fab:active {
    transform: translateY(-1px) scale(0.95);
    transition-duration: 0.1s;
}

/* Icono carpincho dentro del FAB */
.capincho-fab-icon {
    width: 32px;
    /* Un poco más grande */
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 3;
    /* Por encima del aura y el cristal */
    pointer-events: none;
    transition: transform 0.4s var(--capincho-easing-elastic);
}

.capincho-fab:hover .capincho-fab-icon {
    transform: scale(1.08) rotate(-5deg);
}

/* Badge de notificación (punto rojo) */
.capincho-fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    display: none;
    /* Se muestra via JS cuando hay acción pendiente */
    animation: capinchoBadgePulse 2s ease-in-out infinite;
}

.capincho-fab-badge.visible {
    display: block;
}

@keyframes capinchoBadgePulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 2px 12px rgba(239, 68, 68, 0.7);
    }
}

/* --- FAB WhatsApp Support (for Non-Premium) --- */
.capincho-fab--whatsapp {
    background: #25D366 !important;
    /* Verde WhatsApp */
    box-shadow: 0 10px 25px rgba(37, 211, 102, 0.4);
    text-decoration: none;
}

.capincho-fab--whatsapp::after {
    background: #25D366 !important;
    box-shadow: none !important;
}

.capincho-fab--whatsapp::before {
    background: conic-gradient(transparent, #ffffff, transparent 40%) !important;
    opacity: 0.5;
}

.capincho-fab--whatsapp:hover {
    box-shadow: 0 15px 35px rgba(37, 211, 102, 0.55);
    background: #20ba5a !important;
}

.capincho-fab--whatsapp svg {
    width: 30px;
    height: 30px;
    color: white;
    z-index: 3;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.capincho-fab--whatsapp .capincho-fab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   VARIANT: MAPA MENTAL (Collisions Fix)
   ============================================================ */
.capincho-widget--map-mental .capincho-fab {
    right: 88px;
    bottom: 30px;
    background: #0D009E;
    /* Borde Azul Anexit */
}

/* El interior del botón: Usamos el nuevo gradiente celeste vibrante */
.capincho-widget--map-mental .capincho-fab::after {
    background: var(--capincho-gradient);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    inset: 3px;
    border-radius: 19px;
    z-index: 2;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.capincho-widget--map-mental .capincho-panel {
    right: 30px;
    bottom: 88px;
    transform-origin: bottom right;
}

/* ============================================================
   PANEL DE CHAT (Bubble)
   ============================================================ */
.capincho-panel {
    position: fixed;
    bottom: 96px;
    /* FAB (56) + gap (16) + margen (24) */
    right: 24px;
    z-index: 8999;
    width: 340px;
    height: 420px;
    background: var(--capincho-glass, rgba(255, 255, 255, 0.97));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--capincho-border, rgba(13, 0, 158, 0.12));
    box-shadow: var(--capincho-shadow, 0 20px 60px rgba(7, 0, 79, 0.25));
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Estado inicial: oculto */
    opacity: 0;
    transform: scale(0.85) translateY(24px);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity 0.35s var(--capincho-easing-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        transform 0.35s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.capincho-panel.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* -- HEADER DEL PANEL -- */
.capincho-panel-header {
    background: linear-gradient(135deg, #0D009E 0%, #07004F 100%);
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    flex-shrink: 0;
    /* Shimmer sutil en el header */
    overflow: hidden;
}

.capincho-panel-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.06) 50%,
            transparent 100%);
    animation: capinchoHeaderShimmer 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes capinchoHeaderShimmer {
    0% {
        left: -100%;
    }

    40%,
    100% {
        left: 140%;
    }
}

.capincho-panel-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.capincho-panel-avatar img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.capincho-panel-title-group {
    flex: 1;
    min-width: 0;
}

.capincho-panel-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.capincho-panel-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.capincho-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
    flex-shrink: 0;
    animation: capinchoStatusPulse 2.5s ease-in-out infinite;
}

@keyframes capinchoStatusPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

.capincho-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

/* Badge de Créditos */
.capincho-credits-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    cursor: help;
    transition: all 0.3s ease;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.capincho-credits-badge.updated {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.capincho-credits-icon {
    font-size: 0.8rem;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
}

@media (max-width: 420px) {
    .capincho-credits-badge {
        padding: 2px 6px;
    }

    .capincho-credits-count {
        font-size: 0.7rem;
    }
}

.capincho-panel-close,
.capincho-panel-reset {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.capincho-panel-close:hover,
.capincho-panel-reset:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.1);
}

.capincho-panel-close:hover {
    transform: rotate(90deg) scale(1.1);
}

.capincho-panel-reset:hover {
    transform: rotate(-30deg) scale(1.1);
}

.capincho-panel-close svg,
.capincho-panel-reset svg {
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
    pointer-events: none;
}

/* -- ÁREA DE MENSAJES -- */
.capincho-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Scroll personalizado */
.capincho-messages::-webkit-scrollbar {
    width: 4px;
}

.capincho-messages::-webkit-scrollbar-track {
    background: transparent;
}

.capincho-messages::-webkit-scrollbar-thumb {
    background: rgba(13, 0, 158, 0.15);
    border-radius: 4px;
}

.capincho-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 0, 158, 0.25);
}

/* -- BURBUJAS DE MENSAJE -- */
.capincho-msg {
    display: flex;
    gap: 7px;
    align-items: flex-end;
    animation: capinchoMsgIn 0.3s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
    max-width: 100%;
}

@keyframes capinchoMsgIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Burbuja del Agente (izquierda) */
.capincho-msg.agent {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
}

.capincho-msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--capincho-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.capincho-msg-avatar img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.capincho-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--capincho-text, #1a1a2e);
    max-width: 85%;
    width: fit-content;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
    display: block;
    position: relative;
    /* Necesario para el botón de copiado */
}

.capincho-msg.agent .capincho-bubble,
.capincho-msg.action .capincho-bubble,
.capincho-msg.error .capincho-bubble {
    padding-bottom: 28px;
    /* Espacio extra para el botón */
}

/* Botón de copiar dentro de la burbuja */
.capincho-bubble-copy {
    position: absolute;
    bottom: 5px;
    right: 8px;
    background: rgba(255, 255, 255, 0.6);
    border: none;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.35;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--capincho-text-light);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 5;
}

.capincho-bubble-copy:hover {
    opacity: 1;
    background: rgba(59, 130, 246, 0.08);
    transform: scale(1.1);
    color: var(--capincho-primary);
}

.capincho-bubble-copy svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    pointer-events: none;
}

/* Espaciado interno ultra-compacto (para evitar gaps enormes) */
.capincho-bubble p,
.capincho-bubble ul,
.capincho-bubble ol {
    margin: 0 0 0.4rem 0;
}

.capincho-bubble *:last-child {
    margin-bottom: 0;
}

.capincho-bubble ul,
.capincho-bubble ol {
    padding-left: 1.2rem;
}

/* Burbuja agente */
/* Burbuja agente */
.capincho-msg.agent .capincho-bubble {
    background: white;
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.06);
    margin-right: auto;
}

/* Burbuja usuario (derecha) */
.capincho-msg.user {
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;
    align-items: flex-end;
}

.capincho-msg.user .capincho-bubble {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.14);
    border-bottom-right-radius: 6px;
    color: var(--capincho-primary, #3b82f6);
    font-weight: 500;
}

/* Burbuja de acción exitosa (verde) */
.capincho-msg.action .capincho-bubble {
    background: var(--capincho-success-bg, rgba(16, 185, 129, 0.08));
    border: 1px solid var(--capincho-success-border, rgba(16, 185, 129, 0.25));
    border-bottom-left-radius: 6px;
}

/* Burbuja de error (rojo) */
.capincho-msg.error .capincho-bubble {
    background: var(--capincho-error-bg, rgba(220, 38, 38, 0.07));
    border: 1px solid var(--capincho-error-border, rgba(220, 38, 38, 0.2));
    border-bottom-left-radius: 6px;
}

/* Botón de acción inline (dentro de burbuja del agente) */
.capincho-action-btn {
    display: flex;
    align-items: center;
    width: fit-content;
    gap: 5px;
    margin-top: 7px;
    padding: 5px 10px;
    background: var(--capincho-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
    font-family: inherit;
    white-space: nowrap;
}

.capincho-action-btn:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.capincho-action-btn svg {
    width: 11px;
    height: 11px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
    flex-shrink: 0;
}

/* -- TYPING INDICATOR (3 puntos pulsantes) -- */
.capincho-typing {
    display: none;
    align-items: flex-end;
    gap: 7px;
    align-self: flex-start;
    animation: capinchoMsgIn 0.3s ease both;
}

.capincho-typing.visible {
    display: flex;
}

.capincho-typing-dots {
    background: white;
    border: 1px solid rgba(13, 0, 158, 0.1);
    border-bottom-left-radius: 6px;
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    padding: 10px 14px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(13, 0, 158, 0.06);
}

.capincho-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(13, 0, 158, 0.4);
    animation: capinchoTypingDot 1.4s ease-in-out infinite;
}

.capincho-dot:nth-child(1) {
    animation-delay: 0s;
}

.capincho-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.capincho-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes capinchoTypingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
        background: rgba(13, 0, 158, 0.8);
    }
}

/* -- CHIPS DE SUGERENCIA -- */
.capincho-chips {
    padding: 0 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.capincho-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(13, 0, 158, 0.05);
    border: 1px solid rgba(13, 0, 158, 0.12);
    color: var(--capincho-primary, #0D009E);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
    font-family: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.capincho-chip:hover {
    background: rgba(13, 0, 158, 0.1);
    border-color: rgba(13, 0, 158, 0.25);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 3px 10px rgba(13, 0, 158, 0.12);
}

.capincho-chip:active {
    transform: scale(0.97);
}

.capincho-chip-emoji {
    font-size: 0.8rem;
    line-height: 1;
}

/* -- INPUT DEL CHAT -- */
.capincho-input-area {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(59, 130, 246, 0.08);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
}

.capincho-input {
    flex: 1;
    border: 1.5px solid rgba(59, 130, 246, 0.12);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-family: inherit;
    color: var(--capincho-text, #1a1a2e);
    background: white;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 90px;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow-y: auto;
}

.capincho-input::placeholder {
    color: var(--capincho-text-light, #6c7a94);
    font-size: 0.78rem;
}

.capincho-input:focus {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

/* Scrollbar del textarea */
.capincho-input::-webkit-scrollbar {
    width: 3px;
}

.capincho-input::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.2);
    border-radius: 3px;
}

/* Botón de envío */
.capincho-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--capincho-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    align-self: flex-end;
}

.capincho-send-btn:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.45);
}

.capincho-send-btn:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.capincho-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.capincho-send-btn svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
    pointer-events: none;
    transform: translateX(1px);
    /* centra visualmente el icono de flecha */
}

/* ============================================================
   PANEL BLOQUEADO (Modal de upgrade para usuarios Free)
   ============================================================ */
.capincho-locked-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 8999;
    width: 300px;
    background: var(--capincho-glass, rgba(255, 255, 255, 0.97));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 16px 48px rgba(255, 140, 0, 0.15);
    padding: 20px;
    text-align: center;

    opacity: 0;
    transform: scale(0.85) translateY(24px);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity 0.35s var(--capincho-easing-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        transform 0.35s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
    font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
}

.capincho-locked-panel.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.capincho-locked-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: block;
    animation: capinchoLockedBounce 2s ease-in-out infinite;
}

@keyframes capinchoLockedBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

.capincho-locked-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 6px;
    line-height: 1.3;
}

.capincho-locked-desc {
    font-size: 0.78rem;
    color: #6c7a94;
    line-height: 1.5;
    margin-bottom: 14px;
}

.capincho-locked-cta {
    display: block;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
    color: #1a1a2e;
    font-weight: 700;
    font-size: 0.83rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1));
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(255, 140, 0, 0.35);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.capincho-locked-cta:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 7px 20px rgba(255, 140, 0, 0.5);
}

.capincho-locked-dismiss {
    font-size: 0.73rem;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s;
}

.capincho-locked-dismiss:hover {
    color: #6c7a94;
}

/* ============================================================
   RESPONSIVE — MÓVIL
   ============================================================ */
@media (max-width: 768px) {

    /* FAB: Proporción ideal para pulgar */
    .capincho-fab {
        bottom: 26px;
        right: 20px;
        bottom: calc(26px + env(safe-area-inset-bottom, 0px));
        width: 46px;
        height: 46px;
        border-radius: 16px;
    }

    /* Panel: Más alto en móvil para ver mejor el chat */
    .capincho-panel {
        width: 92vw;
        height: 70vh;
        max-height: calc(100dvh - 120px); /* Límite dinámico vertical superior */
        left: 50%;
        right: auto;
        transform-origin: bottom center;
        transform: scale(0.85) translateY(24px) translateX(-50%);
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }

    /* Aumentar hitboxes táctiles (mínimo 40-44px visual o con padding) */
    .capincho-panel-close,
    .capincho-panel-reset {
        width: 36px;
        height: 36px;
    }

    .capincho-panel-close svg,
    .capincho-panel-reset svg {
        width: 18px;
        height: 18px;
    }

    .capincho-chip {
        padding: 8px 14px;
        /* Más alto para facilitar el toque */
        font-size: 0.78rem;
    }

    .capincho-send-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .capincho-input {
        padding: 12px;
        font-size: 0.9rem;
        /* Prevenir zoom automático en iOS (font-size >= 16px suele ser el gatillo, pero 14-15px es aceptable) */
    }

    .capincho-panel.open {
        transform: scale(1) translateY(0) translateX(-50%);
    }

    /* Panel bloqueado móvil */
    .capincho-locked-panel {
        width: 88vw;
        left: 50%;
        right: auto;
        transform-origin: bottom center;
        bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
    .capincho-panel {
        width: 95vw;
        height: 65vh;
        max-height: calc(100dvh - 110px);
    }

    .capincho-panel-header {
        padding: 12px 14px 10px;
    }

    .capincho-panel-title {
        font-size: 0.85rem;
    }
}

/* ============================================================
   REDUCCIÓN DE MOVIMIENTO (accesibilidad)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

    .capincho-fab,
    .capincho-panel,
    .capincho-locked-panel,
    .capincho-msg,
    .capincho-chip,
    .capincho-action-btn,
    .capincho-send-btn {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }

    .capincho-fab {
        transform: scale(1) !important;
    }

    .capincho-dot {
        animation-duration: 2s;
    }
}

/* ============================================================
   ICONOS SVG (Reemplazo de Emojis)
   ============================================================ */
.capincho-icon-svg {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
    display: inline-block;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
    flex-shrink: 0;
}

/* Ajustes específicos para contenedores */
.capincho-credits-icon .capincho-icon-svg {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.capincho-chip-emoji .capincho-icon-svg {
    width: 14px;
    height: 14px;
    display: flex;
}

.capincho-fab-lock-badge .capincho-icon-svg {
    width: 11px;
    height: 11px;
    stroke-width: 2.5;
}

.capincho-locked-icon .capincho-icon-svg {
    width: 64px;
    height: 64px;
    color: var(--capincho-primary);
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.3));
    margin-bottom: 8px;
}

.capincho-action-btn .capincho-icon-svg {
    width: 1.2em;
    height: 1.2em;
    margin-right: 4px;
}

/* ============================================================
   🍌🔸 MINI BANANA — SVG Asset Card (Compact Widget Version)
   ============================================================ */
.capincho-svg-card {
    background: white;
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: 16px;
    overflow: hidden;
    max-width: 100%;
    animation: capinchoMsgIn 0.3s var(--capincho-easing-elastic, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
    box-shadow: 0 3px 12px rgba(20, 184, 166, 0.1);
}

.capincho-svg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(6, 182, 212, 0.05) 100%);
    border-bottom: 1px solid rgba(20, 184, 166, 0.12);
}

.capincho-svg-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: #0d9488;
    letter-spacing: 0.02em;
}

.capincho-svg-cost {
    font-size: 0.65rem;
    font-weight: 600;
    color: #6b7280;
    background: rgba(20, 184, 166, 0.08);
    padding: 1px 6px;
    border-radius: 8px;
}

.capincho-svg-preview {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    /* Tablero de ajedrez = transparencia */
    background-image:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
    background-color: #fafafa;
}

.capincho-svg-preview svg {
    width: 80px;
    height: 80px;
    color: #333;
    transition: color 0.2s ease;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
}

.capincho-svg-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid rgba(20, 184, 166, 0.1);
    background: rgba(249, 250, 251, 0.8);
}

/* Color Picker Inline */
.capincho-svg-color-label {
    position: relative;
    width: 26px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
}

.capincho-svg-color-label input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.capincho-svg-color-label svg {
    width: 22px;
    height: 22px;
    stroke: rgba(0, 0, 0, 0.15);
    stroke-width: 2;
    fill: #333333;
    border-radius: 50%;
    transition: transform 0.15s ease;
    pointer-events: none;
}

.capincho-svg-color-label:hover svg {
    transform: scale(1.15);
}

/* Botones de acción compactos */
.capincho-svg-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(20, 184, 166, 0.2);
    background: rgba(20, 184, 166, 0.06);
    color: #0d9488;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.capincho-svg-btn:hover {
    background: rgba(20, 184, 166, 0.15);
    border-color: rgba(20, 184, 166, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.15);
}

.capincho-svg-btn:active {
    transform: scale(0.95);
}

.capincho-svg-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    pointer-events: none;
}

.capincho-svg-btn span {
    line-height: 1;
}

/* ============================================================
   ONBOARDING MODAL — Mini Carpincho (Premium Identity)
   Paleta: 01_ESTILO_IDENTIDAD.md
   ============================================================ */
.capincho-ob-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(7, 0, 79, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: capinchoObFadeIn 0.4s ease both;
}

.capincho-ob-card {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 40px 100px rgba(7, 0, 79, 0.3), 0 0 0 1px rgba(13, 0, 158, 0.06);
    overflow: hidden;
    transform-origin: center bottom;
    animation: capinchoObPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.capincho-ob-overlay.closing {
    animation: capinchoObFadeOut 0.3s ease both;
}

.capincho-ob-overlay.closing .capincho-ob-card {
    animation: capinchoObPopOut 0.3s ease both;
}

@keyframes capinchoObFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes capinchoObFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes capinchoObPopIn { from { transform: scale(0.92) translateY(24px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
@keyframes capinchoObPopOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95) translateY(10px); opacity: 0; } }

/* --- Header con gradiente principal de marca --- */
.capincho-ob-header {
    background: linear-gradient(135deg, #0D009E 0%, #07004F 100%);
    padding: 28px 24px 22px;
    text-align: center;
    color: white;
    position: relative;
}

/* Brillo sutil en el header (efecto galáctico) */
.capincho-ob-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(66, 99, 235, 0.25) 0%, transparent 60%);
    pointer-events: none;
}

.capincho-ob-avatar {
    width: 68px;
    height: 68px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    position: relative;
    z-index: 1;
}

.capincho-ob-avatar img {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
}

.capincho-ob-header h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    position: relative;
    z-index: 1;
    letter-spacing: -0.02em;
}

.capincho-ob-subtitle {
    margin: 6px 0 0;
    font-size: 0.85rem;
    opacity: 0.7;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

/* --- Body --- */
.capincho-ob-body {
    padding: 24px 24px 16px;
    color: #1a1a2e;
}

.capincho-ob-body > p {
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 20px;
    color: #6c7a94;
}

/* --- Lista de features con iconos SVG --- */
.capincho-ob-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.capincho-ob-list li {
    background: rgba(13, 0, 158, 0.03);
    border: 1px solid rgba(13, 0, 158, 0.08);
    padding: 14px 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.capincho-ob-list li:hover {
    background: rgba(13, 0, 158, 0.06);
    border-color: rgba(13, 0, 158, 0.15);
}

/* Contenedor del icono SVG */
.capincho-ob-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, rgba(13, 0, 158, 0.1) 0%, rgba(66, 99, 235, 0.08) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.capincho-ob-icon svg {
    width: 20px;
    height: 20px;
    stroke: #0D009E;
}

.capincho-ob-list li div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.capincho-ob-list li strong {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1a1a2e;
}

.capincho-ob-list li span {
    font-size: 0.8rem;
    color: #6c7a94;
    line-height: 1.35;
}

/* --- Nota/Tip --- */
.capincho-ob-note {
    font-size: 0.82rem;
    background: rgba(66, 99, 235, 0.06);
    border: 1px solid rgba(66, 99, 235, 0.12);
    padding: 12px 14px;
    border-radius: 12px;
    color: #3b4a6b;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.capincho-ob-note-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.capincho-ob-note-icon svg {
    width: 18px;
    height: 18px;
    stroke: #4263eb;
}

/* --- Footer --- */
.capincho-ob-footer {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.capincho-ob-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #6c7a94;
    user-select: none;
}

.capincho-ob-checkbox input {
    accent-color: #0D009E;
    width: 16px;
    height: 16px;
}

.capincho-ob-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #0D009E 0%, #07004F 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(13, 0, 158, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 0.01em;
}

.capincho-ob-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(13, 0, 158, 0.4);
}

/* --- Responsive: Desktop wider --- */
@media (min-width: 768px) {
    .capincho-ob-card {
        max-width: 620px;
    }

    .capincho-ob-header {
        padding: 24px 32px 16px;
    }

    .capincho-ob-avatar {
        width: 56px;
        height: 56px;
        margin: 0 auto 10px;
    }

    .capincho-ob-avatar img {
        width: 36px;
        height: 36px;
    }

    .capincho-ob-body {
        padding: 20px 32px 16px;
    }

    .capincho-ob-body > p {
        margin-bottom: 16px;
    }

    .capincho-ob-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }

    .capincho-ob-list li {
        padding: 12px;
        gap: 12px;
        align-items: center; /* Centrar icono con el bloque de texto en desktop */
    }

    .capincho-ob-footer {
        padding: 0 32px 24px;
    }
}

/* --- Responsive: Extra small mobiles --- */
@media (max-width: 380px) {
    .capincho-ob-card {
        border-radius: 20px;
    }

    .capincho-ob-header {
        padding: 20px 16px 18px;
    }

    .capincho-ob-header h3 {
        font-size: 1.15rem;
    }

    .capincho-ob-body {
        padding: 18px 16px 12px;
    }

    .capincho-ob-list li {
        padding: 10px 12px;
        gap: 10px;
    }

    .capincho-ob-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .capincho-ob-footer {
        padding: 0 16px 20px;
    }
}

/* Estilo para el botón de ayuda en el header del panel */
.capincho-panel-help {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.capincho-panel-help:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.1);
}

.capincho-panel-help svg {
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
}
