/* ========================================================================
   모던한 AI 채팅창 CSS - 순수 HTML 기반
   ======================================================================== */

/* ========================================================================
   1. CSS VARIABLES & ANIMATIONS
   ======================================================================== */

:root {
    /* Window Dimensions */
    --ai-chat-window-width: 400px;
    --ai-chat-window-height: 600px;
    --ai-chat-header-height: 56px;

    /* VSCode Material Theme Color Palette */
    --vscode-bg-primary: #1e1e1e;
    --vscode-bg-secondary: #252526;
    --vscode-bg-tertiary: #2d2d30;
    --vscode-bg-quaternary: #3e3e42;
    --vscode-bg-main: #23292e;

    --vscode-text-white: #ffffff;
    --vscode-text-white: #cccccc;
    --vscode-text-secondary: #9d9d9d;
    --vscode-text-tertiary: #6d6d6d;

    --vscode-border: #3e3e42;
    --vscode-border-light: #464647;
    --vscode-border-dark: #2d2d30;

    --vscode-accent: #007acc;
    --vscode-accent-glass: #007acc56;
    --vscode-accent-hover: #0e639c;
    --vscode-accent-light: #1a8dd8;

    --vscode-success: #4ec9b0;
    --vscode-warning: #ce9178;
    --vscode-error: #f48771;

    --vscode-button-bg: #0e639c;
    --vscode-button-hover: #1177bb;
    --vscode-button-active: #094771;

    --vscode-scrollbar: #424242;
    --vscode-scrollbar-hover: #4e4e4e;

    --vscode-shadow: rgba(0, 0, 0, 0.3);
    --vscode-shadow-light: rgba(0, 0, 0, 0.15);

    /* Font Families */
    --font-family-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-monospace: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

    /* Code Block Styles */
    --code-bg: rgba(255, 255, 255, 0.06);
    --code-border: rgba(255, 255, 255, 0.12);
    --code-text: #e5e7eb;
    --code-json-bg: rgba(26, 32, 44, 0.7);
    --code-json-border: rgba(96, 165, 250, 0.3);
    --code-json-text: #e2e8f0;
    --code-inline-bg: rgba(255, 255, 255, 0.08);
    --code-inline-text: #c5d9ff;
}

/* Animations */
@keyframes ai-chat-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ai-chat-slide-out {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes ai-chat-typing-pulse {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ai-chat-pulse {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.45;
    }

    50% {
        transform: translateY(-4px) scale(1.25);
        opacity: 1;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 0.45;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ========================================================================
   2. MAIN WINDOW STRUCTURE
   ======================================================================== */

.ai-chat-floating-window {
    position: fixed;
    width: var(--ai-chat-window-width);
    min-width: 370px;
    height: var(--ai-chat-window-height);
    font-family: var(--font-family-system);
    background: var(--vscode-bg-main);
    border-radius: 8px;
    box-shadow: 0 8px 32px var(--vscode-shadow), 0 2px 8px var(--vscode-shadow-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-chat-floating-window.dragging {
    transition: none;
    will-change: transform;
}

.ai-chat-floating-window:hover {
    box-shadow: 0 12px 40px var(--vscode-shadow), 0 4px 12px var(--vscode-shadow-light);
}

/* Body */
.ai-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* 중요: flex item overflow fix */
    background: var(--vscode-bg-main);
    overflow: hidden;
}

/* Resize Handle */
.ai-chat-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    cursor: se-resize;
    background: transparent;
    z-index: 100;
}

.ai-chat-resize-handle:hover {
    background: linear-gradient(-45deg, transparent 30%, rgba(0, 24, 78, 0.3) 30%, rgba(0, 24, 78, 0.3) 40%, transparent 40%, transparent 60%, rgba(0, 24, 78, 0.3) 60%, rgba(0, 24, 78, 0.3) 70%, transparent 70%);
}

/* ========================================================================
   3. HEADER & CONTROLS
   ======================================================================== */

.ai-chat-header {
    background: var(--vscode-bg-secondary);
    padding: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
    position: relative;
    min-height: fit-content;
    box-shadow: 0 2px 8px var(--vscode-shadow-light);
    border-bottom: 1px solid var(--vscode-border);
}

.ai-chat-header:active {
    cursor: grabbing;
}

.ai-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--vscode-accent-glass);
    opacity: 0.05;
    pointer-events: none;
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.ai-chat-title {
    color: var(--vscode-text-white);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.5px;
    max-width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-model-selector {
    display: flex;
    align-items: center;
}

.ai-chat-mode-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 6px;
    padding: 2px;
}

.ai-chat-mode-btn {
    background: transparent;
    color: var(--vscode-text-muted, #8a8a8a);
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 11px;
    font-family: var(--font-family-system);
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ai-chat-mode-btn:hover {
    color: var(--vscode-text-white);
    background: var(--vscode-bg-quaternary);
}

.ai-chat-mode-btn.active {
    background: var(--vscode-accent-glass, rgba(0,122,204,0.35));
    color: var(--vscode-text-white);
    font-weight: 600;
}

.ai-chat-controls {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    min-width: fit-content;
}

/* Header Buttons */
.ai-chat-minimize-btn,
.ai-chat-fullscreen-btn,
.ai-chat-close-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: var(--vscode-bg-tertiary);
    color: var(--vscode-text-white);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family-system);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-minimize-btn:hover,
.ai-chat-fullscreen-btn:hover {
    background: var(--vscode-bg-quaternary);
    transform: scale(1.05);
}

.ai-chat-close-btn:hover {
    background: var(--vscode-error);
    color: var(--vscode-bg-primary);
    transform: scale(1.05);
}

/* Autoscroll Toggle */
.ai-chat-autoscroll-toggle {
    width: auto;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    background: var(--vscode-bg-tertiary);
    color: var(--vscode-text-white);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-chat-autoscroll-toggle:hover {
    background: var(--vscode-bg-quaternary);
}

.ai-chat-autoscroll-toggle.active {
    background: var(--vscode-success);
    color: var(--vscode-bg-primary);
}

/* ========================================================================
   4. MESSAGES & CONTENT
   ======================================================================== */

.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    background: transparent;
    overflow-anchor: none;
    scroll-padding-top: 20px;
    scroll-padding-bottom: 20px;
    transform: translateZ(0);
    will-change: scroll-position;
    contain: layout style paint;
    /* 스크롤 성능 최적화 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--vscode-bg-secondary);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--vscode-scrollbar);
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--vscode-scrollbar-hover);
}

/* Welcome Message */
.ai-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    background: var(--vscode-bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--vscode-shadow-light);
    border: 1px solid var(--vscode-border);
}

.ai-chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.8;
}

.ai-chat-welcome-text {
    color: var(--vscode-text-secondary);
    font-size: 15px;
    line-height: 1.6;
    font-weight: 500;
}

.ai-chat-welcome-disclaimer {
    margin-top: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    line-height: 1.5;
    border-top: 1px solid var(--vscode-border);
    padding-top: 10px;
}

/* Message Bubbles */
.ai-chat-message {
    margin: 16px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: ai-chat-slide-in 0.4s ease-out;
}

.ai-chat-message-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.ai-chat-message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.ai-chat-message-user .ai-chat-message-content {
    background: transparent;
    color: var(--vscode-text-white);
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 24, 78, 0.3);
}

.ai-chat-message-ai .ai-chat-message-content {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
    border: none;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.ai-chat-message-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--vscode-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
}

/* Typing Indicator */
.ai-chat-typing {
    display: none;
    align-items: center;
    gap: 12px;
    margin: 0 20px 20px 20px;
    padding: 12px 16px;
    background: var(--vscode-bg-secondary);
    border-radius: 8px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px var(--vscode-shadow-light);
    animation: ai-chat-fade-in 0.3s ease;
    color: var(--vscode-text-white);
}

.ai-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--vscode-text-tertiary);
    border-radius: 50%;
    animation: ai-chat-pulse 2s linear infinite;
}

