/* ==========================================================
   CCDSITEL — WIDGET DE CHAT ASESOR IA (SALES & TECH BOT)
   ========================================================== */

/* Posicionamiento del botón de WhatsApp para convivir con el Asesor IA */
.whatsapp-float {
    bottom: 96px !important;
    right: 25px !important;
    z-index: 9998 !important;
}

@media (max-width: 600px) {
    .whatsapp-float {
        bottom: 85px !important;
        right: 18px !important;
        width: 48px !important;
        height: 48px !important;
    }
}

/* Botón Lanzador del Asesor IA */
#ccdsitel-ai-launcher {
    position: fixed;
    bottom: 24px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f2b48 0%, #081426 100%);
    border: 2px solid #00d2ff;
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.4), 0 0 12px rgba(0, 210, 255, 0.2);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
    user-select: none;
}

#ccdsitel-ai-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 210, 255, 0.6), 0 0 20px rgba(0, 210, 255, 0.4);
}

#ccdsitel-ai-launcher svg {
    width: 32px;
    height: 32px;
    fill: #00d2ff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    transition: transform 0.3s ease;
}

#ccdsitel-ai-launcher:hover svg {
    transform: rotate(5deg) scale(1.05);
}

/* Indicador de estado en vivo (punto verde pulsante) */
.ai-status-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #081426;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.ai-status-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #10b981;
    animation: aiPulse 2s infinite ease-out;
}

@keyframes aiPulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Tooltip / Badge de bienvenida flotante */
.ai-launcher-tooltip {
    position: absolute;
    right: 72px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(11, 21, 38, 0.95);
    color: #e2e8f0;
    border: 1px solid rgba(0, 210, 255, 0.3);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%) translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-launcher-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent rgba(11, 21, 38, 0.95);
}

.ai-launcher-tooltip.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Ventana de Chat */
#ccdsitel-ai-chat-window {
    position: fixed;
    bottom: 96px;
    right: 25px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 120px);
    background: linear-gradient(180deg, #0b1526 0%, #070d17 100%);
    border: 1px solid rgba(0, 210, 255, 0.25);
    border-radius: 18px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 210, 255, 0.12);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    animation: chatSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#ccdsitel-ai-chat-window.open {
    display: flex;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Encabezado del Chat */
.ai-chat-header {
    background: rgba(15, 27, 49, 0.95);
    border-bottom: 1px solid rgba(0, 210, 255, 0.15);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00d2ff 0%, #0077b6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #04101e;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.3);
}

.ai-chat-title-wrap h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.ai-chat-title-wrap .ai-chat-subtitle {
    margin: 0;
    font-size: 11px;
    color: #00d2ff;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-subtitle-dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #10b981;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ai-header-btn:hover {
    background: rgba(0, 210, 255, 0.15);
    color: #00d2ff;
    border-color: rgba(0, 210, 255, 0.3);
}

.ai-header-btn.btn-wa-header:hover {
    background: rgba(37, 211, 102, 0.2);
    color: #25d366;
    border-color: rgba(37, 211, 102, 0.4);
}

/* Píldoras de atajos rápidos */
.ai-chat-chips {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(8, 17, 30, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.ai-chat-chips::-webkit-scrollbar {
    display: none;
}

.ai-chip {
    background: rgba(16, 32, 57, 0.8);
    border: 1px solid rgba(0, 210, 255, 0.2);
    color: #94a3b8;
    padding: 5px 11px;
    border-radius: 14px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chip:hover {
    background: rgba(0, 210, 255, 0.15);
    color: #ffffff;
    border-color: #00d2ff;
    transform: translateY(-1px);
}

/* Contenedor de Mensajes */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 210, 255, 0.2) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 210, 255, 0.2);
    border-radius: 4px;
}

/* Burbujas de chat */
.ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: msgIn 0.2s ease-out;
}

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

.ai-msg-bot {
    align-self: flex-start;
}

.ai-msg-user {
    align-self: flex-end;
}

.ai-msg-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
}

.ai-msg-bot .ai-msg-bubble {
    background: #0f1f33;
    border: 1px solid rgba(0, 210, 255, 0.18);
    color: #e2e8f0;
    border-bottom-left-radius: 3px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ai-msg-bot .ai-msg-bubble strong,
.ai-msg-bot .ai-msg-bubble b {
    color: #ffffff;
    font-weight: 700;
}

.ai-msg-bot .ai-msg-bubble ul {
    margin: 6px 0;
    padding-left: 18px;
}

.ai-msg-bot .ai-msg-bubble li {
    margin-bottom: 4px;
}

.ai-msg-user .ai-msg-bubble {
    background: linear-gradient(135deg, #0077b6 0%, #0096c7 100%);
    color: #ffffff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 4px 12px rgba(0, 119, 182, 0.35);
}

.ai-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 3px;
    padding: 0 4px;
}

.ai-msg-user .ai-msg-time {
    align-self: flex-end;
}

/* Indicador de escritura (Thinking) */
.ai-typing-indicator {
    display: none;
    align-self: flex-start;
    background: #0f1f33;
    border: 1px solid rgba(0, 210, 255, 0.18);
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    padding: 10px 14px;
    gap: 5px;
    align-items: center;
}

.ai-typing-indicator.show {
    display: flex;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #00d2ff;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

.ai-typing-text {
    font-size: 11px;
    color: #94a3b8;
    margin-left: 6px;
}

/* Área de Entrada de Mensaje */
.ai-chat-input-wrap {
    background: rgba(11, 21, 38, 0.95);
    border-top: 1px solid rgba(0, 210, 255, 0.15);
    padding: 10px 12px;
}

.ai-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-input {
    flex: 1;
    background: #070e1a;
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    border-color: #00d2ff;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.ai-chat-input::placeholder {
    color: #64748b;
}

.ai-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00d2ff 0%, #0077b6 100%);
    border: none;
    color: #04101e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.2s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}

.ai-chat-send-btn:active {
    transform: scale(0.95);
}

.ai-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #04101e;
}

/* Pie de chat / WhatsApp link */
.ai-chat-footer-note {
    text-align: center;
    margin-top: 7px;
    font-size: 11px;
    color: #64748b;
}

.ai-chat-footer-note a {
    color: #25d366;
    text-decoration: none;
    font-weight: 600;
}

.ai-chat-footer-note a:hover {
    text-decoration: underline;
}

/* Modal en Móvil */
@media (max-width: 480px) {
    #ccdsitel-ai-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}
