/* ── Sabi ChatUI ── Mobile-first ─────────────────────────────────────── */

@font-face {
    font-family: 'Visby';
    src: url('https://abogados.work/wp-content/uploads/2026/04/VisbyMedium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* ── Wrapper + glow palpitante ───────────────────────────────────────── */

.aw-sabi-wrap {
    position: relative;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

@keyframes aw-glow-pulse {
    0%, 100% { opacity: 0.45; transform: scale(0.98); }
    50%       { opacity: 0.9;  transform: scale(1.02); }
}

.aw-sabi-glow {
    position: absolute;
    inset: -6px;
    background: linear-gradient(135deg, #bfdbfe 0%, rgba(128,125,254,.35) 50%, #fce7f3 100%);
    border-radius: 38px;
    filter: blur(22px);
    opacity: 0.55;
    pointer-events: none;
    animation: aw-glow-pulse 4s ease-in-out infinite;
    z-index: 0;
}

.aw-sabi-glow--bottom {
    inset: auto 0 -16px 0;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(90deg, rgba(96,165,250,.2) 0%, rgba(128,125,254,.3) 50%, rgba(244,114,182,.2) 100%);
    filter: blur(28px);
    opacity: 0.4;
    animation-delay: 2s;
}

/* ── Chat container ──────────────────────────────────────────────────── */

.aw-sabi-chat {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    background: rgba(250,250,250,.93);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid rgba(229,229,229,.65);
    border-radius: 32px;
    min-height: 540px;
    max-height: 82vh;
    overflow: hidden;
    font-family: 'Visby', system-ui, -apple-system, sans-serif;
    font-size: 17px;
    box-shadow: 0 8px 30px rgba(0,0,0,.04);
    transition: box-shadow .3s ease, background .3s ease, border-color .3s ease;
}

.aw-sabi-chat:focus-within {
    background: rgba(255,255,255,.99);
    border-color: rgba(128,125,254,.55);
    box-shadow: 0 8px 40px rgba(128,125,254,.12);
}

/* ── Mensajes ────────────────────────────────────────────────────────── */

.aw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.aw-messages::-webkit-scrollbar {
    display: none;
}

.aw-msg {
    max-width: 78%;
    padding: 11px 16px;
    border-radius: 18px;
    line-height: 1.55;
    word-break: break-word;
    animation: aw-fade-in .2s ease;
    font-size: 17px;
}

@keyframes aw-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aw-msg--sabi {
    align-self: flex-start;
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    border-bottom-left-radius: 4px;
}

.aw-msg--user {
    align-self: flex-end;
    background: #807dfe;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────────── */

.aw-typing {
    display: none;
    align-self: flex-start;
    padding: 11px 16px;
    background: #fff;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    margin: 0 24px 6px;
    gap: 5px;
    align-items: center;
}

.aw-typing.is-visible { display: flex; }

.aw-typing span {
    width: 7px;
    height: 7px;
    background: #c4c4c4;
    border-radius: 50%;
    animation: aw-bounce .9s infinite ease-in-out;
}

.aw-typing span:nth-child(2) { animation-delay: .15s; }
.aw-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes aw-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Input bar ───────────────────────────────────────────────────────── */

.aw-input-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px 20px;
    background: rgba(245,245,245,.75);
    border-top: 1px solid rgba(229,229,229,.5);
    border-radius: 0 0 32px 32px;
    transition: background .25s ease;
}

.aw-sabi-chat:focus-within .aw-input-bar {
    background: rgba(255,255,255,.95);
}

.aw-input-label {
    font-size: 14.5px;
    font-weight: 500;
    color: #807dfe;
    padding: 0 2px;
    letter-spacing: .01em;
}

.aw-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.aw-input {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    padding: 2px 4px;
    font-size: 17px;
    font-family: inherit;
    line-height: 1.55;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    color: #1a1a1a;
}

.aw-input:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.aw-input::placeholder { color: #a3a3a3; }

.aw-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    background: #807dfe;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(128,125,254,.45);
    transition: background .15s, transform .1s, box-shadow .15s;
    line-height: 1;
}

.aw-send-btn:hover    { background: #6c67ef; transform: scale(1.05); box-shadow: 0 6px 18px rgba(128,125,254,.5); }
.aw-send-btn:active   { transform: scale(.92); }
.aw-send-btn:disabled { background: #d4d4d4; cursor: not-allowed; box-shadow: none; }

/* ── Botón OAuth inline ──────────────────────────────────────────────── */

.aw-oauth-inline-wrap {
    background: transparent;
    box-shadow: none;
    padding: 4px 0;
}

.aw-oauth-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.aw-oauth-inline-btn:hover    { background: #f5f5f5; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.aw-oauth-inline-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Botón cerrar (solo visible en mobile expandido) ─────────────────── */

.aw-sabi-close {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    background: rgba(0,0,0,.07);
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #555;
    z-index: 10;
    transition: background .15s;
}

.aw-sabi-close:hover { background: rgba(0,0,0,.13); }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .aw-sabi-wrap  { padding: 0; }
    .aw-sabi-chat  { border-radius: 24px; max-height: 100dvh; }
    .aw-sabi-glow  { border-radius: 28px; }
    .aw-msg        { max-width: 90%; }
}

/* ── Backdrop mobile (cubre toda la página detrás del chat) ──────────── */

.aw-sabi-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: #fff;
}

.aw-sabi-backdrop.is-visible { display: block; }

/* ── Full-screen expandido ───────────────────────────────────────────── */
/* La clase .is-expanded la añade expandChat(): en mobile al tocar el     */
/* chat, o desde fuera vía window.awSabiChat.expand(). Las reglas están   */
/* fuera de la media query para que el modo pantalla completa también     */
/* pueda forzarse en desktop si algún flujo lo necesita.                  */
/* Nota: el chat embebido en un contenedor [data-aw-sabi-embedded]        */
/* (modal de onboarding) no auto-expande — ver chat-ui.js.                */

.aw-sabi-chat.is-expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    z-index: 99999;
    border-radius: 0;
    max-height: none;
    width: 100%;
    border: none;
}

.aw-sabi-chat.is-expanded .aw-sabi-close {
    display: flex;
}

/* ── Overlay "buscando a tu abogado" ─────────────────────────────────── */
/* Pantalla intermedia entre el registro del lead y el marketplace.       */

.aw-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999; /* por encima del chat expandido (99999) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(250,250,250,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-family: 'Visby', system-ui, -apple-system, sans-serif;
    animation: aw-fade-in .25s ease;
}

.aw-search-card {
    position: relative;
    width: 100%;
    max-width: 340px;
}

/* Glow palpitante más vivo: pulso rápido + rotación de tono (azul→violeta→rosa). */
.aw-search-glow {
    position: absolute;
    inset: -10px;
    background: linear-gradient(135deg, #bfdbfe 0%, rgba(128,125,254,.5) 50%, #fce7f3 100%);
    border-radius: 40px;
    filter: blur(26px);
    opacity: 0.7;
    pointer-events: none;
    animation: aw-search-glow-pulse 1.8s ease-in-out infinite;
}

/* Segunda capa de resplandor a contratiempo: profundidad y latido orgánico. */
.aw-search-glow::after {
    content: '';
    position: absolute;
    inset: 12%;
    background: radial-gradient(circle, rgba(128,125,254,.55) 0%, rgba(244,114,182,.25) 60%, transparent 100%);
    border-radius: 50%;
    animation: aw-search-glow-pulse 1.8s ease-in-out infinite;
    animation-delay: -0.9s; /* late cuando la capa externa descansa */
}

@keyframes aw-search-glow-pulse {
    0%, 100% { opacity: 0.5;  transform: scale(0.94); filter: blur(26px) hue-rotate(0deg); }
    50%      { opacity: 0.95; transform: scale(1.06); filter: blur(30px) hue-rotate(-25deg); }
}

/* Tarjeta CUADRADA con contenido centrado + respiración sutil. */
.aw-search-inner {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.97);
    border: 1.5px solid rgba(229,229,229,.65);
    border-radius: 28px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(128,125,254,.14);
    animation: aw-search-breathe 1.8s ease-in-out infinite;
}

@keyframes aw-search-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.015); }
}

.aw-search-phrase {
    margin: 0 0 24px;
    font-size: 18px;
    line-height: 1.5;
    color: #1f2937;
    min-height: 1.6em; /* evita saltos de layout al rotar frases */
}

.aw-search-bar {
    width: 100%; /* necesario: el padre flex centrado ya no estira los hijos */
    height: 8px;
    border-radius: 999px;
    background: rgba(229,229,229,.8);
    overflow: hidden;
}

.aw-search-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: #12161b;
    /* Duración sincronizada con la narrativa del JS:
       PHRASE_INTERVAL (1400ms) × 5 transiciones + 1200ms de pausa final ≈ 8.2s */
    animation: aw-search-fill 8.2s ease-out forwards;
}