.ai-chat-typing-dots span:nth-child(1) {
    animation-delay: 0.1s;
}

.ai-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.3s;
}

.ai-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Thinking Styles */
.ai-chat-thinking {
    display: none;
    color: var(--vscode-text-secondary);
    font-size: 0.9em;
    font-style: italic;
    margin-top: 6px;
    white-space: pre-wrap;
}

.thinking-indicator {
    margin: 8px 0;
    padding: 12px;
    background: var(--vscode-bg-secondary);
    border-left: 4px solid var(--vscode-accent-glass);
    border-radius: 4px;
    font-size: 0.9em;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
    width: 100%;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-weight: 500;
    color: var(--vscode-text-white);
}

.thinking-icon {
    font-size: 1.2em;
}

.thinking-label {
    flex-grow: 1;
}

.thinking-content {
    margin-top: 8px;
    padding: 8px;
    background: var(--vscode-bg-tertiary);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--vscode-border);
}

.thinking-text {
    font-family: var(--font-family-system);
    font-size: 14px;
    white-space: pre-wrap;
    color: var(--vscode-text-secondary);
    line-height: 1.5;
    text-align: left;
}

/* ========================================================================
   5. INPUT AREA & BUTTONS
   ======================================================================== */

.ai-chat-input-area {
    padding: 0px;
    background: none;
    border-top: 1px solid var(--vscode-border);
    min-height: fit-content;
    position: relative;
    display: flex;
    flex-direction: row;
    gap: 0px;
    align-items: flex-start;
}

.ai-chat-input-container {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 0.375rem;
    border: 1px solid var(--vscode-border);
    transition: all 0.3s ease;
    min-height: fit-content;
    box-shadow: 0 2px 8px var(--vscode-shadow-light);
    position: relative;
    z-index: 1;
    overflow: visible;
}

.ai-chat-input-container:focus-within {
    border-color: var(--vscode-accent-glass);
    box-shadow: 0 0 0 1px var(--vscode-accent-glass), 0 4px 12px var(--vscode-shadow);
}

.ai-chat-input-container.drag-over {
    border-color: var(--vscode-accent);
    background: var(--vscode-accent-glass);
    box-shadow: 0 0 0 2px var(--vscode-accent-glass);
}

.ai-chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: var(--font-family-system);
    resize: none;
    min-height: 2.25rem;
    max-height: 5rem;
    overflow-y: auto;
    line-height: 1.5;
    display: flex;
    align-items: center;
    color: var(--vscode-text-white);
    position: relative;
    z-index: 2;
}

.ai-chat-input::placeholder {
    color: var(--vscode-text-tertiary);
    font-style: italic;
}

.ai-chat-input:focus {
    outline: none;
    background: transparent;
    color: var(--vscode-text-white);
}

/* Monaco Editor */
.ai-chat-editor {
    flex: 1 1 auto;
    min-height: 2.25rem;
    max-height: 5rem;
    overflow: hidden;
    padding: 0.25rem;
    border-radius: 0px;
    position: relative;
    z-index: 2;
    font-family: var(--font-family-monospace) !important;
}

.ai-chat-editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 2.25rem;
}

.ai-chat-editor-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: ai-chat-spin 0.8s linear infinite;
}

@keyframes ai-chat-spin {
    to { transform: rotate(360deg); }
}

