/**
 * Chatbot IA WP - Estilos v2.0
 */
/* reCAPTCHA detrás del chatbot */
.rc-anchor,
.rc-anchor-invisible,
iframe[src*="recaptcha"] {
    z-index: 99990 !important;
}
body:has(.chatbot-ia-window.open) div[style*="z-index: 2000000000"] {
    z-index: 99990 !important;
}
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* O ocultarlo cuando el chat está abierto */
body:has(.chatbot-ia-window.open) .rc-anchor,
body:has(.chatbot-ia-window.open) iframe[src*="recaptcha"],
body:has(.chatbot-ia-window.open) .grecaptcha-badge {
    visibility: hidden !important;
}
:root {
    --chatbot-primary: #1e73be;
    --chatbot-secondary: #f5f5f5;
    --chatbot-bg: #ffffff;
    --chatbot-text: #333333;
    --chatbot-header-text: #ffffff;
    --chatbot-light: #f5f5f5;
    --chatbot-border: #e0e0e0;
}
/* Bloquear scroll del body cuando el chatbot está abierto */
body:has(.chatbot-ia-window.open) {
    overflow: hidden !important;
}
/* Contener el formulario dentro del chat */
.chatbot-ia-messages {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.chatbot-ia-ticket-form {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chatbot-ia-message-content {
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Asegurar que los inputs no se salgan */
.chatbot-ia-ticket-form input,
.chatbot-ia-ticket-form select,
.chatbot-ia-ticket-form textarea {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chatbot-ia-form-row {
    flex-wrap: wrap !important;
}
/* Toggle Button */
.chatbot-ia-toggle {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white !important;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 99998;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.chatbot-ia-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0,0,0,0.25);
}

.chatbot-ia-toggle.open {
    transform: rotate(90deg);
}

.chatbot-ia-toggle svg {
    width: 28px;
    height: 28px;
    fill: var(--chatbot-header-text);
}

/* Chat Window */
.chatbot-ia-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.16);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.chatbot-ia-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-ia-header {
    background: var(--chatbot-primary);
    color: var(--chatbot-header-text);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-ia-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-ia-avatar svg {
    width: 24px;
    height: 24px;
    fill: var(--chatbot-header-text);
}

.chatbot-ia-header-info {
    flex: 1;
}

.chatbot-ia-header-title {
    font-weight: 600;
    font-size: 15px;
    margin: 0;
    color: var(--chatbot-header-text);
}

.chatbot-ia-header-status {
    font-size: 12px;
    opacity: 0.8;
    color: var(--chatbot-header-text);
}

.chatbot-ia-close {
    background: none;
    border: none;
    color: var(--chatbot-header-text);
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-ia-close:hover {
    opacity: 1;
}

.chatbot-ia-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Reset Button */
.chatbot-ia-reset {
    background: none;
    border: none;
    color: var(--chatbot-header-text);
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-ia-reset:hover {
    opacity: 1;
}

.chatbot-ia-reset svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Messages Container */
.chatbot-ia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chatbot-bg);
}

.chatbot-ia-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-ia-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-ia-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Messages */
.chatbot-ia-message {
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

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

.chatbot-ia-message-bot {
    align-self: flex-start;
}

.chatbot-ia-message-user {
    align-self: flex-end;
}

.chatbot-ia-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.chatbot-ia-message-bot .chatbot-ia-message-content {
    background: var(--chatbot-secondary);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
}

.chatbot-ia-message-user .chatbot-ia-message-content {
    background: var(--chatbot-primary);
    color: var(--chatbot-header-text);
    border-bottom-right-radius: 4px;
}

.chatbot-ia-message-content a {
    color: inherit;
    text-decoration: underline;
}

/* Typing Indicator */
.chatbot-ia-typing .chatbot-ia-message-content {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions (fuera del mensaje) */
.chatbot-ia-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px 0;
}

.chatbot-ia-quick-btn {
    background: #fff;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-ia-quick-btn:hover {
    background: var(--chatbot-primary);
    color: var(--chatbot-header-text);
    border-color: var(--chatbot-primary);
}

/* Welcome Question */
.chatbot-ia-welcome-question {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-weight: 600;
    font-size: 13px;
}

/* Quick Actions Inline (dentro del mensaje) */
.chatbot-ia-quick-actions-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-ia-quick-btn-inline {
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--chatbot-text);
}

.chatbot-ia-quick-btn-inline:hover {
    background: var(--chatbot-primary);
    color: var(--chatbot-header-text);
    border-color: var(--chatbot-primary);
}

/* Input Area */
.chatbot-ia-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--chatbot-bg);
}

.chatbot-ia-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
}

