/* css/soporte/chat_widget.css
   Widget de chat de soporte (botón flotante + ventana flotante).
   Reusa tokens de marca (--admin-primary, --admin-accent, --lightcolor).
   Ajustes mobile-first.
*/

/* ===== Botón flotante (sirve tanto para chat como fallback a tickets) ===== */
.tursvp-chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff6f91 0%, #ff9671 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(255, 111, 145, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    z-index: 9990;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tursvp-chat-fab:hover,
.tursvp-chat-fab:focus {
    color: #fff;
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 12px 24px rgba(255, 111, 145, 0.55);
    outline: none;
}

.tursvp-chat-fab .tursvp-chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--admin-danger, #ef4444);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tursvp-chat-fab[data-no-leidos]:not([data-no-leidos="0"]) .tursvp-chat-fab-badge {
    display: inline-flex;
}

@media (max-width: 575.98px) {
    .tursvp-chat-fab { right: 14px; bottom: 14px; width: 54px; height: 54px; font-size: 19px; }
}

/* ===== Ventana de chat ===== */
.tursvp-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 92px;
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 540px;
    max-height: calc(100vh - 220px);
    min-height: 300px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(15, 29, 54, 0.28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9991;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.tursvp-chat-panel.is-open {
    display: flex;
}

.tursvp-chat-header {
    background: linear-gradient(135deg, var(--admin-primary, #1a2b4a) 0%, #2a3f66 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.tursvp-chat-header-logo-wrap {
    width: 94px;
    height: 38px;
    border-radius: 8px;
    background: #fff;
    padding: 5px 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 94px;
}

.tursvp-chat-header-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tursvp-chat-header-info { flex: 1; min-width: 0; }
.tursvp-chat-header-title-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}
.tursvp-chat-header-title-row .tursvp-chat-header-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tursvp-chat-header-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.tursvp-chat-header-editar-nombre {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tursvp-chat-header-editar-nombre:hover {
    color: #fff;
}
.tursvp-chat-header-status { font-size: 12px; opacity: 0.85; display: inline-flex; align-items: center; gap: 6px; }
.tursvp-chat-header-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.tursvp-chat-header-status.is-online::before { background: #22c55e; }
.tursvp-chat-close {
    background: transparent; color: #fff; border: none; font-size: 22px;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto;
}
.tursvp-chat-close:hover { background: rgba(255,255,255,0.12); }

.tursvp-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tursvp-chat-empty {
    color: #6b7280;
    text-align: center;
    margin: auto 0;
    padding: 20px 12px;
    font-size: 13px;
}

.tursvp-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #dbe3ee;
    color: #94a3b8;
    font-size: 13px;
}

.tursvp-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tursvp-chat-avatar-admin {
    background: #fff;
    border-color: #e5e7eb;
    padding: 4px;
}

.tursvp-chat-avatar-admin img {
    object-fit: contain;
}

.tursvp-chat-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.tursvp-chat-msg-row-mine {
    flex-direction: row-reverse;
}

.tursvp-chat-msg {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    animation: tursvp-chat-fade-in 0.18s ease;
}

.tursvp-chat-msg-row .tursvp-chat-msg {
    max-width: min(80%, 260px);
}

@keyframes tursvp-chat-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tursvp-chat-msg-mine {
    align-self: flex-end;
    background: var(--admin-primary, #1a2b4a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tursvp-chat-msg-other {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.tursvp-chat-msg-meta {
    display: block;
    font-size: 10.5px;
    margin-top: 4px;
    opacity: 0.7;
}

.tursvp-chat-msg-pending { opacity: 0.65; }

.tursvp-chat-msg-attachments {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.tursvp-chat-msg-attachments button {
    display: block; width: 80px; height: 80px; overflow: hidden;
    border-radius: 8px; background: #e5e7eb; border: 1px solid #d1d5db;
    padding: 0; cursor: pointer;
}
.tursvp-chat-msg-attachments button:hover,
.tursvp-chat-msg-attachments button:focus { border-color: var(--admin-primary, #1a2b4a); outline: none; }
.tursvp-chat-msg-attachments img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tursvp-chat-image-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.tursvp-chat-image-modal[hidden] { display: none; }

.tursvp-chat-image-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
}

.tursvp-chat-image-modal-dialog {
    position: relative;
    max-width: min(94vw, 980px);
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tursvp-chat-image-modal-img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    background: #fff;
}

.tursvp-chat-image-modal-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    color: #111827;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.28);
}

.tursvp-chat-form {
    border-top: 1px solid #e5e7eb;
    padding: 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tursvp-chat-previews {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.tursvp-chat-preview {
    position: relative; width: 50px; height: 50px;
    border-radius: 6px; overflow: hidden; border: 1px solid #d1d5db;
}
.tursvp-chat-preview img { width: 100%; height: 100%; object-fit: cover; }
.tursvp-chat-preview-remove {
    position: absolute; top: -4px; right: -4px; width: 18px; height: 18px;
    border-radius: 50%; background: var(--admin-danger, #ef4444); color: #fff;
    border: none; font-size: 12px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}

.tursvp-chat-form-row {
    display: flex; align-items: center; gap: 6px;
    width: 100%;
    min-width: 0;
}

.tursvp-chat-attach-btn,
.tursvp-chat-send-btn {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    border: none; border-radius: 50%;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: background 0.18s;
}
.tursvp-chat-attach-btn { background: #e5e7eb; color: #4b5563; }
.tursvp-chat-attach-btn:hover { background: #d1d5db; }
.tursvp-chat-send-btn { background: var(--admin-primary, #1a2b4a); color: #fff; }
.tursvp-chat-send-btn:hover { background: #0f1d36; }
.tursvp-chat-send-btn:disabled,
.tursvp-chat-attach-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.tursvp-chat-send-btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    line-height: 1;
    font-size: 14px;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    transform: translateX(1px);
}

.tursvp-chat-input {
    flex: 1 1 auto; resize: none; min-height: 38px; max-height: 110px;
    min-width: 0;
    border: 1px solid #d1d5db; border-radius: 18px;
    padding: 8px 12px; font-size: 14px; font-family: inherit;
    line-height: 1.4;
    outline: none;
}
.tursvp-chat-input:focus { border-color: var(--admin-primary, #1a2b4a); }

.tursvp-chat-error {
    color: var(--admin-danger, #ef4444);
    font-size: 12px;
    padding: 0 4px;
    min-height: 16px;
}

.tursvp-chat-bloqueado {
    text-align: center; padding: 12px; font-size: 13px; color: #6b7280;
    background: #fef2f2; border-top: 1px solid #fecaca;
}

/* ===== Header prompt de nombre visitante ===== */
.tursvp-chat-header-nombre-prompt {
    flex: 0 0 100%;
    width: 100%;
    order: 10;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    padding-top: 10px;
    margin-top: 2px;
}

.tursvp-chat-header-nombre-prompt-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tursvp-chat-header-nombre-prompt-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tursvp-chat-header-nombre-input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 12px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.tursvp-chat-header-nombre-input::placeholder { color: rgba(255, 255, 255, 0.55); }
.tursvp-chat-header-nombre-input:focus {
    border-color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.25);
}

.tursvp-chat-header-nombre-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.tursvp-chat-header-nombre-btn {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 12px;
    padding: 6px 16px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
}

.tursvp-chat-header-nombre-btn:hover { background: rgba(255, 255, 255, 0.38); }
.tursvp-chat-header-nombre-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.tursvp-chat-header-nombre-cancelar {
    background: transparent;
    color: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 6px 14px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tursvp-chat-header-nombre-cancelar:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.55);
}

.tursvp-chat-header-nombre-error {
    color: #fff;
    background: rgba(239, 68, 68, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.35;
}

.tursvp-chat-header-nombre-error:empty {
    display: none;
}

/* ===== Indicador "está escribiendo" ===== */
.tursvp-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
}

.tursvp-chat-typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.tursvp-chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: tursvp-typing-bounce 1.2s infinite ease-in-out;
}

.tursvp-chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.tursvp-chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Formulario inicial visitante */
.tursvp-chat-visitante-form {
    display: flex; flex-direction: column; gap: 8px;
    padding: 14px; background: #fff;
}
.tursvp-chat-visitante-form input {
    border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px;
    font-size: 14px; outline: none;
}
.tursvp-chat-visitante-form input:focus { border-color: var(--admin-primary, #1a2b4a); }
.tursvp-chat-visitante-form button {
    background: var(--admin-primary, #1a2b4a); color: #fff; border: none;
    border-radius: 8px; padding: 9px 14px; font-size: 14px; cursor: pointer;
}
.tursvp-chat-visitante-form p {
    font-size: 12px; color: #6b7280; margin: 0;
}

@media (max-width: 575.98px) {
    .tursvp-chat-panel {
        right: 8px;
        bottom: 78px;
        width: calc(100vw - 16px);
        height: calc(var(--tursvp-chat-vh, 100vh) - 155px);
        max-height: calc(var(--tursvp-chat-vh, 100vh) - 155px);
        min-height: 280px;
    }

    .tursvp-chat-input,
    .tursvp-chat-visitante-form input,
    .tursvp-chat-header-nombre-input {
        font-size: 16px;
    }

    .tursvp-chat-header-nombre-btn,
    .tursvp-chat-header-nombre-cancelar {
        font-size: 13px;
    }
}

/* ===== Burbuja de bienvenida proactiva ===== */
.tursvp-chat-bienvenida {
    position: fixed;
    bottom: 90px;
    right: 22px;
    background: #1a2b4a;
    color: #fff;
    border-radius: 14px;
    padding: 10px 12px 10px 16px;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 6px 22px rgba(15, 29, 54, 0.28);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9990;
    cursor: pointer;
    max-width: 210px;
    animation: tursvp-bienvenida-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.tursvp-chat-bienvenida.saliendo {
    animation: tursvp-bienvenida-out 0.3s ease-in forwards;
}

.tursvp-chat-bienvenida-cerrar {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
}

.tursvp-chat-bienvenida-cerrar:hover { color: #fff; }

@keyframes tursvp-bienvenida-in {
    from { opacity: 0; transform: translateY(14px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

@keyframes tursvp-bienvenida-out {
    from { opacity: 1; transform: translateY(0);   }
    to   { opacity: 0; transform: translateY(10px); }
}

@media (max-width: 575.98px) {
    .tursvp-chat-bienvenida { right: 8px; bottom: 78px; }
}

/* ===== Guía rápida del chat (wizard) ===== */
.tursvp-chat-guia {
    border-top: 1px solid #e8ecf3;
    background: linear-gradient(180deg, #f9fafc 0%, #fff 100%);
    padding: 12px 14px 14px;
    flex-shrink: 0;
}

.tursvp-chat-guia-etapa {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--admin-primary, #1a2b4a);
}

.tursvp-chat-guia-texto-wrap {
    margin-bottom: 10px;
}

.tursvp-chat-guia-pregunta {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: #1e293b;
}

.tursvp-chat-guia-desc {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.35;
    color: #64748b;
}

.tursvp-chat-guia-opciones {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tursvp-chat-guia-op {
    text-align: left;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
    border: 1px solid #d7dee9;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tursvp-chat-guia-op:hover,
.tursvp-chat-guia-op:focus {
    outline: none;
    border-color: rgba(255, 111, 145, 0.55);
    box-shadow: 0 4px 10px rgba(255, 111, 145, 0.12);
}

.tursvp-chat-guia-op.is-selected {
    border-color: #ff6f91;
    background: rgba(255, 111, 145, 0.08);
}

.tursvp-chat-guia-hint {
    margin: 8px 0 6px;
    font-size: 11px;
    color: #94a3b8;
}

.tursvp-chat-guia-nav {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.tursvp-chat-guia-btn {
    flex: 1;
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    color: #334155;
}

.tursvp-chat-guia-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tursvp-chat-guia-btn-back {
    max-width: 42%;
}

.tursvp-chat-guia-btn-next {
    flex: 1.3;
    background: linear-gradient(135deg, #ff6f91 0%, #ff9671 100%);
    border-color: transparent;
    color: #fff;
}

@media (max-width: 575.98px) {
    .tursvp-chat-guia {
        padding: 10px 10px 12px;
    }
    .tursvp-chat-guia-pregunta {
        font-size: 14px;
    }
    .tursvp-chat-guia-op {
        padding: 7px 9px;
        font-size: 12px;
    }
}
