/**
 * conversation-surface-shell.css — shared container-level layout for
 * conversation surfaces.
 *
 * Covers: chat area column, messages scroll region, composer row,
 * suggestion chips, send button states, context menu, find bar,
 * file-lookup popup, attachment tray, chat actions bar.
 *
 * Message bubble styles live in conversation-rendering.css.
 */

/* Chat action bar (above messages) */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.chat-actions.hidden { display: none; }
.chat-actions-right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Find Bar */
.find-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.find-bar.hidden {
    display: none;
}
.find-bar input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
}
.find-bar input:focus {
    border-color: var(--accent);
}
.find-count {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
    user-select: none;
}
.find-nav-btn {
    padding: 4px;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.find-nav-btn:hover {
    background: #f0f0f0;
    color: var(--accent);
}
.find-highlight {
    background-color: #fff3cd;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}
.find-highlight-active {
    background-color: #ffc107;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.4);
}

/* Send button icon states */
.send-btn-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.send-btn-icon svg {
    width: 18px;
    height: 18px;
}
.send-btn-icon .send-icon { display: block; }
.send-btn-icon .stop-icon { display: none; }
.send-btn-icon .spinner { display: none; }
/* Streaming state - show spinner with stop on hover */
#sendBtn.streaming .send-btn-icon .send-icon { display: none; }
#sendBtn.streaming .send-btn-icon .spinner { display: block; }
#sendBtn.streaming:hover .send-btn-icon .spinner { display: none; }
#sendBtn.streaming:hover .send-btn-icon .stop-icon { display: block; }
#sendBtn.streaming { background: #f57c00; }
#sendBtn.streaming:hover { background: #e65100; }
/* Stopping state - after stop requested, waiting for confirmation */
#sendBtn.stopping { background: #666; cursor: wait; pointer-events: none; }
#sendBtn.stopping .send-btn-icon .send-icon { display: none; }
#sendBtn.stopping .send-btn-icon .stop-icon { display: none; }
#sendBtn.stopping .send-btn-icon .spinner { display: block; }
/* Streaming WITH input - show send icon to queue message */
#sendBtn.streaming.has-input .send-btn-icon .send-icon { display: block; }
#sendBtn.streaming.has-input .send-btn-icon .spinner { display: none; }
#sendBtn.streaming.has-input .send-btn-icon .stop-icon { display: none; }
#sendBtn.streaming.has-input { background: #4CAF50; }
#sendBtn.streaming.has-input:hover { background: #388E3C; }
/* Send button context menu (right-click / two-finger click) */
.send-context-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 1000;
    padding: 4px 0;
}
.send-context-menu.visible { display: block; }
.send-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8125rem;
    white-space: nowrap;
}
.send-context-menu-item:hover { background: var(--bg-tertiary); }
.send-context-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.send-context-menu-item .submenu-arrow { margin-left: auto; font-size: 0.625rem; color: var(--text-secondary); }
.send-context-menu-separator { height: 1px; background: var(--border); margin: 4px 0; }
.send-context-submenu {
    display: none;
    padding: 2px 0;
    border-top: 1px solid var(--border);
}
.send-context-submenu.visible { display: block; }
.send-context-submenu .send-context-menu-item { padding-left: 36px; font-size: 0.75rem; }
.send-btn-wrapper { position: relative; }

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
    position: relative;
}
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* Jump-to-end floating button */
.jump-to-end-btn {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.85);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s, background 0.15s, color 0.15s;
}
.jump-to-end-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}
.jump-to-end-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}
.jump-to-end-btn svg {
    width: 20px;
    height: 20px;
}

/* Suggestion chips */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 20px 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.suggestion-chips:empty {
    display: none;
}
.suggestion-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px 14px;
    color: var(--accent);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.3;
}
.suggestion-chip:hover {
    background: rgba(139, 111, 71, 0.12);
    border-color: var(--accent);
}

/* Composer / input area */
.input-area {
    position: relative;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-top: none;
    display: flex;
    gap: 12px;
}
.input-area:not(.has-suggestions) {
    border-top: 1px solid var(--border);
}
.input-area textarea {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    resize: none;
    font-family: inherit;
    min-height: 48px;
    max-height: 200px;
}
.input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.input-area textarea::placeholder { color: var(--text-secondary); }

/* File lookup popup (@ mention) */
.file-lookup-popup {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    margin-bottom: 4px;
}
.file-lookup-popup.hidden { display: none; }
.file-lookup-header {
    padding: 6px 12px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.file-lookup-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-lookup-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.file-lookup-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.file-lookup-item .file-name {
    color: var(--accent);
}
.file-lookup-item.active .file-name {
    color: #fff;
}
/* @ mention typed-item icons (file/user) and the "People" avatar image —
   shared by conversation-lookup.js across every host that renders the
   popup (index/conversation/file/history/work). */
.file-lookup-item .lookup-icon {
    display: inline-block;
    width: 16px;
    text-align: center;
    margin-right: 6px;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.file-lookup-item .lookup-avatar {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}
.file-lookup-empty {
    padding: 12px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-style: italic;
    text-align: center;
}
.file-lookup-separator {
    padding: 4px 12px;
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}
.file-lookup-separator:first-child {
    border-top: none;
    margin-top: 0;
}

/* Attachment controls */
.input-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.attachment-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.attach-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.attach-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}
.attach-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.attach-btn svg { width: 20px; height: 20px; }
.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}
.attachment-preview:empty { display: none; }
.attachment-item {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    max-width: 200px;
}
.attachment-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
}
.attachment-item .file-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.attachment-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-item .remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}
.attachment-item .remove-btn:hover { color: var(--accent); }
.attachment-item.uploading {
    opacity: 0.7;
}
.attachment-item.uploading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
