/* Widget Assistant CASSATECH Copilot */
#cassatech-ai-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1060;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35), 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#cassatech-ai-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45), 0 4px 10px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #1d4ed8, #6d28d9);
}

#cassatech-ai-btn .ai-badge {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#cassatech-ai-btn .ai-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #34d399;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.3);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* Boîte de dialogue flottante */
#cassatech-ai-window {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 440px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1060;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

#cassatech-ai-window.ai-hidden {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    visibility: hidden;
    pointer-events: none;
}

/* En-tête de la fenêtre */
.ai-header {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.ai-header-title .ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

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

.ai-header-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* Corps des messages */
.ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Bulles de messages */
.ai-msg {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: fadeInMsg 0.2s ease-out;
}

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

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

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

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

.ai-msg-user .ai-msg-bubble {
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ai-msg-bot .ai-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-msg-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.8rem;
}

.ai-msg-bubble table th,
.ai-msg-bubble table td {
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
}

.ai-msg-bubble table th {
    background: #f1f5f9;
    font-weight: 600;
}

.ai-msg-bubble a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: underline;
}

.ai-msg-bubble pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    overflow-x: auto;
}

.ai-msg-bubble code {
    background: #e2e8f0;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: #0f172a;
}

.ai-msg-bubble pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Suggestions rapides (chips) */
.ai-suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.ai-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.78rem;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-chip:hover {
    background: #f1f5f9;
    border-color: #2563eb;
    color: #2563eb;
}

/* Zone de frappe (typing indicator) */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    width: fit-content;
}

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

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Pied / Saisie */
.ai-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.ai-input-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 6px 12px;
    transition: border-color 0.2s;
}

.ai-input-group:focus-within {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ai-textarea {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    max-height: 90px;
    font-size: 0.88rem;
    line-height: 1.4;
    padding: 4px 0;
    color: #1e293b;
}

.ai-send-btn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* Mode print */
@media print {
    #cassatech-ai-btn, #cassatech-ai-window {
        display: none !important;
    }
}