/* Progresión por fases, acompasada con las 4 fases de la narrativa:
   recepción → análisis → filtrado → match (llega a ~98% con el match final). */
@keyframes aw-search-fill {
    0%   { width: 3%; }
    17%  { width: 20%; }  /* recepción */
    51%  { width: 52%; }  /* análisis */
    85%  { width: 84%; }  /* filtrado */
    100% { width: 98%; }  /* match */
}

/* ── Entrega del diagnóstico + cuenta regresiva (gamificación) ────────── */
/* Mensaje final del chat: sello de expediente, entrega automática y anillo */
/* de cuenta regresiva 10→0. Se renderiza dentro de .aw-msg--diag, una     */
/* burbuja de Sabi estirada de margen a margen.                            */

.aw-msg--diag {
    align-self: stretch !important;
    width: 100%;
    max-width: 100% !important;
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.aw-diag-deliver {
    text-align: center;
    padding: 24px 20px 26px;
    border-radius: 10px;
    background: #fafbfc;
    border: 1px solid #dde1e6;
    border-top: 3px solid #12161b;
    box-shadow: 0 8px 22px rgba(9, 12, 16, .07);
}

/* Sello del expediente: documento con escudo, no un regalo. */
.aw-diag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: #12161b;
    color: #fff;
    animation: aw-diag-pop .45s cubic-bezier(.16, 1, .3, 1) both;
}

