/* =========================================
   AI Chat Widget Styles
   ========================================= */

/* Main Container */
.chat-widget-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: 'Outfit', sans-serif;
}

/* Floating Action Button */
.chat-widget-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-primary);
    /* Uses main site green */
    color: var(--color-bg-card);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 255, 157, 0.4);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.chat-widget-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: 0.5s;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 255, 157, 0.6);
}

.chat-widget-btn:hover::before {
    left: 100%;
}

.chat-widget-btn i {
    transition: transform 0.3s ease;
}

.chat-widget-btn:hover i {
    transform: scale(1.2);
}

/* Pulse Animation for Button */
@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 15px rgba(0, 255, 157, 0);
    }

    100% {
        transform: scale(0.8);
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0);
    }
}

.chat-widget-btn {
    animation: pulse-ring 3s infinite;
}

/* Chat Window */
.chat-widget-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 4rem);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-widget-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--color-bg-card) 0%, #2a2a2a 100%);
    color: var(--color-white);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--color-primary);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-primary);
}

.chat-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    color: #a0a0a0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--color-primary);
    border-radius: 50%;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    padding: 0;
}

.chat-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #f9f9f9;
}

/* Scrollbar for messages */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

/* AI Message */
.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #eeeeee;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.ai-message .message-content a {
    color: var(--color-bg-card, #151d2f);
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.2s;
}

.ai-message .message-content a:hover {
    color: var(--color-primary-dark, #ccac00);
}

/* User Message */
.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background-color: var(--color-bg-card);
    color: var(--color-primary);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Typing Indicator Overlay */
.typing-indicator {
    align-self: flex-start;
    background-color: #ffffff;
    border: 1px solid #eeeeee;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: none;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #888;
    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);
        background-color: var(--color-primary);
    }
}

/* Input Area */
.chat-input-area {
    padding: 1rem;
    background: #ffffff;
    border-top: 1px solid #eeeeee;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #dddddd;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

#chat-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 255, 157, 0.2);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: var(--color-dark);
    color: var(--color-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
}

.chat-send-btn:hover {
    background-color: #1a1a1a;
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn i {
    font-size: 1.1rem;
}

/* Footer */
.chat-footer {
    text-align: center;
    font-size: 0.7rem;
    color: #bbbbbb;
    padding-bottom: 0.5rem;
    background: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 1rem;
        right: 1rem;
    }

    .chat-widget-window {
        width: calc(100vw - 2rem);
        right: 0;
        bottom: 70px;
    }
}