/* ===== Asistente Virtual de Opaugranada · Widget flotante ===== */

/* Reset blindado: evita herencia de los estilos globales de la web */
.opau-aw,
.opau-aw *,
.opau-aw *::before,
.opau-aw *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Open Sans", "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: normal;
    text-transform: none;
    line-height: 1.5;
}

.opau-aw {
    --aw-primario: #0269ac;
    --aw-primario-oscuro: #024f82;
    --aw-acento: #d61a46;
    --aw-fondo: #f3f6f9;
    --aw-texto: #1f2933;
    --aw-texto-suave: #5b6b7b;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
}

/* Botón burbuja */
.opau-aw__bubble {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--aw-primario) 0%, var(--aw-primario-oscuro) 100%);
    color: #fff;
    box-shadow: 0 10px 28px rgba(2, 79, 130, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: auto;
}

.opau-aw__bubble::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(2, 105, 172, 0.5);
    animation: opauAwPulse 2.4s ease-out infinite;
}

@keyframes opauAwPulse {
    0%   { box-shadow: 0 0 0 0 rgba(2, 105, 172, 0.45); }
    70%  { box-shadow: 0 0 0 16px rgba(2, 105, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(2, 105, 172, 0); }
}

.opau-aw__bubble:hover {
    transform: scale(1.07);
    box-shadow: 0 12px 32px rgba(2, 79, 130, 0.55);
}

.opau-aw__bubble svg {
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 1;
}

.opau-aw__bubble--hidden {
    display: none;
}

/* Panel de chat */
.opau-aw__panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 40, 70, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.opau-aw__panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Cabecera */
.opau-aw__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--aw-primario) 0%, var(--aw-primario-oscuro) 100%);
    color: #fff;
    flex: 0 0 auto;
}

.opau-aw__avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    color: #fff;
}

.opau-aw__header-text {
    flex: 1 1 auto;
    min-width: 0;
}

.opau-aw__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff !important;
}

.opau-aw__status {
    margin: 3px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9) !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.opau-aw__status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43d17a;
    display: inline-block;
    box-shadow: 0 0 0 3px rgba(67, 209, 122, 0.25);
}

.opau-aw__close {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.opau-aw__close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Mensajes */
.opau-aw__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--aw-fondo);
}

.opau-aw__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.opau-aw__row--user {
    flex-direction: row-reverse;
}

.opau-aw__mini-avatar {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aw-primario) 0%, var(--aw-primario-oscuro) 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
}

.opau-aw__msg {
    max-width: 80%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--aw-texto);
    animation: opauAwIn 0.18s ease-out;
}

@keyframes opauAwIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.opau-aw__msg--user {
    background: linear-gradient(135deg, var(--aw-primario) 0%, var(--aw-primario-oscuro) 100%);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.opau-aw__msg--assistant {
    background: #fff;
    color: var(--aw-texto);
    border: 1px solid #e4ebf2;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(15, 40, 70, 0.05);
}

.opau-aw__msg--error {
    background: #fdecef;
    color: var(--aw-acento);
    border: 1px solid #f5c2cd;
    border-bottom-left-radius: 5px;
}

.opau-aw__msg--loading {
    color: var(--aw-texto-suave);
    font-style: italic;
}

.opau-aw__dots::after {
    content: "";
    animation: opauAwDots 1.2s steps(4, end) infinite;
}

@keyframes opauAwDots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
    100% { content: ""; }
}

/* Formulario */
.opau-aw__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e7edf3;
    background: #fff;
    flex: 0 0 auto;
}

.opau-aw__input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #d3dde7;
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    line-height: 1.4;
    max-height: 110px;
    outline: none;
    color: var(--aw-texto);
    background: #f8fafc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.opau-aw__input::placeholder {
    color: #9aa9b8;
}

.opau-aw__input:focus {
    border-color: var(--aw-primario);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(2, 105, 172, 0.14);
}

.opau-aw__send {
    flex: 0 0 auto;
    border: none;
    border-radius: 12px;
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, var(--aw-primario) 0%, var(--aw-primario-oscuro) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s ease, transform 0.05s ease;
}

.opau-aw__send svg {
    width: 20px;
    height: 20px;
}

.opau-aw__send:hover:not(:disabled) {
    filter: brightness(1.08);
}

.opau-aw__send:active:not(:disabled) {
    transform: scale(0.93);
}

.opau-aw__send:disabled {
    background: #aebecd;
    cursor: not-allowed;
}

.opau-aw__footer {
    text-align: center;
    font-size: 11px;
    color: var(--aw-texto-suave);
    padding: 0 12px 10px;
    background: #fff;
    flex: 0 0 auto;
}

.opau-aw__messages::-webkit-scrollbar {
    width: 8px;
}

.opau-aw__messages::-webkit-scrollbar-thumb {
    background: #c7d3df;
    border-radius: 4px;
}

.opau-aw__messages::-webkit-scrollbar-thumb:hover {
    background: #aebccb;
}

/* Móvil */
@media (max-width: 480px) {
    .opau-aw {
        right: 16px;
        bottom: 16px;
    }

    .opau-aw__panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        right: -4px;
    }
}
