/**
 * Estilos del Chatbot Conversacional WhatsApp
 * Externalizado desde class-ade-whatsapp-frontend.php
 */

/* Box-sizing global dentro del modal */
.modal,
.modal * { box-sizing: border-box; }

/* ============== Botón flotante ============== */
button.whatsapp-float-btn,
.whatsapp-float-btn {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    min-height: 64px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background-color: #25d366 !important;
    background-image: none !important;
    color: #ffffff !important;
    border: none !important;
    outline: none !important;
    box-shadow: 0 8px 24px rgba(37, 211, 102, .25), 0 2px 6px rgba(0, 0, 0, .08) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    z-index: 999998;
    transition: transform .25s ease, box-shadow .25s ease;
    text-indent: 0 !important;
    line-height: 1 !important;
    overflow: visible !important;
}
button.whatsapp-float-btn:hover,
.whatsapp-float-btn:hover {
    transform: scale(1.08);
    background-color: #25d366 !important;
    box-shadow: 0 12px 32px rgba(37, 211, 102, .35), 0 2px 8px rgba(0, 0, 0, .1) !important;
}
.whatsapp-float-btn svg {
    width: 34px !important;
    height: 34px !important;
    display: block !important;
    fill: #ffffff !important;
    color: #ffffff !important;
}
.whatsapp-float-btn svg path {
    fill: #ffffff !important;
}
.whatsapp-float-btn::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    background: #ff3b30;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: .75; }
}

/* ============== Botón interno WhatsApp ============== */
.whatsapp-btnform {
    background-color: #25d366 !important;
    color: #fff;
    padding: 14px 22px;
    font-size: 16px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(37, 211, 102, .25);
    font-weight: 600;
    border: none;
    transition: background-color .25s ease, transform .15s ease, box-shadow .25s ease;
}
.whatsapp-btnform:hover {
    background-color: #1fb557 !important;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, .35);
}
.whatsapp-btnform span { font-size: 20px; }

/* ============== Botón shortcode ============== */
.ade-wa-shortcode-btn,
.ade-whatsapp-shortcode-btn {
    background-color: #075e54 !important;
    color: #ffffff !important;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .18s ease;
    box-shadow: 0 6px 16px rgba(7, 94, 84, .15);
}
.ade-wa-shortcode-btn:hover,
.ade-whatsapp-shortcode-btn:hover {
    background-color: #064e44 !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(7, 94, 84, .22);
}

/* ============== Modal ============== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity .3s ease-in-out, visibility .3s;
    z-index: 999999;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.modal.show { visibility: visible; opacity: 1; }
.modal-content {
    background: #fff;
    width: 50%;
    height: 95%;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .12), 0 4px 14px rgba(0, 0, 0, .06);
}
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
}
.modal .modal-header {
    background: #f9fafb !important;
    padding: 12px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 1px solid #eef0f2 !important;
}
.modal .modal-header h2,
.modal-content .modal-header h2 {
    font-size: 18px !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #1f2937 !important;
    font-family: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    border: 0 !important;
    background: transparent !important;
}

/* Botón cerrar accesible: área 44x44 mínimo */
.close-btnform {
    background: transparent !important;
    border: 0 !important;
    color: #4b5563 !important;
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease;
}
.close-btnform:hover {
    background: #eef0f2 !important;
    color: #111827 !important;
}
.close-btnform:focus-visible {
    outline: 2px solid #25d366;
    outline-offset: 2px;
}
.close-btnform svg { width: 20px; height: 20px; display: block; }

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 768px) {
    .modal-body {
        padding: 12px;
        padding-bottom: 16px;
        font-size: 16px;
    }
    .whatsapp-container {
        padding: 12px;
    }
}

/* ============== Chat ============== */
.chat-container { flex: 1; overflow-y: auto; padding: 5px; overflow-x: hidden; scroll-behavior: smooth; }
.message-row { display: flex; margin-bottom: 20px; animation: fadeIn .3s ease-out forwards; flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; margin-right: 12px; flex: 0 0 32px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-content { max-width: calc(100% - 56px); min-width: 0; }
.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    display: inline-block;
    margin-bottom: 4px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.bot-message .message-bubble { background: #1f2937; color: #f3f4f6; }
.user-message { justify-content: flex-end; }
.user-message .message-bubble { background: #d1d5db; color: #111827; font-weight: 500; }
.message-meta { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* ============== Indicador de escritura ============== */
.typing-indicator {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #1f2937;
    border-radius: 18px;
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============== Opciones ============== */
.options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    margin-left: 44px;
    max-width: 80%;
    margin-bottom: 20px;
    min-width: 0;
}
@media (max-width: 768px) {
    .options { margin-left: 0; max-width: 100%; padding: 0 4px; }
}
.option-btnform {
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    color: #111827 !important;
    border: 1px solid #e5e7eb !important;
    background: #fff !important;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: background-color .2s, border-color .2s, transform .1s;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    min-width: 0;
}
.option-btnform:hover { background: #f9fafb !important; border-color: #d1d5db !important; }
.option-btnform:focus { outline: 2px solid #25d366; outline-offset: 2px; }

.whatsapp-container {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border-top: 1px solid #eef0f2;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Inputs personalizados */
input.option-btnform {
    cursor: text;
    font-size: 16px;
    line-height: 1.5;
    min-height: 48px;
    -webkit-text-size-adjust: 100%;
}

/* Select: evitar clipping del texto en Chrome / Firefox / Safari */
select.option-btnform {
    cursor: pointer;
    font-size: 16px;
    line-height: 1.5;
    min-height: 48px;
    height: auto;
    padding: 10px 36px 10px 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
select.option-btnform option {
    white-space: normal;
    line-height: 1.4;
    padding: 6px 0;
    color: #111827;
}

/* Ocultar botón flotante en móvil cuando el modal está abierto */
@media (max-width: 768px) {
    button.whatsapp-float-btn.modal-open,
    .whatsapp-float-btn.modal-open {
        display: none !important;
    }
}