.ai-chat-editor .monaco-editor,
.ai-chat-editor .monaco-editor .overflow-guard {
    border-radius: inherit;
    font-family: inherit;
}

.ai-chat-editor .monaco-editor .cursor {
    background-color: #2b3442 !important;
    color: var(--vscode-text-white) !important;
}

.ai-chat-editor .monaco-editor .mtkw {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* Common Button Styles */
.ai-chat-send-btn,
.ai-chat-stop-btn,
.ai-chat-clear-btn,
.ai-chat-attach-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
    position: relative;
    z-index: 2;
    overflow: hidden;
    font-size: 16px;
}

.ai-chat-send-btn::before,
.ai-chat-stop-btn::before,
.ai-chat-clear-btn::before,
.ai-chat-attach-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Send Button */
.ai-chat-send-btn {
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
}

.ai-chat-send-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--vscode-text-white);
}

.ai-chat-send-btn::before {
    background: var(--vscode-accent-hover);
}

.ai-chat-send-btn:hover:not(:disabled) {
    box-shadow: 0 4px 8px var(--vscode-shadow);
    background: var(--vscode-accent-hover);
}

.ai-chat-send-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: 0 1px 2px var(--vscode-shadow-light);
}

/* Stop Button */
.ai-chat-stop-btn {
    background: var(--vscode-error);
    color: var(--vscode-text-white);
}

.ai-chat-stop-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--vscode-text-white);
}

.ai-chat-stop-btn:hover {
    box-shadow: 0 4px 8px var(--vscode-shadow);
    background: var(--vscode-error);
}

.ai-chat-stop-btn:hover::before {
    opacity: 1;
}

/* Clear Button */
.ai-chat-clear-btn {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
    font-weight: 500;
}

.ai-chat-clear-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--vscode-text-white);
}

.ai-chat-clear-btn:hover {
    box-shadow: 0 4px 8px var(--vscode-shadow);
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
}

.ai-chat-clear-btn:hover::before {
    opacity: 1;
}

.ai-chat-clear-btn:active {
    background: var(--vscode-accent-hover);
}

/* Attach Button */
.ai-chat-attach-btn {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
}

.ai-chat-attach-btn:hover {
    box-shadow: 0 4px 8px var(--vscode-shadow);
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
}

.ai-chat-attach-btn:hover::before {
    opacity: 1;
}

.ai-chat-attach-btn:active {
    background: var(--vscode-accent-hover);
}

/* Stream Stop Message */
.stream-stop-message {
    color: var(--vscode-warning);
    font-style: italic;
    margin-top: 8px;
    padding: 4px 0;
    opacity: 0.8;
}

/* ========================================================================
   6. TOOL CALL & THINKING
   ======================================================================== */

.tool-call-indicator {
    margin: 8px 0;
    padding: 12px;
    border-left: 4px solid var(--vscode-accent-glass);
    border-radius: 4px;
    font-size: 0.9em;
    background: transparent;
    width: 100%;
    overflow: hidden;
    min-width: 0;
    contain: layout style paint;
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
    isolation: isolate;
}

.tool-call-indicator .tool-header {
    background: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--vscode-text-white);
    padding: 4px 0;
}

.tool-call-indicator .tool-icon {
    font-size: 1.2em;
}

.tool-call-indicator .tool-name {
    flex-grow: 1;
    font-weight: 600;
}

.tool-call-indicator .tool-status {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--vscode-bg-tertiary);
    color: var(--vscode-text-tertiary);
}

.tool-call-indicator .tool-status.status-called {
    background: var(--vscode-warning);
    color: var(--vscode-bg-primary);
}

.tool-call-indicator .tool-status.status-executing {
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
}

.tool-call-indicator .tool-status.status-completed {
    background: var(--vscode-success);
    color: var(--vscode-bg-primary);
    font-weight: 600;
}

.tool-call-indicator .tool-content {
    margin-top: 8px;
}

.tool-call-indicator details {
    border: none;
    padding: 0;
    margin: 0;
    contain: layout style;
    transform: translateZ(0);
}

.tool-call-indicator details summary {
    cursor: pointer;
    padding: 4px 8px;
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    font-size: 0.8em;
    color: var(--vscode-text-secondary);
    user-select: none;
    transition: background-color 0.15s ease;
    list-style: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translateZ(0);
    will-change: background-color;
}

.tool-call-indicator details summary::-webkit-details-marker {
    display: none;
}

.tool-call-indicator details summary::before {
    content: '▶';
    margin-right: 8px;
    font-size: 0.8em;
    transition: transform 0.15s ease;
    will-change: transform;
}

.tool-call-indicator details[open] summary::before {
    transform: rotate(90deg);
}

.tool-call-indicator details summary:hover {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
}

.tool-call-indicator details[open] summary {
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
    border-color: var(--vscode-accent-glass);
}

.tool-call-indicator .tool-summary {
    cursor: pointer;
    padding: 4px 8px;
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    font-size: 0.8em;
    color: var(--vscode-text-secondary);
    user-select: none;
    transition: background-color 0.15s ease;
    list-style: none;
    outline: none;
    transform: translateZ(0);
}

.tool-call-indicator .tool-summary:hover {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
}

.tool-call-indicator details[open] .tool-summary {
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
    border-color: var(--vscode-accent-glass);
}

.tool-call-indicator .tool-section-title {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--vscode-text-secondary);
    margin-bottom: 4px;
    margin-top: 8px;
}

.tool-call-indicator .tool-section-title:first-child {
    margin-top: 0;
}

.tool-call-indicator .tool-args-container {
    margin-bottom: 8px;
}

