
.chat-toggle-button {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.chat-toggle-button:hover {
    background-color: var(--primary-light);
    transform: scale(1.1);
}

.chat-window {
    position: fixed;
    bottom: 100px;
    right: 25px;
    width: 90%;
    max-width: 400px;
    height: 60vh;
    max-height: 600px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0s 0.3s;
}

.chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgba(30, 30, 30, 0.8);
    border-bottom: 1px solid var(--border-color);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.chat-close-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.chat-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user {
    background-color: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.ai {
    background-color: #333;
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.ai.loading span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}
.chat-message.ai.loading span:nth-child(1) { animation-delay: -0.32s; }
.chat-message.ai.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.chat-form {
    display: flex;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

#chat-input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-right: 0.5rem;
    transition: var(--transition);
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-submit-button {
    border: none;
    background-color: var(--primary);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.chat-submit-button:hover {
    background-color: var(--primary-light);
}

.chat-message.ai p:last-child {
    margin-bottom: 0; 
}

.chat-message.ai h1,
.chat-message.ai h2,
.chat-message.ai h3 {
    font-size: 1.1rem;
    color: var(--primary-light);
    margin-bottom: 0.5rem;
}

.chat-message.ai strong {
    color: var(--text-primary);
    font-weight: 600;
}

.chat-message.ai ul,
.chat-message.ai ol {
    padding-left: 20px;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

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

.chat-message.ai pre {
    background-color: transparent;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    white-space: pre-wrap; 
    word-wrap: break-word;
}
.chat-message.ai code {
    font-family: inherit;
    font-size: inherit;
    background: none;
}


@media (max-width: 480px) {
    .chat-window {
        right: 10px;
        bottom: 90px;
        width: calc(100% - 20px);
    }
}