/* ==========================================================================
   Widget de chat - albercabrera.com
   Todo va con prefijo .acw- (alber chat widget) para no pisar index.css
   ni que index.css pise esto. Paleta tomada de la web actual.
   ========================================================================== */

.acw-root {
    --acw-bg: #0d0d0d;
    --acw-bg-deep: #0a0908;
    --acw-text: #f6f5f2;
    --acw-text-soft: #aaaaaa;
    --acw-accent: #3b5eff;
    --acw-accent-soft: #8aa0ff;
    --acw-border: rgba(255, 255, 255, 0.06);
    --acw-font: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   Burbuja
   -------------------------------------------------------------------------- */

/* Mismo lenguaje visual que el boton de WhatsApp de la web (cristal oscuro
   translucido con borde de color sutil), pero en el azul de marca. Va apilado
   encima: WhatsApp esta en bottom:32px con 60px de alto, 32+60+24 de aire = 116. */
.acw-bubble {
    position: fixed;
    bottom: 116px;
    right: 32px;
    z-index: 1000;
    width: 60px;
    height: 60px;
    background-color: rgba(20, 20, 25, 0.6);
    border: 1px solid rgba(59, 94, 255, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    padding: 0;
}

.acw-bubble:hover {
    transform: scale(1.1) translateY(-3px);
    border-color: rgba(59, 94, 255, 0.8);
    box-shadow: 0 15px 40px rgba(59, 94, 255, 0.25);
}

.acw-bubble:hover .acw-bubble-icon {
    transform: rotate(10deg);
}

.acw-bubble:focus-visible {
    outline: 2px solid var(--acw-accent-soft);
    outline-offset: 3px;
}

.acw-bubble-icon {
    width: 28px;
    height: 28px;
    stroke: var(--acw-accent);
    fill: none;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: block;
}

.acw-bubble--hidden {
    display: none;
}

/* Tooltip, mismo patron que el de WhatsApp */
.acw-tooltip {
    position: absolute;
    right: 76px;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background-color: rgba(10, 10, 12, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--acw-text);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.acw-bubble:hover .acw-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */

.acw-panel {
    position: fixed;
    bottom: 188px;
    right: 32px;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 220px));
    background: var(--acw-bg);
    border: 1px solid var(--acw-border);
    border-radius: 4px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    font-family: var(--acw-font);
    color: var(--acw-text);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.acw-panel--open {
    display: flex;
}

/* --------------------------------------------------------------------------
   Cabecera
   -------------------------------------------------------------------------- */

.acw-header {
    background: var(--acw-bg-deep);
    border-bottom: 1px solid var(--acw-border);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.acw-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--acw-text);
    margin: 0;
    line-height: 1.3;
}

.acw-header-sub {
    font-size: 11px;
    color: var(--acw-text-soft);
    margin: 2px 0 0 0;
    line-height: 1.3;
}

.acw-close {
    background: none;
    border: none;
    color: var(--acw-text-soft);
    cursor: pointer;
    padding: 4px;
    line-height: 0;
    flex-shrink: 0;
    margin-left: 12px;
}

.acw-close:hover {
    color: var(--acw-text);
}

.acw-close:focus-visible {
    outline: 2px solid var(--acw-accent-soft);
    outline-offset: 2px;
}

.acw-close svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* --------------------------------------------------------------------------
   Mensajes
   -------------------------------------------------------------------------- */

.acw-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.acw-msg {
    max-width: 82%;
    padding: 11px 14px;
    font-size: 14px;
    line-height: 1.55;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.acw-msg--bot {
    align-self: flex-start;
    background: #111111;
    border: 1px solid var(--acw-border);
    color: var(--acw-text-soft);
}

.acw-msg--user {
    align-self: flex-end;
    background: var(--acw-accent);
    color: #ffffff;
}

/* Aviso de privacidad bajo el saludo. Discreto, no debe competir con la
   conversacion, pero tiene que leerse. */

.acw-aviso {
    align-self: flex-start;
    max-width: 90%;
    margin: -4px 0 0 0;
    font-size: 11px;
    line-height: 1.5;
    color: #777777;
}

.acw-aviso a {
    color: var(--acw-accent-soft);
    text-decoration: underline;
}

.acw-aviso a:hover {
    color: var(--acw-text);
}

/* Puntos de "escribiendo" */

.acw-typing {
    align-self: flex-start;
    display: none;
    gap: 4px;
    padding: 13px 14px;
    background: #111111;
    border: 1px solid var(--acw-border);
    border-radius: 4px;
}

.acw-typing--on {
    display: flex;
}

.acw-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--acw-text-soft);
    animation: acw-blink 1.3s infinite ease-in-out;
}