.tool-call-indicator .tool-args {
    font-family: var(--font-family-monospace);
    background: var(--vscode-bg-tertiary);
    padding: 8px;
    border-radius: 4px;
    font-size: 0.8em;
    color: var(--vscode-text-secondary);
    white-space: pre;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--vscode-border);
    margin: 0;
    min-width: 300px;
}

.tool-call-indicator .tool-result-container {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--vscode-border);
}

.tool-call-indicator .tool-result-content {
    font-family: var(--font-family-monospace);
    font-size: 0.8em;
    color: var(--vscode-text-secondary);
    white-space: pre;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: auto;
    line-height: 1.4;
    background: var(--vscode-bg-tertiary);
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--vscode-border);
    min-width: 300px;
}

.tool-call-indicator.status-called {
    background: rgba(206, 145, 120, 0.1);
    border-left-color: #ce9178;
}

.tool-call-indicator.executing {
    background: rgba(0, 122, 204, 0.1);
    border-left-color: #007acc;
}

.tool-call-indicator.completed {
    background: rgba(78, 201, 176, 0.1) !important;
    border-left-color: #4ec9b0 !important;
}

.tool-call-indicator .tool-result {
    margin-top: 8px;
    padding: 8px;
    background: var(--vscode-bg-primary);
    border-radius: 4px;
    border: 1px solid var(--vscode-border);
}

.tool-call-indicator .tool-result-header {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--vscode-text-white);
    font-size: 0.85em;
}

.tool-call-indicator.completed .tool-status {
    background: var(--vscode-success);
    color: var(--vscode-bg-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tool-expand-button {
    margin-top: 8px;
    padding: 4px 8px;
    background: var(--vscode-accent-glass);
    color: var(--vscode-text-white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.2s ease;
}

.tool-expand-button:hover {
    background: var(--vscode-accent-hover);
}

/* Tool Logs */
.tool-logs-container {
    margin-top: 8px;
    border-top: 1px solid var(--vscode-border);
    padding-top: 8px;
}

.tool-logs-content {
    max-height: 150px;
    overflow-y: auto;
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    padding: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--vscode-text-secondary);
}

.tool-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8em;
    line-height: 1.5;
    word-break: break-word;
}

.tool-log-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

.log-timestamp {
    color: var(--vscode-accent-glass);
    font-weight: bold;
    margin-right: 8px;
    font-size: 0.8em;
}

.log-event-badge {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-top: 2px;
}

.log-badge-thinking {
    background-color: var(--vscode-accent-glass);
    color: var(--vscode-bg-primary);
}

.log-badge-tool-call {
    background-color: var(--vscode-warning);
    color: var(--vscode-bg-primary);
}

.log-badge-text {
    background-color: var(--vscode-success);
    color: var(--vscode-bg-primary);
}

.log-badge-unknown,
.log-badge-raw-message {
    background-color: var(--vscode-text-tertiary);
    color: var(--vscode-bg-primary);
}

.log-content {
    flex-grow: 1;
    color: var(--vscode-text-secondary);
}

.log-json-payload {
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0 0 0;
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    max-width: 100%;
}

/* ========================================================================
   7. TABLES & CODE BLOCKS
   ======================================================================== */



.ai-chat-message-ai .ai-chat-message-content h1,
.ai-chat-message-ai .ai-chat-message-content h2,
.ai-chat-message-ai .ai-chat-message-content h3,
.ai-chat-message-ai .ai-chat-message-content h4,
.ai-chat-message-ai .ai-chat-message-content h5,
.ai-chat-message-ai .ai-chat-message-content h6,
.ai-response-content h1,
.ai-response-content h2,
.ai-response-content h3,
.ai-response-content h4,
.ai-response-content h5,
.ai-response-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 500;
    line-height: 1.4;
    color: var(--vscode-text-white);
}

.ai-chat-message-ai .ai-chat-message-content h1,
.ai-response-content h1 {
    font-size: 1.5em;
    border-bottom: 2px solid rgba(0, 0, 0, 0.12);
    padding-bottom: 8px;
}

.ai-chat-message-ai .ai-chat-message-content h2,
.ai-response-content h2 {
    font-size: 1.3em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    padding-bottom: 6px;
}

.ai-chat-message-ai .ai-chat-message-content h3,
.ai-response-content h3 {
    font-size: 1.1em;
}

.ai-chat-message-ai .ai-chat-message-content p,
.ai-response-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.ai-chat-message-ai .ai-chat-message-content ul,
.ai-chat-message-ai .ai-chat-message-content ol,
.ai-response-content ul,
.ai-response-content ol {
    margin: 8px 0;
    padding-left: 24px;
    color: var(--vscode-text-white);
}

.ai-chat-message-ai .ai-chat-message-content li,
.ai-response-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.ai-chat-message-ai .ai-chat-message-content ul ul,
.ai-chat-message-ai .ai-chat-message-content ol ol,
.ai-chat-message-ai .ai-chat-message-content ul ol,
.ai-chat-message-ai .ai-chat-message-content ol ul,
.ai-response-content ul ul,
.ai-response-content ol ol,
.ai-response-content ul ol,
.ai-response-content ol ul {
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Inline Code */
.ai-chat-message-ai .ai-chat-message-content code,
.ai-response-content code {
    background: var(--code-inline-bg);
    color: var(--code-inline-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-family-monospace);
    font-size: 0.9em;
    border: 1px solid var(--code-border);
}

/* Code Blocks */
.ai-chat-message-ai .ai-chat-message-content pre,
.ai-response-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 12px 0;
    overflow-x: auto;
    max-width: 100%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    position: relative;
}

