/* AI Chat Widget Styles */

.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.ai-chat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--bs-primary, #3b82f6);
    color: #ffffff;
    border: none;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
    font-size: 24px;
    cursor: pointer;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.ai-chat-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 35px rgba(37, 99, 235, 0.6);
    /* Mejor contraste */
}

.ai-chat-btn.idle-pulse {
    animation: gentle-attention 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
}

@keyframes gentle-attention {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
    }

    50% {
        transform: scale(1.08) translateY(-4px);
        box-shadow: 0 15px 35px rgba(59, 130, 246, 0.8);
    }
}

.ai-chat-btn.task-overdue {
    background-color: #f59e0b !important;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.8) !important;
}

.ai-chat-btn.task-overdue-shake {
    animation: shakeWarningChat 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite !important;
}

@keyframes shakeWarningChat {

    10%,
    90% {
        transform: scale(1.1) translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: scale(1.1) translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: scale(1.1) translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: scale(1.1) translate3d(4px, 0, 0);
    }
}

.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
}

.ai-chat-window.d-none {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    display: flex !important;
    /* overriden by opacity/transform for animation */
}

/* Dark mode support */
body[data-bs-theme="dark"] .ai-chat-window {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
}

.ai-chat-header {
    padding: 16px 20px;
    background-color: var(--bs-primary, #3b82f6);
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.ai-chat-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-action-btn:hover {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.15);
}

.ai-chat-action-btn:active {
    background: rgba(0, 0, 0, 0.25);
}

.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--bg-body, #f8fafc);
}

body[data-bs-theme="dark"] .ai-chat-body {
    background: #0f172a;
}

.ai-message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.ai-message .msg-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-msg .msg-content {
    background-color: var(--bs-primary, #3b82f6);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.assistant-msg .msg-content {
    background: white;
    color: #1e293b;
    /* Mejorado desde #334155 para mejor contraste */
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

body[data-bs-theme="dark"] .assistant-msg .msg-content {
    background: #1e293b;
    color: #ffffff;
    /* Mejorado desde #f8fafc para contraste puro */
    border-color: rgba(255, 255, 255, 0.05);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-top-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

body[data-bs-theme="dark"] .typing-indicator {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.05);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #475569;
    /* Mejorado desde #94a3b8 para más contraste */
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.ai-chat-footer {
    padding: 15px;
    background: var(--bg-card, white);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body[data-bs-theme="dark"] .ai-chat-footer {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

.ai-chat-footer input {
    border-radius: 20px 0 0 20px;
    padding-left: 15px;
}

.ai-chat-footer input::placeholder {
    color: #475569;
    /* WCAG AA Contrast against white: 5.4:1 */
}

body[data-bs-theme="dark"] .ai-chat-footer input {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.2);
    /* Contrast */
    color: #f8fafc;
}

body[data-bs-theme="dark"] .ai-chat-footer input::placeholder {
    color: #94a3b8;
    /* WCAG AA Contrast against #0f172a: 4.6:1 */
}

.ai-chat-footer button {
    border-radius: 0 20px 20px 0;
    padding-right: 15px;
}

/* Responsive */
@media (max-width: 576px) {
    .ai-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }
}