.chatbot-ia-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.1);
}

.chatbot-ia-input::placeholder {
    color: var(--chatbot-text);
    opacity: 0.5;
}

.chatbot-ia-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.chatbot-ia-send:hover {
    transform: scale(1.05);
}

.chatbot-ia-send svg {
    width: 20px;
    height: 20px;
    fill: var(--chatbot-header-text);
}

/* Lead Form */
.chatbot-ia-lead-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 5px;
}

.chatbot-ia-lead-form input,
.chatbot-ia-lead-form textarea {
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-ia-lead-form input:focus,
.chatbot-ia-lead-form textarea:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-ia-lead-submit {
    background: var(--chatbot-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-ia-lead-submit:hover {
    background: #1557a0;
}

.chatbot-ia-lead-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-ia-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .chatbot-ia-toggle.open {
        display: none;
    }
}

/* ========================================
   CHAT EN VIVO
   ======================================== */

/* Barra de estado de chat en vivo */
.chatbot-ia-live-status {
    padding: 8px 16px;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.chatbot-ia-live-status.waiting {
    background: #fef3e2;
    color: #f39c12;
}

.chatbot-ia-live-status.active {
    background: #e8f8f0;
    color: #27ae60;
}

/* Botón de agente en quick actions */
.chatbot-ia-request-agent {
    background: #e8f4fc !important;
    border-color: var(--chatbot-primary) !important;
    color: var(--chatbot-primary) !important;
}

.chatbot-ia-request-agent:hover {
    background: var(--chatbot-primary) !important;
    color: #fff !important;
}

/* Formulario de nombre */
.chatbot-ia-name-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-ia-name-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

.chatbot-ia-name-input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-ia-name-submit {
    background: var(--chatbot-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-ia-name-submit:hover {
    background: #1557a0;
}

/* Mensaje del sistema */
.chatbot-ia-message-system {
    align-self: center;
    max-width: 90%;
}

.chatbot-ia-system-message {
    background: #f0f0f0 !important;
    color: #666 !important;
    font-size: 12px !important;
    text-align: center;
    padding: 8px 14px !important;
    border-radius: 12px !important;
}

/* ========================================
   FORMULARIO DE TICKET ISPGESTIÓN
   ======================================== */

.chatbot-ia-ticket-intro {
    margin-bottom: 12px;
}

.chatbot-ia-ticket-intro strong {
    display: block;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--chatbot-text);
}

.chatbot-ia-ticket-intro p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.chatbot-ia-ticket-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-ia-form-row {
    display: flex;
    gap: 8px;
}

.chatbot-ia-form-row input {
    flex: 1;
}

.chatbot-ia-input-small {
    flex: 0 0 90px !important;
    max-width: 90px;
}

.chatbot-ia-input-wide {
    flex: 1 !important;
}

.chatbot-ia-ticket-form input,
.chatbot-ia-ticket-form textarea,
.chatbot-ia-ticket-form select {
    padding: 10px 12px;
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.chatbot-ia-ticket-form input:focus,
.chatbot-ia-ticket-form textarea:focus,
.chatbot-ia-ticket-form select:focus {
    outline: none;
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.1);
}

.chatbot-ia-ticket-form select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

.chatbot-ia-ticket-form textarea {
    resize: vertical;
    min-height: 50px;
}

.chatbot-ia-ticket-form button[type="submit"] {
    background: var(--chatbot-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.chatbot-ia-ticket-form button[type="submit"]:hover {
    background: #1557a0;
    transform: translateY(-1px);
}

.chatbot-ia-ticket-form button[type="submit"]:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.chatbot-ia-ticket-cancel {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-ia-ticket-cancel:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

/* Select de localidades */
.chatbot-ia-localidad-select {
    flex: 1 !important;
    min-width: 0;
}

.chatbot-ia-localidad-select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.chatbot-ia-localidad-select option {
    padding: 8px;
}