.ai-chat-message-ai .ai-chat-message-content pre code,
.ai-response-content pre code {
    background: transparent;
    color: var(--code-text);
    padding: 0;
    display: block;
    white-space: pre;
    word-break: normal;
    border: none;
    font-size: 0.85em;
    line-height: 1.5;
}

.ai-chat-message-ai .ai-chat-message-content pre[class*="language-"]::before,
.ai-response-content pre[class*="language-"]::before {
    content: attr(class);
    position: absolute;
    top: 0;
    right: 0;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 6px 0 6px;
    font-size: 0.75em;
    color: var(--vscode-text-tertiary);
    text-transform: uppercase;
}

/* Code Block Scrollbar */
.ai-chat-message-ai .ai-chat-message-content pre::-webkit-scrollbar,
.ai-response-content pre::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.ai-chat-message-ai .ai-chat-message-content pre::-webkit-scrollbar-track,
.ai-response-content pre::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.ai-chat-message-ai .ai-chat-message-content pre::-webkit-scrollbar-thumb,
.ai-response-content pre::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 3px;
}

.ai-chat-message-ai .ai-chat-message-content pre::-webkit-scrollbar-thumb:hover,
.ai-response-content pre::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}

/* Code Block Styles */
.ai-chat-message-ai .ai-chat-message-content .code-block,
.ai-response-content .code-block {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-block {
    position: relative;
}

/* JSON Code */
.ai-chat-message-ai .ai-chat-message-content .json-code,
.ai-response-content .json-code {
    background: var(--code-json-bg);
    border: 1px solid var(--code-json-border);
    color: var(--code-json-text);
    font-family: var(--font-family-monospace);
    font-size: 0.85em;
    line-height: 1.5;
}

/* Inline Code */
.ai-chat-message-ai .ai-chat-message-content .inline-code,
.ai-response-content .inline-code {
    background: var(--code-inline-bg);
    color: var(--code-inline-text);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: var(--font-family-monospace);
    font-size: 0.85em;
    border: 1px solid var(--code-border);
    word-break: break-word;
}

/* JSON Syntax Highlighting */
.language-json {
    color: var(--vscode-text-white);
}

.language-json .string {
    color: var(--vscode-success);
}

.language-json .number {
    color: var(--vscode-accent-light);
}

.language-json .boolean {
    color: var(--vscode-warning);
}

.language-json .null {
    color: var(--vscode-error);
}

.language-json .punctuation {
    color: var(--vscode-text-white);
}

/* Copy Button */
.copy-button {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--vscode-bg-tertiary);
    color: var(--vscode-text-white);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7;
    z-index: 10;
}