.acw-typing span:nth-child(2) {
    animation-delay: 0.18s;
}

.acw-typing span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes acw-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

/* --------------------------------------------------------------------------
   Barra de escritura
   -------------------------------------------------------------------------- */

.acw-form {
    border-top: 1px solid var(--acw-border);
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--acw-bg-deep);
    flex-shrink: 0;
}

.acw-form--hidden {
    display: none;
}

.acw-input {
    flex: 1 1 auto;
    background: #111111;
    border: 1px solid var(--acw-border);
    border-radius: 4px;
    color: var(--acw-text);
    font-family: var(--acw-font);
    font-size: 14px;
    line-height: 1.45;
    padding: 10px 12px;
    resize: none;
    max-height: 96px;
    overflow-y: auto;
}

.acw-input::placeholder {
    color: #666666;
}

.acw-input:focus {
    outline: none;
    border-color: var(--acw-accent);
}

.acw-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.acw-send {
    background: var(--acw-accent);
    border: none;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.acw-send:hover:not(:disabled) {
    background: #5275ff;
}

.acw-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.acw-send:focus-visible {
    outline: 2px solid var(--acw-accent-soft);
    outline-offset: 2px;
}

.acw-send svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* --------------------------------------------------------------------------
   Formulario de respaldo (backend caido o tope agotado)
   -------------------------------------------------------------------------- */

.acw-fallback {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border-top: 1px solid var(--acw-border);
    background: var(--acw-bg-deep);
    overflow-y: auto;
    flex-shrink: 0;
}

.acw-fallback--on {
    display: flex;
}

.acw-fallback-note {
    font-size: 12px;
    color: var(--acw-text-soft);
    margin: 0 0 2px 0;
    line-height: 1.5;
}

.acw-field {
    background: #111111;
    border: 1px solid var(--acw-border);
    border-radius: 4px;
    color: var(--acw-text);
    font-family: var(--acw-font);
    font-size: 14px;
    padding: 10px 12px;
    width: 100%;
    box-sizing: border-box;
}

.acw-field::placeholder {
    color: #666666;
}

.acw-field:focus {
    outline: none;
    border-color: var(--acw-accent);
}

.acw-field--area {
    resize: vertical;
    min-height: 72px;
    font-family: var(--acw-font);
}

.acw-submit {
    background: var(--acw-accent);
    border: none;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    font-family: var(--acw-font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 13px 20px;
    transition: background 0.2s ease;
}

.acw-submit:hover:not(:disabled) {
    background: #5275ff;
}

.acw-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.acw-status {
    font-size: 12px;
    line-height: 1.5;
    margin: 0;
    min-height: 1px;
}

.acw-status--ok {
    color: var(--acw-accent-soft);
}

.acw-status--error {
    color: #ff7a7a;
}

/* Honeypot: invisible para personas, visible para bots tontos */
.acw-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Movil: pantalla completa
   -------------------------------------------------------------------------- */

/* Mismo breakpoint que .whatsapp-float en index.css (768px), para que
   las dos burbujas cambien de tamaño/posicion juntas y no queden
   descoordinadas en el rango intermedio. Mismo espaciado que en
   escritorio (32px de borde, 24px de aire entre ellas), solo cambia
   el tamaño de WhatsApp a 54px (ver index.css). */
@media (max-width: 768px) {
    /* WhatsApp baja a bottom:20px con 54px de alto (ver index.css),
       asi que 20 + 54 + 24 = 98 de aire real entre burbujas. */
    .acw-bubble {
        bottom: 98px;
        right: 20px;
        width: 54px;
        height: 54px;
    }

    /* Sin raton no hay hover: el tooltip solo estorbaria */
    .acw-tooltip {
        display: none;
    }
}

@media (max-width: 640px) {
    .acw-panel {
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
}

/* --------------------------------------------------------------------------
   Accesibilidad: respetar preferencia de menos movimiento
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .acw-bubble,
    .acw-send,
    .acw-submit {
        transition: none;
    }

    .acw-typing span {
        animation: none;
        opacity: 0.6;
    }
}