.aw-diag-badge svg {
    width: 24px;
    height: 24px;
    display: block;
}

.aw-diag-title {
    margin: 12px 0 3px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #12161b;
}

.aw-diag-sub {
    margin: 0 auto 4px;
    max-width: 330px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #67707c;
}

/* Anillo de cuenta regresiva. El JS actualiza --p (100→0). */
.aw-diag-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #e6e9ed;
}

.aw-diag-ring {
    --p: 100;
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        conic-gradient(#12161b calc(var(--p) * 1%), #e2e6ea 0);
    transition: background 1s linear;
}

/* Aro interior blanco → deja solo el borde de progreso. */
.aw-diag-ring::before {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fafbfc;
}

.aw-diag-num {
    position: relative;
    z-index: 1;
    font-size: 24px;
    font-weight: 800;
    color: #12161b;
    font-variant-numeric: tabular-nums;
}

.aw-diag-num.is-tick {
    animation: aw-diag-tick .5s ease-out;
}

.aw-diag-hint {
    margin: 0;
    font-size: 12.5px;
    color: #67707c;
}

.aw-diag-hint b {
    color: #12161b;
    font-variant-numeric: tabular-nums;
}

@keyframes aw-diag-pop {
    from { opacity: 0; transform: translateY(6px) scale(.92); }
    to   { opacity: 1; transform: none; }
}

@keyframes aw-diag-tick {
    0%   { transform: scale(1.35); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .aw-diag-badge,
    .aw-diag-num.is-tick { animation: none; }
}