.copy-button-container {
    position: relative;
    bottom: 4px;
    right: 4px;
    display: flex;
    flex-direction: row;
    width: fit-content;
    gap: 4px;
    background: var(--vscode-bg-secondary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
}

.copy-text-button,
.copy-html-button {
    font-size: 0.6rem;
    padding: 2px 4px;
    border-radius: 1px;
    width: auto;
    min-width: 60px;
    text-align: center;
    white-space: nowrap;
}

.copy-text-button {
    background: var(--vscode-bg-tertiary);
    color: var(--vscode-text-white);
    border: 1px solid var(--vscode-border);
    transition: all 0.15s ease;
}

.copy-html-button {
    background: var(--vscode-success);
    color: var(--vscode-bg-primary);
    border: 1px solid var(--vscode-success);
    transition: all 0.15s ease;
}

.copy-text-button:hover {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
}

.copy-html-button:hover {
    background: var(--vscode-success);
    color: var(--vscode-bg-primary);
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
}

.copy-text-button:active,
.copy-html-button:active {
    background: var(--vscode-accent-glass);
    color: var(--vscode-bg-primary);
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Tables */
.ai-chat-message-ai .ai-chat-message-content table,
.ai-response-content table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 12px 0;
    border: 1px solid var(--vscode-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
    font-size: 0.9em;
    background: var(--vscode-bg-secondary);
}

.ai-chat-message-ai .ai-chat-message-content thead,
.ai-response-content thead {
    background: var(--vscode-bg-tertiary);
}

.ai-chat-message-ai .ai-chat-message-content thead tr,
.ai-response-content thead tr {
    background: var(--vscode-bg-tertiary);
}

.ai-chat-message-ai .ai-chat-message-content th,
.ai-chat-message-ai .ai-chat-message-content td,
.ai-response-content th,
.ai-response-content td {
    padding: 10px 12px;
    text-align: left;
}

.ai-chat-message-ai .ai-chat-message-content th,
.ai-response-content th {
    background: var(--vscode-bg-tertiary);
    font-weight: 600;
    color: var(--vscode-text-white);
    border-bottom: 2px solid var(--vscode-border);
}

.ai-chat-message-ai .ai-chat-message-content th:first-child,
.ai-response-content th:first-child {
    border-top-left-radius: 8px;
}

.ai-chat-message-ai .ai-chat-message-content th:last-child,
.ai-response-content th:last-child {
    border-top-right-radius: 8px;
}

.ai-chat-message-ai .ai-chat-message-content td,
.ai-response-content td {
    border: none;
    border-bottom: 1px solid var(--vscode-border);
    color: var(--vscode-text-white);
}

.ai-chat-message-ai .ai-chat-message-content tbody tr,
.ai-response-content tbody tr {
    transition: background-color 0.2s ease;
}

.ai-chat-message-ai .ai-chat-message-content tbody tr:nth-child(even),
.ai-response-content tbody tr:nth-child(even) {
    background: var(--vscode-bg-secondary);
}

.ai-chat-message-ai .ai-chat-message-content tbody tr:hover,
.ai-response-content tbody tr:hover {
    background: var(--vscode-bg-quaternary);
}

.ai-chat-message-ai .ai-chat-message-content tbody tr:last-child td,
.ai-response-content tbody tr:last-child td {
    border-bottom: none;
}

.ai-chat-message-ai .ai-chat-message-content tbody tr:last-child td:first-child,
.ai-response-content tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.ai-chat-message-ai .ai-chat-message-content tbody tr:last-child td:last-child,
.ai-response-content tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* Other Elements */
.ai-chat-message-ai .ai-chat-message-content blockquote,
.ai-response-content blockquote {
    border-left: 4px solid var(--vscode-text-secondary);
    margin: 12px 0;
    padding-left: 16px;
    color: var(--vscode-text-white);
    font-style: italic;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 4px 4px 0;
}

.ai-chat-message-ai .ai-chat-message-content a,
.ai-response-content a {
    color: var(--vscode-accent-light);
    text-decoration: none;
    word-break: break-word;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ai-chat-message-ai .ai-chat-message-content a:hover,
.ai-response-content a:hover {
    color: var(--vscode-accent-hover);
    text-decoration: underline;
}

.ai-chat-message-ai .ai-chat-message-content strong,
.ai-response-content strong {
    font-weight: 500;
    color: var(--vscode-text-white);
}

.ai-chat-message-ai .ai-chat-message-content em,
.ai-response-content em {
    font-style: italic;
    color: var(--vscode-text-white);
}

.ai-chat-message-ai .ai-chat-message-content hr,
.ai-response-content hr {
    border: none;
    height: 1px;
    background: var(--vscode-border);
    margin: 16px 0;
}

.ai-chat-message-ai .ai-chat-message-content img,
.ai-response-content img {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
    object-fit: contain;
}

.ai-chat-message-user .ai-chat-message-content img {
    max-width: 300px;
    max-height: 300px;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
    object-fit: contain;
}

.ai-chat-message-ai .ai-chat-message-content input[type="checkbox"],
.ai-response-content input[type="checkbox"] {
    margin-right: 8px;
}

.ai-chat-message-ai .ai-chat-message-content dl,
.ai-response-content dl {
    margin: 12px 0;
}

.ai-chat-message-ai .ai-chat-message-content dt,
.ai-response-content dt {
    font-weight: 600;
    color: var(--vscode-text-white);
    margin-top: 8px;
}

.ai-chat-message-ai .ai-chat-message-content dd,
.ai-response-content dd {
    margin-left: 20px;
    color: var(--vscode-text-white);
    margin-bottom: 8px;
}

.ai-chat-message-ai .ai-chat-message-content kbd,
.ai-response-content kbd {
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 3px;
    padding: 2px 4px;
    font-family: var(--font-family-monospace);
    font-size: 0.85em;
    box-shadow: 0 1px 2px var(--vscode-shadow-light);
}

.ai-chat-message-ai .ai-chat-message-content del,
.ai-response-content del {
    text-decoration: line-through;
    color: var(--vscode-text-tertiary);
}

.ai-chat-message-ai .ai-chat-message-content ins,
.ai-response-content ins {
    text-decoration: underline;
    color: var(--vscode-success);
}

.ai-chat-message-ai .ai-chat-message-content mark,
.ai-response-content mark {
    background: var(--vscode-warning);
    padding: 2px 4px;
    border-radius: 2px;
}

.ai-chat-message-ai .ai-chat-message-content .mermaid-diagram,
.ai-response-content .mermaid-diagram {
    margin: 12px 0;
    text-align: center;
    background: var(--vscode-bg-primary);
    border: 1px solid var(--vscode-border);
    border-radius: 4px;
    padding: 16px;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
    overflow: auto;
}

.ai-chat-message-ai .ai-chat-message-content .mermaid-error,
.ai-response-content .mermaid-error {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--vscode-error);
    border: 1px solid var(--vscode-error);
    border-radius: 4px;
    color: var(--vscode-bg-primary);
    font-family: var(--font-family-monospace);
    font-size: 0.9em;
}

/* ========================================================================
   8. ATTACHMENTS
   ======================================================================== */

.ai-chat-attachments-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    background: transparent;
    border: none;
    min-width: 80px;
    max-width: 100px;
    flex-shrink: 0;
}

.ai-chat-attachment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--vscode-bg-tertiary);
    border: 1px solid var(--vscode-border);
    border-radius: 6px;
    box-shadow: 0 2px 4px var(--vscode-shadow-light);
    transition: all 0.2s ease;
    width: 100%;
    position: relative;
}

.ai-chat-attachment:hover {
    background: var(--vscode-bg-quaternary);
    box-shadow: 0 4px 8px var(--vscode-shadow);
}

.ai-chat-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--vscode-bg-primary);
    border: 1px solid var(--vscode-border);
    flex-shrink: 0;
}

.ai-chat-attachment-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ai-chat-attachment-icon {
    font-size: 24px;
    color: var(--vscode-text-secondary);
}

