/* ===================================
   AI Chatbot Styles
   =================================== */
.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-widget.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    background: var(--gradient-primary);
    color: white;
    padding: 1rem;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* NEW: Header actions toolbar */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    font-size: 0.875rem;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.chat-action-btn:active {
    transform: translateY(0);
}

.bot-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bot-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.bot-status {
    font-size: 0.75rem;
    opacity: 0.9;
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    align-items: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 260px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 0.9375rem;
}

.bot-message .message-bubble {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.user-message .message-bubble {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    transition: var(--transition-fast);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send {
    width: 45px;
    height: 45px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.quick-questions {
    padding: 0 1rem 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 0.5rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.quick-btn:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 1000;
    transition: var(--transition-base);
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(59, 130, 246, 0.6);
}

.chat-toggle.active {
    transform: rotate(360deg) scale(0.9);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ===================================
   Scroll Progress Bar
   =================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: var(--gradient-primary);
    z-index: 9999;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* ===================================
   Typing Cursor Animation
   =================================== */
.title-line.gradient-text::after {
    content: '|';
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ===================================
   NEW: Smart Suggestions
   =================================== */
.smart-suggestions {
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    animation: slideIn 0.3s ease;
}

.suggest-label {
    width: 100%;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.suggest-btn {
    padding: 0.5rem 0.875rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 20px;
    font-size: 0.8125rem;
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.suggest-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ===================================
   NEW: Rich Messages & Code Snippets
   =================================== */
.rich-message .message-bubble {
    max-width: 300px;
}

.rich-message pre {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.rich-message code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #d4d4d4;
    display: block;
    white-space: pre;
}

.rich-message a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.rich-message a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

/* Syntax highlighting for code */
.rich-message code::before {
    content: '# Python';
    display: block;
    color: #6a9fb5;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

/* ===================================
   Typing Indicator Enhancement
   =================================== */
.message-bubble.typing {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
}

.message-bubble.typing span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.message-bubble.typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.message-bubble.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ===================================
   Mobile Responsive & Fluidity
   =================================== */
@media (max-width: 768px) {
    .chat-widget {
        width: calc(100vw - 32px);
        height: min(600px, calc(100vh - 120px));
        bottom: 85px;
        right: 16px;
        border-radius: 16px;
    }

    /* On very small screens, make it feel more full-screen */
    @media (max-height: 600px) {
        .chat-widget {
            height: calc(100vh - 100px);
        }
    }

    .back-to-top {
        right: 16px;
        bottom: 85px;
        width: 45px;
        height: 45px;
    }

    .quick-questions {
        padding: 0 0.75rem 0.75rem;
        gap: 0.35rem;
    }

    .quick-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
}

/* Optimization: Smooth momentum scrolling for iOS */
.chat-messages {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Optimization: Prevent body scroll when chat is open on mobile */
body.chat-open {
    overflow: hidden;
}