/* frontend.css comentado: estilos del chat visible para el cliente. */
.acp-chat-widget [hidden] {
    display: none !important;
}

.acp-chat-widget {
    font-family: Arial, Helvetica, sans-serif;
    color: #1f2937;
}

.acp-floating-chat {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 999999;
}

/* Chat en modo página: por defecto ocupa casi todo el área visible del navegador.
   El ancho y alto se controlan desde Ajustes → Asistente de Chat mediante variables CSS. */
.acp-page-chat {
    position: relative;
    left: 50%;
    z-index: 1;
    width: var(--acp-page-width-desktop, 96vw);
    max-width: var(--acp-page-width-desktop, 96vw);
    height: var(--acp-page-height-desktop, 92dvh);
    margin: 2dvh 0;
    transform: translateX(-50%);
    box-sizing: border-box;
}

.acp-fab {
    width: 64px;
    height: 64px;
    border: 0;
    border-radius: 50%;
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
    font-size: 30px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.acp-fab-close {
    display: none;
    font-size: 42px;
    line-height: 1;
}

.acp-floating-chat.is-open .acp-fab-open {
    display: none;
}

.acp-floating-chat.is-open .acp-fab-close {
    display: block;
}

.acp-panel {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.acp-floating-chat .acp-panel {
    position: absolute;
    right: 0;
    bottom: 82px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: auto;
    max-height: 75vh;
    opacity: 0;
    transform: translateY(15px);
    pointer-events: none;
    transition: 0.18s ease;
}

.acp-floating-chat.is-open .acp-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* El panel en modo página usa altura completa para que mensajes y entrada aprovechen el espacio disponible. */
.acp-page-chat .acp-panel {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

/* Encabezado de bienvenida/menu del chat. */
.acp-panel-header {
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
    padding: 20px 22px;
    display: flex;
    gap: 14px;
    align-items: center;
    box-sizing: border-box;
}

/* En modo página, el alto/ancho del encabezado se controla desde Ajustes → Asistente de Chat. */
.acp-page-chat .acp-panel-header {
    min-height: var(--acp-intro-header-height-desktop, 118px);
    width: var(--acp-header-width-desktop, 100%);
    margin: 0 auto;
    padding: 16px 22px;
}

.acp-panel-icon {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.acp-panel-title {
    font-size: 20px;
    font-weight: 700;
}

.acp-panel-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 3px;
}

.acp-panel-body {
    padding: 18px 20px 20px;
}

/* En modo página, el área de selección/perfil también se expande y puede desplazar internamente si hay mucho contenido. */
.acp-page-chat .acp-panel-body {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 28px 20px;
    flex: 1;
    overflow: auto;
    box-sizing: border-box;
}

.acp-page-chat .acp-profile-view,
.acp-page-chat .acp-menu-view,
.acp-page-chat .acp-closed-view {
    max-width: 720px;
    margin: 0 auto;
}

.acp-schedule {
    font-size: 13px;
    line-height: 1.5;
    color: #667085;
    margin: 0 0 16px;
}

.acp-profile-form,
.acp-closed-card {
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}

.acp-profile-form h3,
.acp-closed-card h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.acp-profile-form label {
    display: block;
    font-weight: 600;
    margin: 14px 0 8px;
}

.acp-profile-form label small,
.acp-muted {
    color: #667085;
    font-weight: 400;
}

.acp-required {
    color: #dc2626;
}

.acp-customer-name,
.acp-customer-phone {
    width: 100%;
    margin-top: 6px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 11px;
    font-size: 14px;
    box-sizing: border-box;
}

.acp-profile-submit,
.acp-continue-conversation,
.acp-start-new-conversation {
    width: 100%;
    border: 0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 12px;
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.acp-start-new-conversation {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

.acp-route-card {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--acp-primary, #0b65b9);
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 14px;
    margin: 12px 0;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}

.acp-route-card:hover {
    background: #f8fafc;
}

.acp-route-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e7f1fd;
    color: var(--acp-primary, #0b65b9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex: none;
}

.acp-route-human {
    background: #f0fdf4;
    color: #16a34a;
}

.acp-route-card strong {
    display: block;
    font-size: 15px;
}

.acp-route-card small {
    display: block;
    color: #667085;
    margin-top: 3px;
}

.acp-route-card b {
    margin-left: auto;
    font-size: 24px;
    color: #475467;
}

.acp-secure {
    background: #f8fafc;
    border-radius: 8px;
    color: #667085;
    font-size: 12px;
    padding: 12px;
    margin-top: 14px;
    text-align: center;
}

.acp-chat-view {
    height: 460px;
    max-height: 68vh;
    display: flex;
    flex-direction: column;
}

/* La vista de conversación en modo página ya no usa altura fija: ocupa el espacio sobrante del panel. */
.acp-page-chat .acp-chat-view {
    height: auto;
    max-height: none;
    flex: 1;
    min-height: 0;
}

/* Encabezado interno de la conversación. */
.acp-chat-topbar {
    min-height: 60px;
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    box-sizing: border-box;
}

/* En modo página, el encabezado interno también puede configurarse por escritorio/móvil. */
.acp-page-chat .acp-chat-topbar {
    min-height: var(--acp-chat-header-height-desktop, 96px);
    width: var(--acp-header-width-desktop, 100%);
    margin: 0 auto;
}

.acp-back {
    font-size: 34px;
    line-height: 1;
    background: transparent;
    border: 0;
    color: #ffffff;
    cursor: pointer;
    padding: 0 8px;
}

.acp-chat-topbar small {
    display: block;
    opacity: 0.9;
    margin-top: 2px;
}

.acp-browser-notification-button {
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 8px;
    cursor: pointer;
    white-space: nowrap;
}

.acp-browser-notification-button:hover,
.acp-browser-notification-button:focus {
    background: rgba(255, 255, 255, 0.26);
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 2px;
}

.acp-browser-notification-button[hidden] {
    display: none !important;
}


.acp-messages {
    flex: 1;
    overflow: auto;
    background: #f8fafc;
    padding: 16px;
}

.acp-message {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 12px;
    margin: 8px 0;
    line-height: 1.35;
    font-size: 14px;
    clear: both;
}

.acp-message small {
    display: block;
    text-align: right;
    color: #667085;
    margin-top: 5px;
    font-size: 11px;
}

.acp-message.customer {
    background: #d9f7c7;
    margin-left: auto;
}

.acp-message.bot,
.acp-message.agent {
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.acp-message.system {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    max-width: 100%;
    font-size: 12px;
    text-align: center;
}

.acp-sender {
    font-weight: 700;
    color: var(--acp-primary, #0b65b9);
    font-size: 12px;
    margin-bottom: 3px;
}

.acp-input-row {
    display: flex;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    padding: 12px;
    background: #ffffff;
}

.acp-input {
    flex: 1;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 11px;
    font-size: 14px;
    line-height: 1.35;
    font-family: inherit;
    box-sizing: border-box;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
}

.acp-send {
    width: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
}

.acp-loading {
    opacity: 0.65;
}

.acp-product-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.acp-product-link {
    display: inline-block;
    align-self: flex-start;
    padding: 7px 10px;
    border: 1px solid var(--acp-primary, #0b65b9);
    border-radius: 7px;
    text-decoration: none;
    font-weight: 600;
}

.acp-error {
    color: #b42318;
    font-size: 13px;
    margin: 8px 0;
}

@media (max-width: 480px) {
    .acp-floating-chat {
        right: 16px;
        bottom: 16px;
    }

    .acp-floating-chat .acp-panel {
        right: -4px;
        width: calc(100vw - 24px);
    }

    .acp-chat-view,
    .acp-page-chat .acp-chat-view {
        height: auto;
        max-height: none;
    }

    .acp-fab {
        width: 58px;
        height: 58px;
    }

    /* En móvil el chat intenta cubrir todo el alto visible para eliminar espacios vacíos abajo. */
    .acp-page-chat {
        width: var(--acp-page-width-mobile, 100vw);
        max-width: var(--acp-page-width-mobile, 100vw);
        height: var(--acp-page-height-mobile, 100dvh);
        margin: 0;
    }

    .acp-page-chat .acp-panel {
        border-radius: 0;
        min-height: 0;
    }

    .acp-page-chat .acp-panel-header {
        min-height: var(--acp-intro-header-height-mobile, 104px);
        width: var(--acp-header-width-mobile, 100%);
        padding: 12px 18px;
    }

    .acp-page-chat .acp-chat-topbar {
        min-height: var(--acp-chat-header-height-mobile, 84px);
        width: var(--acp-header-width-mobile, 100%);
        padding: 8px 10px;
    }

    .acp-panel-title {
        font-size: 18px;
    }

    .acp-panel-subtitle,
    .acp-chat-topbar small {
        font-size: 12px;
    }

    .acp-page-chat .acp-panel-body {
        padding: 18px 14px;
    }
}

.acp-chat-heading {
    min-width: 0;
    flex: 1;
}

.acp-front-close {
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.acp-front-close:hover {
    background: rgba(255, 255, 255, 0.26);
}

.acp-close-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(15, 23, 42, 0.48);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.acp-close-dialog {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    color: #1f2937;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.acp-close-dialog h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.acp-close-dialog p {
    color: #667085;
    line-height: 1.45;
    margin: 0 0 14px;
}

.acp-hide-history-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    color: #344054;
    line-height: 1.4;
    font-size: 13px;
}

.acp-hide-history-label input {
    margin-top: 2px;
}

.acp-close-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.acp-cancel-close,
.acp-confirm-close {
    flex: 1;
    border-radius: 8px;
    padding: 11px 12px;
    font-weight: 700;
    cursor: pointer;
}

.acp-cancel-close {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
}

.acp-confirm-close {
    border: 0;
    background: #b42318;
    color: #ffffff;
}

.acp-confirm-close:disabled {
    opacity: 0.65;
    cursor: progress;
}

.acp-privacy-notice {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Imágenes en chat - fase 1 */
.acp-image-button,
.acp-audio-button {
    min-width: 82px;
    width: auto;
    border: 1px solid var(--acp-image-button-bg, var(--acp-primary, #0b65b9));
    border-radius: 8px;
    background: var(--acp-image-button-bg, var(--acp-primary, #0b65b9));
    color: var(--acp-image-button-color, #ffffff);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    padding: 0 12px;
    white-space: nowrap;
}

.acp-image-button:hover:not(:disabled),
.acp-audio-button:hover:not(:disabled) {
    filter: brightness(0.95);
}

.acp-image-button:disabled,
.acp-audio-button:disabled,
.acp-image-button[aria-disabled="true"],
.acp-audio-button[aria-disabled="true"],
.acp-image-button.is-not-allowed,
.acp-audio-button.is-not-allowed {
    opacity: 0.7;
    cursor: pointer;
}

.acp-image-button.is-not-allowed:hover,
.acp-audio-button.is-not-allowed:hover {
    filter: none;
}

.acp-audio-button.is-recording {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
    animation: acp-recording-pulse 1s ease-in-out infinite;
}

@keyframes acp-recording-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.72;
    }
}

.acp-file-notice > div {
    border: 1px solid #f0c36d;
    background: #fff8e5;
    color: #5f4300;
}

.acp-image-wrap {
    margin: 2px 0 4px;
}

.acp-chat-image {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    object-fit: contain;
    background: #ffffff;
}

.acp-message.customer .acp-chat-image {
    margin-left: auto;
}

@media (max-width: 480px) {
    .acp-chat-image {
        max-height: 220px;
    }
}

.acp-audio-wrap {
    margin: 2px 0 4px;
}

.acp-chat-audio {
    width: 100%;
    max-width: 300px;
    display: block;
}

/* Reproductor de audio nativo */
.acp-native-audio-player {
    display: block;
    width: 100%;
    max-width: 340px;
}

.acp-native-audio-player audio,
.acp-native-audio {
    display: block;
    width: 100%;
    max-width: 340px;
}

.acp-native-audio-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

.acp-message.customer .acp-native-audio-meta {
    color: rgba(255, 255, 255, 0.86);
}

.acp-audio-review-card .acp-native-audio-player {
    max-width: 100%;
    margin: 8px 0 12px;
}

.acp-audio-review-card .acp-native-audio-player audio {
    max-width: 100%;
}

@media (max-width: 520px) {
    .acp-input-row {
        flex-wrap: wrap;
    }

    .acp-input {
        flex-basis: 100%;
        order: 1;
    }

    .acp-image-button,
    .acp-audio-button,
    .acp-send {
        order: 2;
    }
}


/* Avisos amigables de permiso de micrófono */
.acp-mic-notice .acp-mic-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid #d8e6f4;
    border-radius: 10px;
    background: #f7fbff;
}

.acp-mic-notice .acp-mic-card p {
    margin: 0;
}

.acp-mic-enable-button {
    align-self: flex-start;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    background: #0b65b9;
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
}

.acp-mic-enable-button:hover {
    filter: brightness(0.95);
}


/* Zoom de imágenes del chat */
.acp-image-zoom-trigger {
    display: block;
    max-width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    line-height: 0;
}

.acp-image-zoom-trigger:focus {
    outline: 2px solid var(--acp-primary, #0b65b9);
    outline-offset: 3px;
    border-radius: 10px;
}

.acp-image-zoom-open {
    overflow: hidden;
}

.acp-image-zoom-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}

.acp-image-zoom-modal.is-open {
    display: block;
}

.acp-image-zoom-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

.acp-image-zoom-dialog {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 18px 24px;
}

/* Mensaje temporal mientras se carga la imagen ampliada.
   Evita mostrar la imagen anterior durante la espera del endpoint protegido. */
.acp-image-zoom-loading {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 1000000;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    min-height: 60px;
    padding: 14px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.acp-image-zoom-modal.is-loading .acp-image-zoom-loading {
    display: inline-flex;
}

.acp-image-zoom-modal.has-error .acp-image-zoom-loading {
    display: inline-flex;
}

.acp-image-zoom-modal.has-error .acp-image-zoom-loading::after {
    content: ' No se pudo cargar.';
}

.acp-image-zoom-img {
    display: block;
    max-width: 96vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    background: #ffffff;
}

/* La imagen ampliada solo se muestra cuando terminó de cargar.
   Si se abre otra imagen, el modal muestra “Cargando imagen...” en vez de la foto anterior. */
.acp-image-zoom-modal.is-loading .acp-image-zoom-img,
.acp-image-zoom-modal.has-error .acp-image-zoom-img {
    display: none;
}

.acp-image-zoom-modal.is-loaded .acp-image-zoom-img {
    display: block;
}

.acp-image-zoom-close {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 1000000;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    color: #111827;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.acp-image-zoom-close:hover,
.acp-image-zoom-close:focus {
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .acp-image-zoom-dialog {
        padding: 58px 10px 18px;
    }

    .acp-image-zoom-img {
        max-width: 98vw;
        max-height: 84vh;
    }

    .acp-image-zoom-close {
        top: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
}

/* Revisión de audio antes de enviar */
.acp-audio-review-message {
    max-width: 100%;
}

.acp-audio-review-card {
    background: #ffffff;
    border: 1px solid #d7e2ef;
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.acp-audio-review-card strong {
    display: block;
    margin-bottom: 4px;
    color: #0f172a;
}

.acp-audio-review-meta {
    margin: 0 0 10px;
    color: #526078;
    font-size: 13px;
}

.acp-audio-review-card audio {
    display: block;
    width: 100%;
    margin: 8px 0 12px;
}

.acp-audio-review-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.acp-audio-review-actions button {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 600;
}

.acp-audio-review-actions .acp-audio-cancel {
    background: #e5e7eb;
    color: #111827;
}

.acp-audio-review-actions .acp-audio-send {
    background: #0b65b9;
    color: #ffffff;
}

.acp-audio-review-actions button:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* Reproductor personalizado de audio */
.acp-custom-audio-player {
    --acp-audio-progress: 0%;
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(100%, 390px);
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    box-sizing: border-box;
}

.acp-custom-audio-el {
    display: none;
}

.acp-custom-audio-play {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #0f172a;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.acp-custom-audio-play:hover,
.acp-custom-audio-play:focus {
    background: rgba(15, 23, 42, 0.08);
    outline: none;
}

.acp-custom-audio-current,
.acp-custom-audio-duration {
    flex: 0 0 auto;
    min-width: 34px;
    font-size: 12px;
    color: #334155;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.acp-custom-audio-duration {
    text-align: right;
}

.acp-custom-audio-range {
    flex: 1 1 auto;
    min-width: 70px;
    height: 6px;
    border-radius: 999px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(
        to right,
        var(--acp-primary, #0b65b9) 0%,
        var(--acp-primary, #0b65b9) var(--acp-audio-progress),
        #cbd5e1 var(--acp-audio-progress),
        #cbd5e1 100%
    );
    cursor: pointer;
}

.acp-custom-audio-range::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: var(--acp-primary, #0b65b9);
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.25);
}

.acp-custom-audio-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: var(--acp-primary, #0b65b9);
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.25);
}

.acp-custom-audio-range::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: transparent;
}



.acp-custom-audio-player.is-loading .acp-custom-audio-play {
    cursor: wait;
}

.acp-custom-audio-loading {
    flex: 0 0 auto;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}

.acp-custom-audio-error {
    flex: 1 0 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding-left: 36px;
    font-size: 12px;
    line-height: 1.35;
    color: #991b1b;
}

.acp-custom-audio-error[hidden],
.acp-custom-audio-loading[hidden] {
    display: none !important;
}

.acp-custom-audio-retry {
    flex: 0 0 auto;
    padding: 2px 8px;
    border: 1px solid #fecaca;
    border-radius: 999px;
    background: #ffffff;
    color: #991b1b;
    font-size: 11px;
    line-height: 1.5;
    cursor: pointer;
}

.acp-custom-audio-retry:hover,
.acp-custom-audio-retry:focus {
    background: #fef2f2;
    outline: none;
}

.acp-custom-audio-player.has-error {
    border: 1px solid #fecaca;
}

.acp-message.customer .acp-custom-audio-player {
    margin-left: auto;
}

.acp-audio-review-card .acp-custom-audio-player {
    width: 100%;
    max-width: 420px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
}

@media (max-width: 480px) {
    .acp-custom-audio-player {
        gap: 6px;
        padding: 8px;
    }

    .acp-custom-audio-current,
    .acp-custom-audio-duration {
        min-width: 30px;
        font-size: 11px;
    }
}

/* Separador de fecha entre mensajes del chat del cliente. */
.acp-date-separator {
    display: block;
    width: fit-content;
    align-self: center;
    margin: 14px auto 10px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #eef2f7;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

/* Mensaje sustituido después de que el cliente o agente borra texto, foto o audio. */
.acp-deleted-message {
    color: #667085;
    font-style: italic;
}

/* Botón pequeño para borrar mensajes recientes dentro de la ventana configurada. */
.acp-delete-message {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 3px 8px;
    border: 1px solid #d0d5dd;
    border-radius: 999px;
    background: #ffffff;
    color: #344054;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
}

.acp-delete-message:hover,
.acp-delete-message:focus {
    border-color: #f04438;
    color: #b42318;
    outline: none;
}


/* Oculta la opción visual de descarga del audio en navegadores basados en WebKit/Chromium.
   Esta regla complementa controlsList="nodownload" usado en el HTML del reproductor. */
.acp-native-audio::-webkit-media-controls-download-button {
    display: none;
}

/* Vista previa de múltiples imágenes seleccionadas por el cliente antes de enviarlas.
   A diferencia del backend del agente, aquí se usa un solo texto para todo el grupo. */
.acp-customer-image-preview {
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    padding: 10px 12px;
}

.acp-customer-preview-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.acp-customer-preview-header strong {
    font-size: 13px;
    color: #1f2937;
}

.acp-customer-preview-header small {
    color: #667085;
    font-size: 12px;
}

.acp-customer-preview-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 2px 6px;
}

.acp-customer-preview-thumb {
    position: relative;
    width: 70px;
    height: 70px;
    flex: 0 0 auto;
    border: 2px solid var(--acp-primary, #0b65b9);
    border-radius: 9px;
    background: #ffffff;
    overflow: visible;
}

.acp-customer-preview-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 7px;
}

.acp-customer-preview-thumb span {
    position: absolute;
    left: 4px;
    bottom: 4px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.acp-customer-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #111827;
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    line-height: 22px;
    z-index: 2;
}

.acp-customer-preview-remove:hover {
    background: #dc2626;
}

.acp-customer-image-caption {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 9px 10px;
    resize: vertical;
    min-height: 42px;
    font-size: 13px;
}

.acp-customer-preview-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.acp-customer-send-images,
.acp-customer-clear-images {
    border-radius: 8px;
    padding: 8px 10px;
    font-weight: 700;
    cursor: pointer;
}

.acp-customer-send-images {
    border: 0;
    background: var(--acp-primary, #0b65b9);
    color: #ffffff;
}

.acp-customer-clear-images {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
}

/* Grupo de imágenes del cliente renderizado como un solo mensaje visual. */
.acp-image-group-wrap {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 2px 0 4px;
    max-width: 360px;
}

.acp-image-group-item {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: zoom-in;
}

.acp-image-group-item .acp-chat-image {
    width: 100%;
    height: 130px;
    object-fit: cover;
}

@media (max-width: 480px) {
    .acp-image-group-wrap {
        max-width: 100%;
    }

    .acp-image-group-item .acp-chat-image {
        height: 112px;
    }
}

/* Carrusel de imágenes ampliadas: permite navegar entre fotos del mismo chat sin cerrar el zoom. */
.acp-image-zoom-nav {
    position: fixed;
    top: 50%;
    z-index: 1000000;
    width: 52px;
    height: 52px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    color: #111827;
    font-size: 42px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.acp-image-zoom-prev {
    left: 18px;
}

.acp-image-zoom-next {
    right: 18px;
}

.acp-image-zoom-nav:hover:not(:disabled),
.acp-image-zoom-nav:focus:not(:disabled) {
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.acp-image-zoom-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

/* v3.28: al usar zoom adicional, se ocultan los botones anterior/siguiente hasta volver a 100%. */
.acp-image-zoom-modal.is-extra-zoomed .acp-image-zoom-nav {
    display: none !important;
}

.acp-image-zoom-counter {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 1000000;
    transform: translateX(-50%);
    min-width: 64px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    color: #111827;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.acp-image-zoom-modal.has-carousel .acp-image-zoom-dialog {
    padding-left: 86px;
    padding-right: 86px;
}

@media (max-width: 600px) {
    .acp-image-zoom-nav {
        width: 42px;
        height: 42px;
        font-size: 34px;
    }

    .acp-image-zoom-prev {
        left: 8px;
    }

    .acp-image-zoom-next {
        right: 8px;
    }

    .acp-image-zoom-modal.has-carousel .acp-image-zoom-dialog {
        padding-left: 56px;
        padding-right: 56px;
    }
}


/* Zoom adicional de escritorio/laptop dentro del modal de imagen.
   Los botones + y - permiten ampliar detalles pequeños usando la imagen original. */
.acp-image-zoom-dialog {
    overflow: auto;
}

.acp-image-zoom-stage {
    width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.acp-image-zoom-img {
    flex: 0 0 auto;
}

.acp-image-zoom-modal.is-extra-zoomed .acp-image-zoom-stage {
    align-items: flex-start;
    justify-content: flex-start;
}

.acp-image-zoom-modal.is-loaded .acp-image-zoom-img {
    cursor: zoom-in;
}

.acp-image-zoom-modal.is-extra-zoomed .acp-image-zoom-img {
    cursor: zoom-in;
}

.acp-image-zoom-extra-controls {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 1000000;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, var(--acp-image-zoom-controls-opacity, 1));
    color: #111827;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.acp-image-zoom-extra-button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.09);
    color: #111827;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.acp-image-zoom-extra-button:hover:not(:disabled),
.acp-image-zoom-extra-button:focus:not(:disabled) {
    background: rgba(17, 24, 39, 0.16);
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.acp-image-zoom-extra-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.acp-image-zoom-scale {
    min-width: 48px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

@media (max-width: 780px) {
    .acp-image-zoom-extra-controls {
        display: none;
    }
}


/* v3.32: estado visual de miniaturas con lazy loading.
   El navegador no descarga la miniatura protegida hasta que el elemento entra en pantalla. */
.acp-image-wrap .acp-chat-image.acp-lazy-image:not(.is-loaded) {
    width: 320px;
    max-width: 100%;
    min-height: 180px;
    background: #f3f4f6;
}

.acp-image-group-item .acp-chat-image.acp-lazy-image:not(.is-loaded) {
    width: 100%;
    background: #f3f4f6;
}

.acp-chat-image.acp-lazy-image.is-loading {
    opacity: 0.9;
}

.acp-chat-image.acp-lazy-image.is-error {
    min-height: 80px;
    border: 1px dashed #c3c4c7;
}

/* v3.33: mensaje visible en el placeholder mientras lazy loading descarga la miniatura real. */
.acp-image-zoom-trigger.acp-lazy-loading-wrap {
    position: relative;
}

.acp-image-zoom-trigger.acp-lazy-loading-wrap::after {
    content: 'Cargando';
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #4b5563;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* v3.45.10: tarjetas WooCommerce renderizadas localmente dentro del chat. */
.acp-product-cards {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.acp-product-card {
    border: 1px solid #d7dde5;
    border-radius: 12px;
    padding: 12px;
    background: #ffffff;
    max-width: 520px;
}

.acp-product-card-title {
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 4px;
}

.acp-product-card-price {
    font-weight: 700;
    margin-bottom: 3px;
}

.acp-product-card-stock {
    font-size: 13px;
    margin-bottom: 8px;
}

.acp-product-card-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.acp-product-card-image-trigger {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: zoom-in;
    border-radius: 10px;
    overflow: hidden;
    min-height: 110px;
}

.acp-product-card-image {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: contain;
    background: #ffffff;
}

.acp-product-gallery-more {
    margin-top: 8px;
}

.acp-product-gallery-more > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--acp-primary, #0b65b9);
}

.acp-product-card-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.acp-product-description-button,
.acp-product-card-link {
    display: inline-block;
    padding: 7px 10px;
    border: 1px solid var(--acp-primary, #0b65b9);
    border-radius: 7px;
    text-decoration: none;
    font-weight: 600;
    background: #ffffff;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.acp-product-description-button:disabled { opacity: .65; cursor: wait; }
.acp-product-description-panel {
    margin-top: 9px;
    padding: 10px;
    border-radius: 8px;
    background: #f6f8fa;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.acp-product-description-panel[hidden] { display: none !important; }
.acp-product-description-panel > :first-child { margin-top: 0; }
.acp-product-description-panel > :last-child { margin-bottom: 0; }
.acp-product-description-panel table { max-width: 100%; border-collapse: collapse; }
.acp-product-description-panel th,
.acp-product-description-panel td { border: 1px solid #d7dde5; padding: 5px; }
.acp-product-description-empty { margin: 0; font-style: italic; }

@media (max-width: 480px) {
    .acp-product-card {
        max-width: 100%;
    }

    .acp-product-card-images {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .acp-product-card-image {
        height: 130px;
    }
}