.ai-chat-attachment-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.ai-chat-attachment-name {
    font-size: 10px;
    color: var(--vscode-text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

.ai-chat-attachment-remove {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--vscode-error);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ai-chat-attachment-remove:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

.ai-chat-attachment-remove:active {
    transform: scale(0.95);
}

/* ========================================================================
   9. CONTEXT MANAGER
   ======================================================================== */

/* Progress Bar Container in Header */
.ai-chat-context-progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
    margin-left: auto;
    position: relative;
    cursor: pointer;
    z-index: 10001;
}

.ai-chat-context-progress-bar {
    width: 60px;
    height: 8px;
    background: var(--vscode-bg-quaternary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.ai-chat-context-progress-fill {
    height: 100%;
    background: var(--vscode-success);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.ai-chat-context-progress-icon {
    font-size: 14px;
    color: var(--vscode-text-secondary);
    display: flex;
    align-items: center;
}

/* Compact Hover Preview Modal */
.ai-chat-context-modal-compact {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--vscode-bg-secondary);
    border: 1px solid var(--vscode-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--vscode-shadow);
    width: 250px;
    z-index: 10002;
    padding: 8px;
    display: none;
}

.ai-chat-context-modal-compact.visible {
    display: block;
    animation: ai-chat-slide-in 0.2s ease;
}

.context-compact-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--vscode-text-secondary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--vscode-border-light);
}

.context-compact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.context-compact-role {
    font-weight: bold;
    width: 40px;
    color: var(--vscode-accent-light);
    text-transform: capitalize;
}

.context-compact-bar {
    flex: 1;
    height: 4px;
    background: var(--vscode-bg-quaternary);
    border-radius: 2px;
    overflow: hidden;
}

.context-compact-fill {
    height: 100%;
    background: var(--vscode-accent);
}

/* Context Modal Backdrop */
.ai-chat-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    /* Semi-transparent dark overlay */
    z-index: 10003;
    /* Higher than other elements */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ai-chat-fade-in 0.2s ease;
}

/* Full Context Manager Modal */
.ai-chat-context-modal-full {
    width: 90%;
    max-width: 600px;
    height: 80%;
    max-height: 800px;
    background: var(--vscode-bg-primary);
    border: 1px solid var(--vscode-border);
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Centering is now handled by backdrop */
}

.context-full-header {
    padding: 12px 16px;
    background: var(--vscode-bg-secondary);
    border-bottom: 1px solid var(--vscode-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--vscode-text-white);
}

.context-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-header-actions .ai-chat-close-btn {
    margin-left: auto;
}

.context-full-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.context-full-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-bottom: 1px solid var(--vscode-border-dark);
    font-size: 13px;
}

.context-full-item:last-child {
    border-bottom: none;
}

.context-item-checkbox {
    cursor: pointer;
}

.context-item-role {
    width: 60px;
    font-weight: bold;
    color: var(--vscode-accent-light);
    text-transform: capitalize;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ✅ Context badges for thinking and tool_logs */
.context-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: normal;
    text-transform: none;
}

.context-badge-thinking {
    background: rgba(142, 68, 173, 0.3);
    color: #ce93d8;
    border: 1px solid rgba(142, 68, 173, 0.5);
}

.context-badge-tools {
    background: rgba(78, 201, 176, 0.3);
    color: #4ec9b0;
    border: 1px solid rgba(78, 201, 176, 0.5);
}

.context-item-preview {
    flex: 2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--vscode-text-white);
    cursor: pointer;
}

.context-item-preview:hover {
    color: var(--vscode-accent-hover);
    text-decoration: underline;
}

.context-item-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.context-item-bar {
    height: 6px;
    background: var(--vscode-bg-quaternary);
    border-radius: 3px;
    overflow: hidden;
}

.context-item-tokens {
    font-size: 10px;
    color: var(--vscode-text-tertiary);
    text-align: right;
}

.context-item-fill {
    height: 100%;
    background: var(--vscode-accent);
}

.context-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.context-btn-edit,
.context-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--vscode-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.context-btn-edit:hover {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
}

.context-btn-delete:hover {
    background: var(--vscode-error);
    color: white;
}

