/* ==========================================================================
   AI Assistant Chat Widget Styles
   ========================================================================== */

.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.ai-fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-premium);
}

.ai-widget-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-widget-container.closed {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

.ai-chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-assistant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: white;
}

.ai-assistant-info h4 {
    font-size: 1rem;
    margin: 0 0 2px 0;
    font-weight: 600;
}

.ai-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #4CAF50;
    border-radius: 50%;
}

.ai-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 5px;
}

.ai-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.ai-chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-in-out;
}

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

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

.message p {
    margin: 0;
}

.message p+p {
    margin-top: 0.5rem;
}

.bot-message {
    background: var(--white);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.bot-message ul,
.bot-message ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.bot-message li {
    margin-bottom: 0.25rem;
}

.user-message {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: var(--shadow-sm);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
    width: max-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #9CA3AF;
    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-input-area {
    padding: 1rem;
    background: var(--white);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

#ai-chat-input {
    flex: 1;
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #F9FAFB;
    min-width: 350px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#ai-chat-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ai-chat-input:focus {
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(214, 40, 40, 0.1);
}

.ai-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.ai-send-btn:hover {
    background-color: #b01f1f;
}

.ai-send-btn:disabled {
    background-color: #E5E7EB;
    color: #9CA3AF;
    cursor: not-allowed;
}

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

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

.ai-chat-messages::-webkit-scrollbar-track,
#ai-chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb,
#ai-chat-input::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover,
#ai-chat-input::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

@media (max-width: 480px) {
    .ai-widget-container {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 90px;
        height: 80vh;
    }

    .ai-fab {
        right: 16px;
        bottom: 16px;
        width: 55px;
        height: 55px;
    }
}