/**
 * Estilos del Widget de Chat WooContex.
 *
 * Diseño Premium, Mobile First, Glassmorphism, Micro-animaciones, Variables CSS.
 */

:root {
    --woocontex-primary: #6c5ce7;
    --woocontex-bg: #1e1e2e;
    --woocontex-text: #ffffff;
    --woocontex-font: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Burbuja Flotante del Chat */
#woocontex-chat-trigger {
    position: fixed;
    bottom: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--woocontex-primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    font-size: 28px;
    border: none;
    outline: none;
}

#woocontex-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Posicionamiento dinámico */
.woocontex-pos-right {
    right: 25px;
}
.woocontex-pos-left {
    left: 25px;
}

/* Contenedor del Chatbox */
#woocontex-chat-container {
    position: fixed;
    bottom: 95px;
    width: 380px;
    height: 580px;
    border-radius: 16px;
    background-color: var(--woocontex-bg);
    color: var(--woocontex-text);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 999999;
    overflow: hidden;
    font-family: var(--woocontex-font);
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#woocontex-chat-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Cabecera Premium (Glassmorphism) */
.woocontex-chat-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.woocontex-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.woocontex-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.woocontex-agent-details h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.woocontex-agent-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
}

.woocontex-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10ac84;
    box-shadow: 0 0 8px #10ac84;
}

.woocontex-close-btn {
    background: transparent;
    border: none;
    color: var(--woocontex-text);
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.woocontex-close-btn:hover {
    opacity: 1;
}

/* Cuerpo de Mensajes */
.woocontex-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Estilos de Burbujas */
.woocontex-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: woocontex-fade-in 0.25s ease forwards;
}

.woocontex-msg-user {
    background-color: var(--woocontex-primary);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.woocontex-msg-bot {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--woocontex-text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.woocontex-msg-bot a {
    color: #00cec9;
    text-decoration: underline;
    font-weight: 500;
}

.woocontex-msg-bot a:hover {
    color: #81ecec;
}

/* Indicador de Carga (Loading Spinner) */
.woocontex-loading-bubble {
    align-self: flex-start;
    display: flex;
    gap: 6px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    border-bottom-left-radius: 2px;
}

.woocontex-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--woocontex-text);
    opacity: 0.4;
    animation: woocontex-bounce 1.4s infinite ease-in-out both;
}

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

/* Barra de Entrada de Datos */
.woocontex-chat-input-bar {
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.woocontex-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.woocontex-chat-input-bar textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 14px 28px 14px; /* Mayor padding abajo para dejar espacio al contador */
    color: #ffffff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    height: 60px; /* Espacio visual ampliado para lectura cómoda */
    font-family: var(--woocontex-font);
    line-height: 1.4;
    box-sizing: border-box;
}

.woocontex-chat-input-bar textarea:focus {
    border-color: var(--woocontex-primary);
}

/* Contador de caracteres dinámico flotante */
.woocontex-char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 10px;
    font-weight: 600;
    transition: color 0.25s ease;
    user-select: none;
    pointer-events: none;
}

.char-ok {
    color: #10ac84; /* Verde profesional */
}

.char-warn {
    color: #ff9f43; /* Naranja advertencia */
}

.char-danger {
    color: #ff7675; /* Rojo peligro */
    animation: woocontex-shake 0.3s ease;
}

/* Animación de vibración leve */
@keyframes woocontex-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.woocontex-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--woocontex-primary);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s ease;
}

.woocontex-send-btn:hover {
    transform: scale(1.05);
}

/* Estilos de Formularios de Fallback */
.woocontex-fallback-form {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.woocontex-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.woocontex-form-group label {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.8;
}

.woocontex-form-group input, .woocontex-form-group textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    resize: none;
}

.woocontex-fallback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none !important;
    text-align: center;
    border: none;
    transition: background 0.2s ease;
}

.btn-submit {
    background-color: var(--woocontex-primary);
    color: #ffffff;
}

.btn-whatsapp {
    background-color: #10ac84;
    color: #ffffff;
    width: 100%;
}

.btn-telegram {
    background-color: #2e86de;
    color: #ffffff;
    width: 100%;
}

.woocontex-fallback-link-container {
    margin-top: 10px;
}

.woocontex-form-message {
    font-size: 12px;
    text-align: center;
    padding: 6px;
    border-radius: 4px;
}

.form-msg-success {
    background-color: rgba(16, 172, 132, 0.15);
    color: #10ac84;
}

.form-msg-error {
    background-color: rgba(238, 82, 83, 0.15);
    color: #ee5253;
}

/* Spinner animado */
.woocontex-loader-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: woocontex-spin 0.6s linear infinite;
    margin-left: 8px;
}

/* Animaciones */
@keyframes woocontex-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes woocontex-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes woocontex-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* DISEÑO RESPONSIVO (MOBILE FIRST) */
@media (max-width: 600px) {
    #woocontex-chat-container {
        width: 100% !important;
        height: 100% !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
    }
    
    #woocontex-chat-trigger {
        bottom: 15px !important;
        right: 15px !important;
    }
}
