/* =================================================================
   AI CHAT OVERLAY - Terminal Style
   Based on Figma: 18px IBM Plex Mono, 60px padding, 24px icon-text gap
   ================================================================= */

/* Prevent body scroll when chat is active */
body.ai-chat-active {
    overflow: hidden;
}

/* Main overlay container */
.ai-chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #111;

    display: flex;
    flex-direction: column;

    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-chat-overlay.active {
    pointer-events: auto;
    opacity: 1;
}

/* Close Button */
.ai-chat__close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: #111;
    /* Matches overlay background */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s, transform 0.2s, opacity 0.2s;
    z-index: 10;
}

.ai-chat__close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ai-chat__close-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

/* Response area - scrollable, fills available space */
.ai-chat__response-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px;

    display: flex;
    flex-direction: column;
    gap: 34px;
}

/* Push content to bottom when short, allow scroll when long */
.ai-chat__response-area::before {
    content: '';
    flex: 1;
}

/* Terminal-style scrollbar */
.ai-chat__response-area::-webkit-scrollbar {
    width: 8px;
}

.ai-chat__response-area::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat__response-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.ai-chat__response-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Terminal-style conversation lines */
.ai-chat__line {
    display: flex;
    gap: 16px;
    align-items: flex-start;

    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 400;
    color: white;
}

/* Prompt symbol */
.ai-chat__line .ai-chat__prompt {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    color: white;
}

/* Assistant prompt color */
.ai-chat__line--assistant .ai-chat__prompt {
    color: rgba(255, 255, 255, 0.8);
}

/* Avatar wrapper */
.ai-chat__avatar-wrap {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat__avatar {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    vertical-align: middle;
}


/* Message content - fills remaining space */
.ai-chat__content {
    flex: 1;
    min-width: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Links */
.ai-chat__line a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.ai-chat__line a:hover {
    opacity: 0.7;
}

/* Media blocks in response */
.ai-chat__media-block {
    display: block;
    margin-top: 16px;
    margin-bottom: 8px;
    max-width: 100%;
}

.ai-chat__media-block img,
.ai-chat__media-block video {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    background-color: rgba(128, 128, 128, 0.2);
}

/* Loading indicator - aligned with text (after icon + gap) */
.ai-chat__loading {
    margin-left: 48px;
    /* 24px icon + 24px gap */
}

.ai-chat__thinking {
    height: 80px;
    width: auto;
    border-radius: 8px;
}

/* Input bar - fixed at bottom */
.ai-chat__input-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0 40px 90px 40px;
    /* 40px (link bottom) + 24px (link height) + 24px (gap) ≈ 88px -> 90px safe */
    padding: 20px 0 20px 0;

    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);

    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    line-height: 1.4;
    color: white;
}

/* Prompt symbol in input bar */
.ai-chat__input-bar .ai-chat__prompt {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    color: white;
}

/* Input field */
.ai-chat__input {
    flex: 1;
    min-width: 0;

    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 400;
    color: white;

    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    caret-color: white;
}

.ai-chat__input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Footer with link and hint */
.ai-chat__footer {
    position: absolute;
    bottom: 40px;
    left: 40px;
    right: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.ai-chat__context-link {
    pointer-events: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    transition: color 0.2s;
}

.ai-chat__hint {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.2);
}

.ai-chat__context-link:hover {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: underline;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .ai-chat__response-area {
        padding: 24px;
        gap: 24px;
    }

    .ai-chat__line {
        font-size: 16px;
        gap: 16px;
    }

    /* .ai-chat__close-btn uses default 12px/12px from desktop */

    .ai-chat__avatar-wrap,
    .ai-chat__line--user .ai-chat__prompt {
        width: 20px;
    }

    .ai-chat__avatar {
        width: 20px;
        height: 20px;
    }

    .ai-chat__input-bar {
        margin: 0 20px 80px 20px;
        padding: 20px 0 20px 0;
        gap: 16px;
        font-size: 16px;
    }

    .ai-chat__input {
        font-size: 16px;
    }

    .ai-chat__thinking {
        height: 50px;
    }

    .ai-chat__media-block img,
    .ai-chat__media-block video {
        max-height: 250px;
    }

    .ai-chat__footer {
        left: 20px;
        right: 20px;
        bottom: 30px;
    }

    .ai-chat__context-link {
        font-size: 16px;
    }

    .ai-chat__hint {
        display: none;
    }

    ```