/* ============================================================
   Gobi — mascota flotante y chat de la PCM
   ============================================================ */

.gobi-mascot {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1040; /* por debajo de modales (Bootstrap usa 1050+), por encima del contenido */
    line-height: 0;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.gobi-mascot img {
    height: 130px;
    width: auto;
    display: block;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25));
}

.gobi-mascot:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 4px;
    border-radius: 50%;
}

.gobi-mascot[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .gobi-mascot img {
        height: 90px;
    }

    .gobi-mascot {
        right: 8px;
        bottom: 8px;
    }
}

/* En páginas con reCAPTCHA v3, el badge "protegido por reCAPTCHA" de Google
   ocupa la esquina inferior-derecha (bottom:14px, ~60px de alto) en su
   posición estándar — no se reubica. Gobi sube lo suficiente para no
   solaparse con él. */
.gobi-mascot--recaptcha {
    bottom: 90px;
}

@media (max-width: 767px) {
    .gobi-mascot--recaptcha {
        bottom: 82px;
    }
}

/* ── Tooltip rotativo del mascot ─────────────────────────────────────────── */

.gobi-tooltip {
    position: absolute;
    right: calc(100% + 10px);
    bottom: 30px;
    max-width: 220px;
    width: max-content;
    background: #fff;
    color: #1f2937;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.35;
    padding: .55rem .8rem;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateX(6px);
    transition: opacity .35s ease, transform .35s ease;
    pointer-events: none;
}

.gobi-tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -6px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: translateY(-50%) rotate(45deg);
}

.gobi-tooltip--visible {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 767px) {
    .gobi-tooltip {
        right: calc(100% + 6px);
        bottom: 18px;
        max-width: 180px;
        font-size: .74rem;
    }
}

/* ── Panel de chat ────────────────────────────────────────────────────── */

.gobi-chat {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1041;
    width: 340px;
    max-width: calc(100vw - 16px);
    max-height: min(480px, calc(100vh - 24px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

.gobi-chat[hidden] {
    display: none;
}

.gobi-chat:not([hidden]) {
    animation: gobi-chat-in .22s ease;
}

@media (max-width: 767px) {
    .gobi-chat {
        right: 8px;
        bottom: 8px;
    }
}

.gobi-chat__header {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .85rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    flex-shrink: 0;
}

.gobi-chat__avatar {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
}

.gobi-chat__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .5);
}

.gobi-chat__status-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--primary-dark);
}

.gobi-chat__title-block {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
    flex: 1;
}

.gobi-chat__title {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
}

.gobi-chat__subtitle {
    font-size: .72rem;
    color: rgba(255, 255, 255, .85);
    line-height: 1.2;
}

.gobi-chat__clear,
.gobi-chat__close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: .85rem;
    transition: background .15s ease;
}

.gobi-chat__clear {
    font-size: .78rem;
}

.gobi-chat__clear:hover,
.gobi-chat__close:hover {
    background: rgba(255, 255, 255, .28);
}

.gobi-chat__clear:focus-visible,
.gobi-chat__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gobi-chat__body {
    padding: 1rem;
    background: var(--gray-bg);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.gobi-chat__bubble {
    background: #fff;
    border-radius: 12px;
    padding: .75rem .9rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    max-width: 90%;
    align-self: flex-start;
}

.gobi-chat__bubble p {
    margin: 0 0 .35rem;
    font-size: .87rem;
    line-height: 1.45;
    color: #1f2937;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.gobi-chat__list {
    margin: 0 0 .35rem;
    padding-left: 1.1rem;
}

.gobi-chat__list li {
    font-size: .87rem;
    line-height: 1.45;
    color: #1f2937;
    margin: 0 0 .2rem;
    overflow-wrap: break-word;
}

.gobi-chat__time {
    font-size: .68rem;
    color: #9ca3af;
}

/* Mensaje del usuario: alineado a la derecha, color primario */
.gobi-chat__bubble--user {
    align-self: flex-end;
    background: var(--primary);
}

.gobi-chat__bubble--user p {
    color: #fff;
}

.gobi-chat__bubble--user .gobi-chat__time {
    color: rgba(255, 255, 255, .75);
}

/* Mensaje de error (fallo de red, rate limit, etc.) */
.gobi-chat__bubble--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.gobi-chat__bubble--error p {
    color: #b91c1c;
}

/* Indicador "Gobi está escribiendo…" */
.gobi-chat__typing {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 4px;
    padding: .65rem .85rem;
}

.gobi-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: gobi-typing-bounce 1.2s infinite ease-in-out;
}

.gobi-chat__typing span:nth-child(2) { animation-delay: .15s; }
.gobi-chat__typing span:nth-child(3) { animation-delay: .3s; }

@keyframes gobi-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.gobi-chat__input:disabled,
.gobi-chat__send:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.gobi-chat__notice {
    margin: 0;
    padding: .45rem .9rem;
    background: var(--gray-bg);
    border-top: 1px solid var(--gray-border);
    font-size: .68rem;
    line-height: 1.4;
    color: #6b7280;
    flex-shrink: 0;
}

.gobi-chat__footer {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem .75rem;
    background: #fff;
    border-top: 1px solid var(--gray-border);
    flex-shrink: 0;
}

.gobi-chat__input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--gray-border);
    border-radius: 20px;
    padding: .5rem .9rem;
    font-size: .85rem;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.gobi-chat__input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(191, 9, 9, .1);
}

.gobi-chat__send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .85rem;
    transition: background .15s ease;
}

.gobi-chat__send:hover {
    background: var(--primary-dark);
}

.gobi-chat__send:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

@keyframes gobi-chat-in {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