.context-full-footer {
    padding: 12px 16px;
    background: var(--vscode-bg-secondary);
    border-top: 1px solid var(--vscode-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.context-token-info {
    font-size: 12px;
    color: var(--vscode-text-secondary);
    padding: 8px 16px;
    background: var(--vscode-bg-secondary);
    border-bottom: 1px solid var(--vscode-border);
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
}

/* Monaco Editor Popup */
.ai-chat-monaco-popup {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10004;
    display: flex;
    align-items: center;
    justify-content: center;
}

.monaco-popup-content {
    background: var(--vscode-bg-primary);
    border: 1px solid var(--vscode-border);
    border-radius: 8px;
    width: 80%;
    height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px black;
    overflow: hidden;
    /* Ensure rounded corners clip content */
}

.monaco-popup-header {
    padding: 8px 12px;
    background: var(--vscode-bg-secondary);
    color: var(--vscode-text-white);
    border-bottom: 1px solid var(--vscode-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.monaco-popup-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.monaco-popup-footer {
    padding: 8px 12px;
    background: var(--vscode-bg-secondary);
    border-top: 1px solid var(--vscode-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Common Button Styles */
.ai-chat-btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
}

.ai-chat-btn-primary {
    background: var(--vscode-button-bg);
    color: white;
}

.ai-chat-btn-primary:hover {
    background: var(--vscode-button-hover);
}

.ai-chat-btn-secondary {
    background: var(--vscode-bg-quaternary);
    color: var(--vscode-text-white);
}

.ai-chat-btn-secondary:hover {
    background: var(--vscode-border-light);
}

.ai-chat-btn-danger {
    background: var(--vscode-error);
    color: white;
}

.ai-chat-btn-danger:hover {
    background: #d32f2f;
}

/* ========================================================================
   10. RESPONSIVE DESIGN
   ======================================================================== */

@media (max-width: 1000px) {
    .ai-chat-floating-window {
        border-radius: 16px;
    }

    .ai-chat-message-content {
        max-width: 85%;
    }

    .ai-chat-input-area {
        padding: 0px;
    }

    .ai-chat-messages {
        padding: 16px;
    }

    /* Context 관련 요소들 숨기기 */
    .ai-chat-context-progress-container {
        display: none !important;
    }
}

/* ========================================================================
   11. TEMPLATE CARD GRID
   ======================================================================== */

.ai-template-card-grid-wrapper {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-template-grid-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text-secondary, #aaa);
    padding-bottom: 2px;
}

.ai-template-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.ai-template-card {
    border: 1px solid var(--ai-border, #3a3a3a);
    border-radius: 8px;
    padding: 12px 14px;
    cursor: pointer;
    background: var(--ai-bg-secondary, #2a2a2a);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    user-select: none;
}

.ai-template-card:hover {
    border-color: #4a9eff;
    background: rgba(74, 158, 255, 0.08);
}

.ai-template-card.selected {
    border-color: #4a9eff;
    background: rgba(74, 158, 255, 0.14);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

.ai-template-card.dimmed {
    opacity: 0.4;
}

.ai-template-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text-primary, #e0e0e0);
    margin-bottom: 4px;
    line-height: 1.4;
}

.ai-template-card-desc {
    font-size: 11px;
    color: var(--ai-text-secondary, #999);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ai-template-approve-btn {
    align-self: flex-start;
    padding: 8px 24px;
    border: none;
    border-radius: 6px;
    background: #4a9eff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.ai-template-approve-btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

.ai-template-approve-btn.active:not(:disabled):hover {
    background: #2d84f5;
}

.ai-template-approve-btn.approved {
    background: #3ecf6e;
    cursor: default;
}

/* ========================================================================
   12. CUSTOMER TABLE GRID
   ======================================================================== */

.ai-customer-table-wrapper {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-customer-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.ai-customer-table thead th {
    padding: 6px 10px;
    text-align: left;
    background: var(--ai-bg-secondary, #2a2a2a);
    color: var(--ai-text-secondary, #999);
    border-bottom: 1px solid var(--ai-border, #3a3a3a);
    font-weight: 600;
    white-space: nowrap;
}

.ai-customer-table thead th:first-child {
    width: 28px;
}

.ai-customer-row {
    cursor: pointer;
    border-bottom: 1px solid var(--ai-border, #2e2e2e);
    transition: background 0.1s;
}

.ai-customer-row td {
    padding: 7px 10px;
    color: var(--ai-text-primary, #ddd);
}

.ai-customer-row:hover {
    background: rgba(74, 158, 255, 0.07);
}

.ai-customer-row.selected {
    background: rgba(74, 158, 255, 0.13);
}

.ai-customer-row.dimmed {
    opacity: 0.4;
}

.ai-radio-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #555;
    vertical-align: middle;
    transition: border-color 0.1s, background 0.1s;
}

.ai-customer-row.selected .ai-radio-dot {
    border-color: #4a9eff;
    background: #4a9eff;
}

.ai-customer-btn-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-customer-skip-btn {
    padding: 8px 18px;
    border: 1px solid #555;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.ai-customer-skip-btn:hover:not(:disabled) {
    border-color: #888;
    color: #ddd;
}

.ai-customer-skip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================================================
   13. COLLECTION FIELD EDITOR (Step 5 – OCR 수집문자 편집)
   ======================================================================== */

.ai-field-editor-wrapper {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-field-editor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.ai-field-editor-table thead th {
    padding: 6px 10px;
    text-align: left;
    background: var(--ai-bg-secondary, #2a2a2a);
    color: var(--ai-text-secondary, #999);
    border-bottom: 1px solid var(--ai-border, #3a3a3a);
    font-weight: 600;
}

.ai-field-editor-table tbody tr {
    border-bottom: 1px solid var(--ai-border, #2e2e2e);
}

.ai-field-editor-table td {
    padding: 5px 10px;
    color: var(--ai-text-primary, #ddd);
    vertical-align: middle;
}

.ai-field-code { color: var(--ai-text-secondary, #999); font-size: 11px; }

.ai-field-value-input {
    width: 100%;
    background: var(--ai-bg-secondary, #2a2a2a);
    border: 1px solid var(--ai-border, #3a3a3a);
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--ai-text-primary, #ddd);
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.ai-field-value-input:focus {
    border-color: #4a9eff;
}

.ai-field-value-input.empty {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.07);
}

.ai-field-value-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================================================
   14. STANDARD INFO EDITOR (Step 7 – 기준정보 4단계 순차 승인)
   ======================================================================== */

.ai-std-editor-wrapper {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-std-steps {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ai-std-step {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--ai-bg-secondary, #2a2a2a);
    color: var(--ai-text-secondary, #888);
    border: 1px solid var(--ai-border, #3a3a3a);
    transition: background 0.15s, color 0.15s;
}

.ai-std-step.active {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
    border-color: #4a9eff;
}

.ai-std-step.done {
    background: rgba(62, 207, 110, 0.15);
    color: #3ecf6e;
    border-color: #3ecf6e;
}

.ai-std-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.ai-std-panel.active {
    display: flex;
}

.ai-std-panel-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--ai-text-secondary, #aaa);
    letter-spacing: 0.05em;
}

.ai-std-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    max-height: 220px;
    display: block;
    overflow-y: auto;
    overflow-x: auto;
}

.ai-std-table thead th {
    padding: 5px 8px;
    text-align: left;
    background: var(--ai-bg-secondary, #2a2a2a);
    color: var(--ai-text-secondary, #999);
    border-bottom: 1px solid var(--ai-border, #3a3a3a);
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.ai-std-table tbody tr {
    border-bottom: 1px solid var(--ai-border, #2a2a2a);
}

.ai-std-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.ai-std-table td {
    padding: 5px 8px;
    color: var(--ai-text-primary, #ddd);
    white-space: nowrap;
}

.ai-std-section-btn {
    align-self: flex-start;
    margin-top: 4px;
}