/* ============================================================
   Crecer Digital — AI Chatbot & FAQ Assistant
   Estilos Cinemáticos con Glassmorphism, Neon Glow y Responsive
   ============================================================ */

/* Botón flotante de activación */
.ai-chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0057FF 0%, #00E5FF 50%, #FF7A00 100%);
    background-size: 200% 200%;
    animation: gradientShift 6s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 87, 255, 0.45), 0 0 20px rgba(0, 229, 255, 0.3);
    cursor: pointer;
    z-index: 9998;
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.ai-chat-toggle:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 87, 255, 0.6), 0 0 30px rgba(0, 229, 255, 0.5);
}

.ai-toggle-logo-img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-chat-toggle:hover .ai-toggle-logo-img {
    transform: scale(1.1) rotate(6deg);
}

/* Indicador de pulso activo */
.ai-toggle-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #00D084;
    border: 2px solid #050A1A;
    border-radius: 50%;
    box-shadow: 0 0 10px #00D084;
}

/* Tooltip emergente */
.ai-toggle-badge {
    position: absolute;
    right: 74px;
    background: rgba(13, 27, 62, 0.95);
    color: #FFFFFF;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-chat-toggle:hover .ai-toggle-badge {
    opacity: 1;
    transform: translateX(0);
}

/* Contenedor principal de la ventana de chat */
.ai-chat-window {
    position: fixed;
    bottom: 98px;
    right: 28px;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100dvh - 120px);
    background: rgba(5, 10, 26, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 87, 255, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header del chat */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(90deg, rgba(0, 87, 255, 0.25), rgba(0, 229, 255, 0.15));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-chat-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.ai-chat-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.ai-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #00D084;
    border-radius: 50%;
    border: 2px solid #050A1A;
    box-shadow: 0 0 8px #00D084;
}

.ai-chat-titles h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #FFFFFF;
    font-family: var(--font-display);
    letter-spacing: 0.5px;
}

.ai-chat-titles p {
    margin: 0;
    font-size: 0.72rem;
    color: var(--color-accent);
}

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

.ai-control-btn {
    background: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.ai-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
}

/* Área de mensajes */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

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

.ai-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

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

/* Burbujas de mensaje */
.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: fadeInMsg 0.3s ease;
}

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

.ai-message--bot {
    align-self: flex-start;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 90%;
}

.ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.ai-bot-msg-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
    border: 1px solid rgba(0, 229, 255, 0.25);
}

.ai-msg-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ai-message--user {
    align-self: flex-end;
    max-width: 85%;
}

.ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.ai-message--bot .ai-msg-bubble {
    background: rgba(13, 27, 62, 0.85);
    color: #E2E8F0;
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.ai-message--user .ai-msg-bubble {
    background: linear-gradient(135deg, #0057FF, #00BFFF);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 87, 255, 0.35);
}

.ai-msg-time {
    font-size: 0.68rem;
    color: var(--color-muted);
    margin-top: 4px;
    align-self: flex-end;
}

/* Quick FAQs Chips */
.ai-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ai-chip {
    background: rgba(0, 87, 255, 0.15);
    color: var(--color-accent);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-chip:hover {
    background: rgba(0, 229, 255, 0.25);
    color: #FFFFFF;
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.ai-chip--img {
    background: rgba(255, 107, 0, 0.18);
    color: #FF9500;
    border-color: rgba(255, 107, 0, 0.4);
}

.ai-chip--img:hover {
    background: rgba(255, 107, 0, 0.35);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.4);
}

/* Tarjeta de imagen generada */
.ai-generated-image-card {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(5, 10, 26, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.ai-generated-image-preview {
    width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.ai-generated-image-preview:hover {
    transform: scale(1.02);
}

.ai-image-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(13, 27, 62, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-image-prompt-text {
    font-size: 0.72rem;
    color: var(--color-muted);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.ai-img-btn {
    background: rgba(0, 229, 255, 0.15);
    color: var(--color-accent);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-img-btn:hover {
    background: var(--color-accent);
    color: #050A1A;
    font-weight: 600;
}

/* Indicador de escritura / generación */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: rgba(13, 27, 62, 0.85);
    border-radius: 16px;
    width: fit-content;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.ai-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.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.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Barra de Entrada */
.ai-chat-input-bar {
    padding: 12px 14px;
    background: rgba(13, 27, 62, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-input-btn-mode {
    background: rgba(255, 107, 0, 0.18);
    border: 1px solid rgba(255, 107, 0, 0.4);
    color: #FF9500;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-input-btn-mode:hover, .ai-input-btn-mode.active {
    background: #FF6B00;
    color: #FFFFFF;
    box-shadow: 0 0 12px rgba(255, 107, 0, 0.5);
}

.ai-chat-input {
    flex: 1;
    background: rgba(5, 10, 26, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.25);
    color: #FFFFFF;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.ai-chat-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.ai-chat-send {
    background: linear-gradient(135deg, #0057FF, #00E5FF);
    border: none;
    color: #FFFFFF;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    transform: scale(1.06);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}

.ai-chat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Botón contextual de WhatsApp dentro del chat */
.ai-chat-wa-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 14px;
    background: #25D366;
    color: #FFFFFF;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-wa-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
    color: #FFFFFF;
}

/* Ajustes Responsivos */
@media (max-width: 768px) {
    .ai-chat-toggle {
        bottom: 20px;
        right: 18px;
        width: 54px;
        height: 54px;
    }

    .ai-chat-window {
        bottom: 84px;
        right: 12px;
        left: 12px;
        width: calc(100vw - 24px);
        height: 75dvh;
    }
}

/* ============================================================
   ARGUS: TARJETA DE EXPEDIENTE / BRIEFING DE COTIZACIÓN
   ============================================================ */
.ai-dossier-card {
    background: rgba(0, 87, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 14px;
    padding: 14px;
    margin-top: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 229, 255, 0.06);
}

.ai-dossier-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-dossier-title {
    font-family: var(--font-display, 'Montserrat', sans-serif);
    font-size: 0.85rem;
    font-weight: 800;
    color: #00E5FF;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0;
}

.ai-dossier-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    color: #CBD5E1;
}

.ai-dossier-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.ai-dossier-label {
    color: #94A3B8;
    font-weight: 600;
    flex-shrink: 0;
}

.ai-dossier-value {
    color: #FFFFFF;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.ai-dossier-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* Botón Google Calendar */
.ai-calendar-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #1A73E8, #4285F4);
    color: #FFFFFF;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(26, 115, 232, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-calendar-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(26, 115, 232, 0.55);
    color: #FFFFFF;
}

/* Modal de Configuración Google App Key */
.ai-config-modal {
    position: absolute;
    top: 60px;
    left: 12px;
    right: 12px;
    background: rgba(5, 10, 26, 0.98);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(0, 229, 255, 0.4);
    border-radius: 16px;
    padding: 18px;
    z-index: 10005;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 87, 255, 0.3);
    animation: fadeInModal 0.25s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-config-modal h4 {
    margin: 0 0 6px 0;
    color: #00E5FF;
    font-size: 0.9rem;
    font-weight: 800;
    font-family: var(--font-display, 'Montserrat', sans-serif);
}

.ai-config-modal p {
    font-size: 0.76rem;
    color: #94A3B8;
    margin-bottom: 12px;
    line-height: 1.4;
}

.ai-config-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #FFFFFF;
    font-size: 0.8rem;
    margin-bottom: 10px;
    outline: none;
    box-sizing: border-box;
}

.ai-config-input:focus {
    border-color: #00E5FF;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.ai-config-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ai-config-btn-save {
    padding: 6px 14px;
    background: #00E5FF;
    color: #050A1A;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
}

.ai-config-btn-close {
    padding: 6px 12px;
    background: transparent;
    color: #94A3B8;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 0.78rem;
    cursor: pointer;
}
