/* =============================================================================
   TERMINAL CSS - Modern Manus-Inspired Design
   =============================================================================
   Contains:
   1. Modern Embedded Terminal (inline within chat messages)
   2. Side Panel Terminal (slide-out panel)
   3. Approval System Styles
   ============================================================================= */


/* =============================================================================
   SECTION 1: MODERN EMBEDDED TERMINAL (Inline Chat)
   ============================================================================= */

.embedded-terminal {
    background: #1a1f2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin: 16px auto;
    overflow: hidden;
    animation: terminalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 50rem;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes terminalFadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Header with macOS Traffic Light Dots + Window Controls --- */
.embedded-terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #232839;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: default;
    user-select: none;
    min-width: 0;
    overflow: hidden;
}

.embedded-terminal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #e6edf3;
    letter-spacing: -0.01em;
    padding-left: 28px;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

/* Traffic light dots via the existing <i> element */
.embedded-terminal-title i {
    width: 10px;
    height: 10px;
    color: transparent !important;
    font-size: 0 !important;
    background: #3fb950;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
}

.embedded-terminal-title i::before,
.embedded-terminal-title i::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    top: 0;
}

.embedded-terminal-title i::before {
    background: #f0883e;
    left: -16px;
}

.embedded-terminal-title i::after {
    background: #f85149;
    left: -32px;
}

/* --- Embedded Terminal Header Right Section --- */
.embedded-terminal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Status indicator */
.embedded-terminal-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #8b949e;
    font-weight: 400;
}

/* --- Embedded Terminal Window Controls --- */
.embedded-terminal-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.et-control-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: #6e7681;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 11px;
    padding: 0;
}

.et-control-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #c9d1d9;
}

/* Mobile back button - hidden on desktop */
.et-mobile-back-btn {
    display: none !important;
}

.et-control-btn.et-close-btn:hover {
    background: rgba(210, 153, 34, 0.15);
    color: #d2991f;
}

.et-control-btn.et-maximize-btn:hover {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
}

.et-control-btn.et-fullscreen-btn:hover {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
}

.embedded-terminal-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.embedded-terminal-status .status-dot.running {
    background: #3fb950;
    animation: statusPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(63, 185, 80, 0.4);
}

.embedded-terminal-status .status-dot.completed {
    background: #58a6ff;
    animation: none;
}

.embedded-terminal-status .status-dot.error {
    background: #f85149;
    animation: none;
}

.embedded-terminal-status .status-dot.cancelled {
    background: #f0883e;
    animation: none;
}

.embedded-terminal-status .status-dot.interrupted {
    background: #a371f7;
    animation: none;
}

.embedded-terminal-status .status-dot.detached {
    background: #8b949e;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* --- Terminal Body --- */
.embedded-terminal-body {
    padding: 14px 16px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 12.5px;
    line-height: 1.7;
    color: #c9d1d9;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    direction: ltr !important;
    text-align: left !important;
    word-break: break-word;
    background: #1a1f2e;
}

.embedded-terminal-body::-webkit-scrollbar { width: 5px; }
.embedded-terminal-body::-webkit-scrollbar-track { background: transparent; }
.embedded-terminal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}
.embedded-terminal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Terminal Entry (each command block) --- */
.terminal-entry {
    margin-bottom: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    animation: entrySlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: background 0.2s ease;
}

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

@keyframes entrySlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.terminal-entry-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    min-width: 0;
    overflow: hidden;
}

.terminal-entry-prompt {
    color: #39d353;
    font-weight: 700;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(57, 211, 83, 0.15);
}

/* Inline command displayed next to prompt (like a real terminal) */
.terminal-entry-cmd-inline {
    color: #f0f6fc;
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
    font-size: 12px;
    font-weight: 500;
    word-break: break-all;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr !important;
    text-align: left !important;
    max-width: 100%;
}

/* Execution info row (badge + target) */
.terminal-entry-exec-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 2px 0;
    padding-left: 2px;
    min-width: 0;
    overflow: hidden;
}

.terminal-exec-badge {
    background: rgba(88, 166, 255, 0.08);
    color: #58a6ff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid rgba(88, 166, 255, 0.12);
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.terminal-exec-badge.quantum {
    background: rgba(139, 92, 246, 0.08);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.12);
}

.terminal-exec-target {
    color: #8b949e;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Commands block (multiple commands) */
.terminal-commands-block {
    margin: 6px 0;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 2px solid rgba(63, 185, 80, 0.3);
    overflow-x: auto;
    max-width: 100%;
}

.terminal-cmd-line {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 11.5px;
    color: #c9d1d9;
    padding: 2px 0;
    direction: ltr !important;
    text-align: left !important;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-cmd-prefix {
    color: #3fb950;
    font-weight: 600;
    margin-right: 6px;
}

/* OLD: keeping for backwards compat but hiding */
.terminal-entry-tool {
    display: none;
}

.terminal-entry-command {
    display: none;
}

.terminal-entry-timestamp {
    color: rgba(255, 255, 255, 0.25);
    font-size: 10px;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Multi-command display (legacy) */
.terminal-entry-command .multi-command {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
}
.terminal-entry-command .multi-command:last-child { border-bottom: none; }
.terminal-entry-command .multi-command::before {
    content: "$ ";
    color: #3fb950;
    font-weight: 600;
}

/* --- Terminal Entry Output --- */
.terminal-entry-output {
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    border-left: 3px solid rgba(255, 255, 255, 0.1);
    white-space: pre-wrap;
    word-break: break-word;
    color: #8b949e;
    direction: ltr !important;
    text-align: left !important;
    font-size: 12px;
    line-height: 1.6;
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
}

.terminal-entry-output.success,
.terminal-entry-output.terminal-status-completed,
.terminal-entry-output.terminal-status-success {
    border-left-color: #39d353;
    color: #56d364;
    background: rgba(57, 211, 83, 0.06);
}

.terminal-entry-output.error,
.terminal-entry-output.terminal-status-failed,
.terminal-entry-output.terminal-status-error {
    border-left-color: #f85149;
    color: #ff7b72;
    background: rgba(248, 81, 73, 0.08);
}

.terminal-entry-output.warning {
    border-left-color: #e3b341;
    color: #e3b341;
    background: rgba(227, 179, 65, 0.06);
}

.terminal-entry-output.terminal-status-running,
.terminal-entry-output.terminal-status-pending {
    border-left-color: #58a6ff;
    color: #79c0ff;
    background: rgba(88, 166, 255, 0.06);
}

.terminal-entry-output.skipped {
    border-left-color: #d29922;
    color: #e3b341;
    background: rgba(210, 153, 34, 0.06);
}

/* --- Expandable Output --- */
.terminal-output-expandable {
    margin-top: 8px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid rgba(255, 255, 255, 0.1);
}

.terminal-output-expandable.success { border-left-color: #3fb950; }
.terminal-output-expandable.success .terminal-output-text { color: #3fb950; }
.terminal-output-expandable.error { border-left-color: #f85149; }
.terminal-output-expandable.error .terminal-output-text { color: #f85149; }

.terminal-output-expandable .terminal-output-text {
    margin: 0;
    padding: 10px 12px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #8b949e;
    background: transparent;
    direction: ltr !important;
    text-align: left !important;
}

.terminal-output-expandable .terminal-output-preview { display: block; }
.terminal-output-expandable .terminal-output-full { display: none; max-height: 400px; overflow-y: auto; }
.terminal-output-expandable:not(.collapsed) .terminal-output-preview { display: none; }
.terminal-output-expandable:not(.collapsed) .terminal-output-full { display: block; }

.terminal-output-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #58a6ff;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
    transition: all 0.15s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(88, 166, 255, 0.04);
}

.terminal-output-toggle:hover { background: rgba(88, 166, 255, 0.08); }
.terminal-output-toggle .toggle-icon { font-size: 10px; transition: transform 0.2s ease; }
.terminal-output-expandable:not(.collapsed) .toggle-icon { transform: rotate(90deg); }
.terminal-output-toggle .toggle-text-expand { display: inline; }
.terminal-output-toggle .toggle-text-collapse { display: none; }
.terminal-output-expandable:not(.collapsed) .toggle-text-expand { display: none; }
.terminal-output-expandable:not(.collapsed) .toggle-text-collapse { display: inline; }

/* --- Running Indicator --- */
.terminal-running-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: #8b949e;
    font-size: 12px;
}

.terminal-running-dots {
    display: flex;
    gap: 4px;
}

.terminal-running-dots span {
    width: 5px;
    height: 5px;
    background: #3fb950;
    border-radius: 50%;
    animation: terminalDot 1.4s infinite;
}

.terminal-running-dots span:nth-child(2) { animation-delay: 0.2s; }
.terminal-running-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes terminalDot {
    0%, 60%, 100% { transform: scale(0.6); opacity: 0.3; }
    30% { transform: scale(1.2); opacity: 1; }
}

/* --- Cursor blink animation for running state --- */
.terminal-typing-effect {
    display: inline-flex;
    align-items: center;
}

.terminal-cursor {
    color: #3fb950;
    font-size: 14px;
    animation: cursorBlink 1s step-end infinite;
    line-height: 1;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.terminal-running-text {
    color: #8b949e;
    font-size: 12px;
}

/* --- Progress Bar --- */
.terminal-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.04);
    position: relative;
    overflow: hidden;
    transition: opacity 0.5s ease;
}

.terminal-progress-bar.fade-out {
    opacity: 0;
    height: 0;
    transition: opacity 0.5s ease, height 0.3s ease 0.5s;
}

.terminal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3fb950, #58a6ff);
    border-radius: 0 2px 2px 0;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.terminal-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShimmer 2s infinite;
}

.terminal-progress-fill.completed {
    background: linear-gradient(90deg, #3fb950, #2ea043);
}

.terminal-progress-fill.completed::after {
    animation: none;
    display: none;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* --- Entry Highlight (live view) --- */
.terminal-entry.entry-highlight {
    background: rgba(63, 185, 80, 0.08);
    border-color: rgba(63, 185, 80, 0.2);
    box-shadow: 0 0 12px rgba(63, 185, 80, 0.06);
    transition: all 0.5s ease;
}

/* Live View Mode */
.embedded-terminal.et-live-mode .embedded-terminal-body {
    scroll-behavior: smooth;
}

.embedded-terminal.et-live-mode .terminal-entry:last-child {
    border-color: rgba(63, 185, 80, 0.15);
}

/* --- Live Button Styles --- */
.et-live-btn {
    position: relative;
}

.et-live-btn.active {
    color: #3fb950 !important;
    border-color: rgba(63, 185, 80, 0.3) !important;
    background: rgba(63, 185, 80, 0.08) !important;
}

.et-live-btn.active::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #3fb950;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.6); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(63, 185, 80, 0); }
}

/* --- Replay Button Styles --- */
.et-replay-btn {
    position: relative;
}

.et-replay-btn.replaying {
    color: #f85149 !important;
    border-color: rgba(248, 81, 73, 0.3) !important;
    background: rgba(248, 81, 73, 0.08) !important;
}

.completed-bar .terminal-progress-fill {
    transition: width 0.4s ease;
}

/* --- Footer --- */
.embedded-terminal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #232839;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: #8b949e;
    font-family: 'JetBrains Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.embedded-terminal-stats {
    display: flex;
    gap: 16px;
}

.embedded-terminal-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.embedded-terminal-stats strong { color: #c9d1d9; font-weight: 600; }
.embedded-terminal-stats i { font-size: 10px; color: #6e7681; }

.embedded-terminal-actions { display: flex; gap: 8px; }

.embedded-terminal-action-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8b949e;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
}

.embedded-terminal-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- AI Reasoning Section --- */
.terminal-reasoning-container {
    margin: 8px 0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(88, 166, 255, 0.04);
    border: 1px solid rgba(88, 166, 255, 0.1);
    transition: all 0.2s ease;
}

.terminal-reasoning-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #58a6ff;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
    transition: all 0.15s ease;
}

.terminal-reasoning-toggle:hover { background: rgba(88, 166, 255, 0.08); }
.terminal-reasoning-toggle .toggle-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
    color: #58a6ff;
}

.terminal-reasoning-container:not(.collapsed) .toggle-icon { transform: rotate(90deg); }
.terminal-reasoning-container.collapsed .toggle-text::before { content: "Show "; }
.terminal-reasoning-container:not(.collapsed) .toggle-text::before { content: "Hide "; }

.terminal-reasoning-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.2s ease;
}

.terminal-reasoning-container:not(.collapsed) .terminal-reasoning-content {
    max-height: 500px;
    padding: 0 12px 12px 12px;
}

.terminal-reasoning-text {
    color: #8b949e;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid #58a6ff;
    font-style: italic;
}

/* --- Quantum Tool Styling --- */
.terminal-entry.quantum .terminal-entry-tool {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.15);
}

.terminal-entry.quantum .terminal-entry-prompt { color: #a78bfa; }
.terminal-entry.quantum .terminal-entry-cmd-inline { color: #c4b5fd; }
.terminal-entry.quantum .terminal-cursor { color: #a78bfa; }

/* --- Collapse / Expand / Maximize States --- */

/* Collapsed: body + footer hidden, only header visible */
.embedded-terminal.et-collapsed .embedded-terminal-body {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease;
    opacity: 0;
}

.embedded-terminal.et-collapsed .embedded-terminal-footer {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
    border-top: none;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.2s ease;
    opacity: 0;
}

.embedded-terminal.et-collapsed .terminal-progress-bar {
    height: 0;
    opacity: 0;
}

/* Icon is toggled via JS - no CSS content override needed */

/* Normal expanded state transition */
.embedded-terminal .embedded-terminal-body {
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    opacity: 1;
}

.embedded-terminal .embedded-terminal-footer {
    max-height: 100px;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    opacity: 1;
}

/* Maximized: right panel — NOT fullscreen, shares screen with chat */
.embedded-terminal.et-maximized {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 38%;
    min-width: 340px;
    max-width: 720px;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1050;
    animation: etSlideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.embedded-terminal.et-maximized .embedded-terminal-body {
    max-height: none;
    flex: 1;
    overflow-y: auto;
}

.embedded-terminal.et-maximized .embedded-terminal-footer {
    max-height: none;
    flex-shrink: 0;
}

/* Push chat container when terminal panel is open (desktop) */
/* FIXED: Use min() to sync with terminal max-width */
body.terminal-panel-open .chat-container {
    margin-right: min(38%, 720px);
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
}

body:not(.terminal-panel-open) .chat-container {
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Force all children to fit inside the squeezed chat area */
body.terminal-panel-open .message {
    max-width: 100%;
    box-sizing: border-box;
}

body.terminal-panel-open .message-content {
    max-width: 100%;
    min-width: 0;
}

body.terminal-panel-open .message-text {
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

body.terminal-panel-open .chat-reasoning-card {
    max-width: 100%;
    box-sizing: border-box;
}

body.terminal-panel-open .terminal-mini-bar {
    max-width: 100%;
    box-sizing: border-box;
}

body.terminal-panel-open .mini-bar-approval {
    max-width: 100%;
    box-sizing: border-box;
}

body.terminal-panel-open .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    max-width: 100%;
}

body.terminal-panel-open .terminal-entry.approval-entry {
    max-width: 100%;
}

body.terminal-panel-open #chat-form,
body.terminal-panel-open .chat-form {
    max-width: 100%;
    box-sizing: border-box;
}

body.terminal-panel-open .chat-input-container {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* ===== FULLSCREEN CENTER MODE ===== */
.embedded-terminal.et-fullscreen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 1100px;
    height: 85vh;
    max-height: 900px;
    margin: 0;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 2050;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: etFullscreenIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.embedded-terminal.et-fullscreen .embedded-terminal-body {
    max-height: none;
    flex: 1;
    overflow-y: auto;
}

.embedded-terminal.et-fullscreen .embedded-terminal-footer {
    max-height: none;
    flex-shrink: 0;
}

body.terminal-fullscreen-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2049;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes etFullscreenIn {
    from { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== CHAT AI REASONING CARD ===== */
.chat-reasoning-card {
    margin: 8px 0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.04), rgba(59, 130, 246, 0.02));
    border: 1px solid rgba(139, 92, 246, 0.12);
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 50rem;
    width: 100%;
    align-self: stretch;
    box-sizing: border-box;
    min-height: 62px;
    opacity: 0.85;
}

/* Collapsed card - subtle styling */
.chat-reasoning-card:not(.expanded) {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.03), rgba(59, 130, 246, 0.02));
    border-color: rgba(139, 92, 246, 0.08);
}

/* Expanded (latest) card - prominent styling */
.chat-reasoning-card.expanded {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(59, 130, 246, 0.05));
    border-color: rgba(139, 92, 246, 0.25);
    opacity: 1;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.15);
}

/* Collapsed cards show step indicator */
.chat-reasoning-card:not(.expanded)::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(139, 92, 246, 0.3);
    border-radius: 12px 0 0 12px;
}

.chat-reasoning-card {
    position: relative;
}

.chat-reasoning-card.expanded::before {
    background: linear-gradient(to bottom, #8b5cf6, #6366f1);
}

.chat-reasoning-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    min-height: 44px;
}

.chat-reasoning-header:hover {
    background: rgba(139, 92, 246, 0.08);
}

.chat-reasoning-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-reasoning-icon i {
    color: #fff;
    font-size: 13px;
}

.chat-reasoning-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-reasoning-label {
    font-size: 12px;
    font-weight: 600;
    color: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-reasoning-tool {
    font-size: 13px;
    color: var(--text-secondary, #8b949e);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reasoning-toggle-icon {
    color: var(--text-secondary, #8b949e);
    transition: transform 0.3s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.chat-reasoning-card.expanded .chat-reasoning-toggle-icon {
    transform: rotate(180deg);
}

.chat-reasoning-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    padding: 0 14px;
}

.chat-reasoning-card.expanded .chat-reasoning-body {
    max-height: 400px;
    padding: 0 14px 12px;
    overflow-y: auto;
}

.chat-reasoning-text {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary, #8b949e);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border-left: 3px solid #8b5cf6;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .chat-reasoning-card {
        margin: 8px 0;
        max-width: 100%;
    }

    .chat-reasoning-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .chat-reasoning-icon {
        width: 24px;
        height: 24px;
    }

    .chat-reasoning-icon i {
        font-size: 12px;
    }

    .chat-reasoning-body {
        padding: 0 12px;
    }

    .chat-reasoning-card.expanded .chat-reasoning-body {
        max-height: 280px;
        padding: 0 12px 10px;
    }

    .chat-reasoning-text {
        font-size: 12.5px;
        line-height: 1.65;
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .chat-reasoning-header {
        padding: 9px 10px;
    }

    .chat-reasoning-label {
        font-size: 11px;
    }

    .chat-reasoning-tool {
        font-size: 12px;
    }

    .chat-reasoning-card.expanded .chat-reasoning-body {
        max-height: 240px;
    }
}

/* Light theme */
.light .chat-reasoning-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(59, 130, 246, 0.03));
    border-color: rgba(139, 92, 246, 0.2);
}

.light .chat-reasoning-text {
    background: rgba(139, 92, 246, 0.04);
    color: #57606a;
}

.light .chat-reasoning-header:hover {
    background: rgba(139, 92, 246, 0.06);
}

/* Light theme fullscreen */
.light .embedded-terminal.et-fullscreen {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.light body.terminal-fullscreen-open::after,
body.light.terminal-fullscreen-open::after {
    background: rgba(255, 255, 255, 0.6);
}

/* RTL support for reasoning card */
[dir="rtl"] .chat-reasoning-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .chat-reasoning-title {
    text-align: right;
}

[dir="rtl"] .chat-reasoning-text {
    border-left: none;
    border-right: 3px solid #8b5cf6;
    text-align: right;
}

[dir="rtl"] .chat-reasoning-card {
    margin-right: auto;
    margin-left: auto;
}

@keyframes etSlideInRight {
    from { transform: translateX(100%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes etSlideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Close animation */
.embedded-terminal.et-closing {
    animation: etCloseOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes etCloseOut {
    from { opacity: 1; transform: scale(1); max-height: 600px; }
    to { opacity: 0; transform: scale(0.95); max-height: 0; margin: 0; padding: 0; border-width: 0; }
}

/* Legacy collapsed class (backwards compat) */
.embedded-terminal.collapsed .embedded-terminal-body {
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.embedded-terminal.collapsed .embedded-terminal-body::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, transparent, #1a1f2e);
    pointer-events: none;
}

/* --- Light Theme --- */
.light .embedded-terminal {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.light .embedded-terminal-header {
    background: #f6f8fa;
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.light .embedded-terminal-title { color: #24292f; }
.light .embedded-terminal-title i {
    background: #1a7f37;
}
.light .embedded-terminal-title i::before { background: #bf8700; }
.light .embedded-terminal-title i::after { background: #cf222e; }

.light .embedded-terminal-body { color: #24292f; background: #ffffff; }

.light .terminal-entry {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}
.light .terminal-entry:hover { background: rgba(0, 0, 0, 0.04); }
.light .terminal-entry-prompt { color: #1a7f37; }
.light .terminal-entry-cmd-inline { color: #24292f; }
.light .terminal-exec-badge {
    background: rgba(9, 105, 218, 0.06);
    color: #0969da;
    border-color: rgba(9, 105, 218, 0.12);
}
.light .terminal-exec-target { color: #57606a; }
.light .terminal-commands-block {
    background: rgba(0, 0, 0, 0.03);
    border-left-color: rgba(26, 127, 55, 0.3);
}
.light .terminal-cmd-line { color: #24292f; }
.light .terminal-cmd-prefix { color: #1a7f37; }
.light .terminal-cursor { color: #1a7f37; }
.light .terminal-running-text { color: #57606a; }
.light .terminal-progress-fill { background: linear-gradient(90deg, #1a7f37, #0969da); }
.light .terminal-progress-fill.completed { background: linear-gradient(90deg, #1a7f37, #2da44e); }
.light .terminal-progress-bar { background: rgba(0, 0, 0, 0.06); }
.light .terminal-entry.entry-highlight {
    background: rgba(26, 127, 55, 0.06);
    border-color: rgba(26, 127, 55, 0.15);
}
.light .et-live-btn.active {
    color: #1a7f37 !important;
    border-color: rgba(26, 127, 55, 0.3) !important;
    background: rgba(26, 127, 55, 0.06) !important;
}
.light .et-live-btn.active::before { background: #1a7f37; }
.light .terminal-entry-tool {
    background: rgba(9, 105, 218, 0.08);
    color: #0969da;
    border-color: rgba(9, 105, 218, 0.15);
}
.light .terminal-entry-command { color: #24292f; }
.light .terminal-entry-timestamp { color: rgba(0, 0, 0, 0.3); }

.light .terminal-entry-output {
    background: rgba(0, 0, 0, 0.03);
    border-left-color: rgba(0, 0, 0, 0.1);
    color: #57606a;
}
.light .terminal-entry-output.success,
.light .terminal-entry-output.terminal-status-completed,
.light .terminal-entry-output.terminal-status-success {
    border-left-color: #1a7f37;
    color: #1a7f37;
    background: rgba(26, 127, 55, 0.04);
}
.light .terminal-entry-output.error,
.light .terminal-entry-output.terminal-status-failed,
.light .terminal-entry-output.terminal-status-error {
    border-left-color: #cf222e;
    color: #cf222e;
    background: rgba(207, 34, 46, 0.04);
}

.light .terminal-output-expandable {
    background: rgba(0, 0, 0, 0.03);
    border-left-color: rgba(0, 0, 0, 0.1);
}
.light .terminal-output-expandable.success { border-left-color: #1a7f37; }
.light .terminal-output-expandable.success .terminal-output-text { color: #1a7f37; }
.light .terminal-output-expandable.error { border-left-color: #cf222e; }
.light .terminal-output-expandable.error .terminal-output-text { color: #cf222e; }
.light .terminal-output-expandable .terminal-output-text { color: #57606a; }

.light .terminal-output-toggle {
    color: #0969da;
    background: rgba(9, 105, 218, 0.04);
    border-top-color: rgba(0, 0, 0, 0.06);
}
.light .terminal-output-toggle:hover { background: rgba(9, 105, 218, 0.08); }
.light .terminal-output-toggle .toggle-icon { color: #0969da; }

.light .embedded-terminal-footer {
    background: #f6f8fa;
    border-top-color: rgba(0, 0, 0, 0.08);
}
.light .embedded-terminal-stats strong { color: #24292f; }
.light .embedded-terminal-action-btn {
    border-color: rgba(0, 0, 0, 0.1);
    color: #57606a;
}
.light .embedded-terminal-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #24292f;
}

/* Light theme window controls */
.light .embedded-terminal-controls {
    border-left-color: rgba(0, 0, 0, 0.08);
}
.light .et-control-btn {
    color: #8b949e;
}
.light .et-control-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #24292f;
}
.light .et-control-btn.et-close-btn:hover {
    background: rgba(210, 153, 34, 0.1);
    color: #9a6700;
}
.light .et-control-btn.et-maximize-btn:hover {
    background: rgba(9, 105, 218, 0.1);
    color: #0969da;
}
.light .et-control-btn.et-fullscreen-btn:hover {
    background: rgba(31, 136, 61, 0.1);
    color: #1a7f37;
}

.light .terminal-reasoning-container {
    background: rgba(9, 105, 218, 0.04);
    border-color: rgba(9, 105, 218, 0.12);
}
.light .terminal-reasoning-toggle { color: #0969da; }
.light .terminal-reasoning-toggle:hover { background: rgba(9, 105, 218, 0.08); }
.light .terminal-reasoning-toggle .toggle-icon { color: #0969da; }
.light .terminal-reasoning-text {
    color: #57606a;
    background: rgba(0, 0, 0, 0.02);
    border-left-color: #0969da;
}

.light .embedded-terminal.collapsed .embedded-terminal-body::after {
    background: linear-gradient(to bottom, transparent, var(--bg-primary, #f8f9fb));
}

/* --- RTL Support for Embedded Terminal --- */
[dir="rtl"] .embedded-terminal-title { padding-left: 0; padding-right: 28px; }
[dir="rtl"] .embedded-terminal-title i::before { left: auto; right: -16px; }
[dir="rtl"] .embedded-terminal-title i::after { left: auto; right: -32px; }
[dir="rtl"] .terminal-entry-timestamp { margin-left: 0; margin-right: auto; }
[dir="rtl"] .terminal-reasoning-toggle { flex-direction: row-reverse; }
[dir="rtl"] .embedded-terminal-controls {
    margin-left: 0;
    margin-right: 8px;
    padding-left: 0;
    padding-right: 8px;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.light[dir="rtl"] .embedded-terminal-controls {
    border-right-color: rgba(0, 0, 0, 0.08);
}
[dir="rtl"] .terminal-reasoning-text {
    border-left: none;
    border-right: 3px solid #58a6ff;
    text-align: right;
}
.light[dir="rtl"] .terminal-reasoning-text { border-right-color: #0969da; }
[dir="rtl"] .terminal-entry-output {
    border-left: none;
    border-right: 3px solid rgba(255, 255, 255, 0.1);
}
[dir="rtl"] .terminal-entry-output.success,
[dir="rtl"] .terminal-entry-output.terminal-status-completed,
[dir="rtl"] .terminal-entry-output.terminal-status-success { border-right-color: #3fb950; }
[dir="rtl"] .terminal-entry-output.error,
[dir="rtl"] .terminal-entry-output.terminal-status-failed,
[dir="rtl"] .terminal-entry-output.terminal-status-error { border-right-color: #f85149; }
[dir="rtl"] .terminal-output-expandable {
    border-left: none;
    border-right: 3px solid rgba(255, 255, 255, 0.1);
}
[dir="rtl"] .terminal-output-expandable.success { border-right-color: #3fb950; }
[dir="rtl"] .terminal-output-expandable.error { border-right-color: #f85149; }
.light[dir="rtl"] .terminal-entry-output {
    border-right-color: rgba(0, 0, 0, 0.1);
}
.light[dir="rtl"] .terminal-entry-output.success,
.light[dir="rtl"] .terminal-entry-output.terminal-status-completed { border-right-color: #1a7f37; }
.light[dir="rtl"] .terminal-entry-output.error,
.light[dir="rtl"] .terminal-entry-output.terminal-status-failed { border-right-color: #cf222e; }

/* --- Responsive for Embedded Terminal --- */

/* ===== LARGE DESKTOP (1441px - 1919px) — generous panel width ===== */
@media (min-width: 1441px) and (max-width: 1919px) {
    .embedded-terminal.et-maximized {
        width: 36%;
        max-width: 760px;
    }

    body.terminal-panel-open .chat-container {
        margin-right: min(36%, 760px);
    }

    body.terminal-panel-open .message,
    body.terminal-panel-open .chat-reasoning-card,
    body.terminal-panel-open #chat-form,
    body.terminal-panel-open .terminal-mini-bar,
    body.terminal-panel-open .mini-bar-approval {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* ===== FULL HD DESKTOP (1920px - 2559px) ===== */
@media (min-width: 1920px) and (max-width: 2559px) {
    .embedded-terminal.et-maximized {
        width: 32%;
        max-width: 800px;
    }

    body.terminal-panel-open .chat-container {
        margin-right: min(32%, 800px);
    }

    /* Center chat content on large screens */
    .chat-messages {
        max-width: 1100px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 24px;
        padding-right: 24px;
    }

    body.terminal-panel-open .message,
    body.terminal-panel-open .chat-reasoning-card {
        max-width: 100%;
    }
}

/* ===== 2K/QHD DESKTOP (2560px+) ===== */
@media (min-width: 2560px) {
    .embedded-terminal.et-maximized {
        width: 28%;
        max-width: 900px;
    }

    body.terminal-panel-open .chat-container {
        margin-right: min(28%, 900px);
    }

    /* Larger content area on ultra-wide */
    .chat-messages {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 32px;
        padding-right: 32px;
    }

    .message {
        max-width: 56rem; /* Slightly larger messages */
    }

    .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
        max-width: 56rem;
    }

    .chat-reasoning-card {
        max-width: 56rem;
    }
}

/* ===== STANDARD DESKTOP (1201px - 1440px) ===== */
@media (min-width: 1201px) and (max-width: 1440px) {
    .embedded-terminal.et-maximized {
        width: 36%;
        max-width: 520px;
    }

    body.terminal-panel-open .chat-container {
        margin-right: min(36%, 520px);
    }

    body.terminal-panel-open .message,
    body.terminal-panel-open .chat-reasoning-card,
    body.terminal-panel-open #chat-form {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* ===== SMALL DESKTOP / TABLET LANDSCAPE (1025px - 1200px) ===== */
@media (min-width: 1025px) and (max-width: 1200px) {
    .embedded-terminal.et-maximized {
        width: 36%;
        min-width: 320px;
        max-width: 440px;
    }

    body.terminal-panel-open .chat-container {
        margin-right: 36%;
    }

    body.terminal-panel-open .message,
    body.terminal-panel-open .chat-reasoning-card,
    body.terminal-panel-open #chat-form,
    body.terminal-panel-open .terminal-mini-bar,
    body.terminal-panel-open .mini-bar-approval {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Compact footer on smaller desktops */
    .embedded-terminal-footer {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 14px;
    }

    .embedded-terminal-stats {
        gap: 10px;
        font-size: 10px;
    }

    .embedded-terminal-actions {
        gap: 6px;
    }

    .embedded-terminal-action-btn {
        padding: 4px 10px;
        font-size: 10px;
    }

    /* Tighter entry spacing */
    .terminal-entry {
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    .terminal-entry-cmd-inline {
        font-size: 11.5px;
    }

    .terminal-exec-badge {
        font-size: 9px;
        padding: 1px 6px;
    }

    .terminal-exec-target {
        font-size: 10px;
    }

    .terminal-cmd-line {
        font-size: 11px;
    }
}

/* ===== TABLET PORTRAIT (769px - 1024px) — overlay panel, no push ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .embedded-terminal.et-maximized {
        width: 50%;
        min-width: 320px;
        max-width: 500px;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    }

    /* Don't push the chat — panel overlays */
    body.terminal-panel-open .chat-container {
        margin-right: 0 !important;
    }

    .embedded-terminal-footer {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 12px;
    }

    .embedded-terminal-stats {
        gap: 8px;
        font-size: 10px;
    }

    .embedded-terminal-stats span {
        gap: 3px;
    }

    .embedded-terminal-action-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .terminal-entry {
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    .terminal-entry-prompt {
        font-size: 11px;
    }

    .terminal-entry-cmd-inline {
        font-size: 11px;
    }

    .terminal-entry-exec-info {
        gap: 6px;
    }

    .terminal-exec-badge {
        font-size: 9px;
        padding: 1px 6px;
    }

    .terminal-exec-target {
        font-size: 10px;
    }

    .terminal-commands-block {
        padding: 5px 8px;
    }

    .terminal-cmd-line {
        font-size: 10.5px;
    }

    /* Fullscreen adjusts for tablet */
    .embedded-terminal.et-fullscreen {
        width: 95vw;
        max-width: none;
        height: 85vh;
    }

    .chat-reasoning-card {
        max-width: 90%;
    }
}

/* ===== MOBILE (≤768px) ===== */
@media (max-width: 768px) {
    .embedded-terminal { margin: 12px 0; border-radius: 10px; }
    .embedded-terminal-header { padding: 10px 14px; }
    .embedded-terminal-title { font-size: 12px; }
    .embedded-terminal-body { padding: 10px 14px; max-height: 280px; font-size: 11.5px; }
    .terminal-entry { padding: 8px 10px; }
    .embedded-terminal-footer {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 8px 14px;
    }
    .embedded-terminal-stats { flex-wrap: wrap; gap: 10px; }

    /* Mobile back button */
    .et-mobile-back-btn {
        display: flex !important;
        align-items: center;
        gap: 6px;
        background: rgba(88, 166, 255, 0.1);
        color: #58a6ff;
        border: 1px solid rgba(88, 166, 255, 0.2);
        border-radius: 8px;
        padding: 6px 12px;
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
        margin-right: 8px;
        width: auto;
        height: auto;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    }
    
    .et-mobile-back-btn:hover {
        background: rgba(88, 166, 255, 0.2);
    }
    
    .et-mobile-back-btn span {
        font-size: 12px;
    }
    
    .light .et-mobile-back-btn {
        background: rgba(9, 105, 218, 0.08);
        color: #0969da;
        border-color: rgba(9, 105, 218, 0.2);
    }

    /* Mobile: panel opens as fullscreen overlay */
    .embedded-terminal.et-maximized {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        min-width: unset;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        border-left: none;
        border-bottom: none;
        border-radius: 0;
        animation: etSlideInTop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1100;
    }

    /* Chat stays in place - terminal overlays it */
    body.terminal-panel-open .chat-container {
        margin-right: 0 !important;
        margin-top: 0 !important;
    }

    body:not(.terminal-panel-open) .chat-container {
        margin-top: 0;
    }

    /* Fullscreen on mobile uses full screen */
    .embedded-terminal.et-fullscreen {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        top: 50%;
        left: 50%;
    }

    .chat-reasoning-card {
        max-width: 95%;
    }

    @keyframes etSlideInTop {
        from { transform: translateY(-100%); opacity: 0.5; }
        to { transform: translateY(0); opacity: 1; }
    }
}

/* ===== SMALL MOBILE (≤480px) ===== */
@media (max-width: 480px) {
    .embedded-terminal { margin: 8px 0; border-radius: 8px; }
    .embedded-terminal-header { padding: 8px 12px; }
    .embedded-terminal-title { font-size: 11px; gap: 6px; }
    .embedded-terminal-body { padding: 8px 12px; max-height: 220px; font-size: 11px; }
    .terminal-entry { padding: 6px 8px; margin-bottom: 8px; }
    .terminal-entry-prompt { font-size: 10px; }
    .terminal-entry-cmd-inline { font-size: 10px; }
    .terminal-exec-badge { font-size: 8px; padding: 1px 5px; }
    .terminal-exec-target { font-size: 9px; }
    .terminal-entry-output { font-size: 10px; padding: 8px 10px; }
    .terminal-cmd-line { font-size: 10px; }
    .embedded-terminal-footer { padding: 6px 12px; font-size: 10px; }
    .embedded-terminal-stats { gap: 6px; font-size: 9px; }
    .embedded-terminal-stats i { font-size: 9px; }
    .embedded-terminal-action-btn { padding: 3px 8px; font-size: 10px; }
    
    /* Hide some controls to save space */
    .embedded-terminal-controls .et-fullscreen-btn { display: none; }
    .embedded-terminal-actions .et-live-btn span { display: none; }
    
    /* Status text */
    .embedded-terminal-status .status-text { display: none; }
    
    /* Terminal panel on very small screens is fullscreen */
    .embedded-terminal.et-maximized { height: 100vh; height: 100dvh; }
    body.terminal-panel-open .chat-container { margin-top: 0 !important; }
}

/* =============================================================================
   SECTION 1B: TERMINAL MINI-BAR (Above Input Field)
   ============================================================================= */

/* Mini terminal bar — small floating bar above the chat input */
.terminal-mini-bar {
    display: none; /* hidden by default, shown by JS */
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin: 0 auto 4px;
    max-width: 50rem;
    background: #1a1f2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    color: #8b949e;
    user-select: none;
    animation: miniBarSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.terminal-mini-bar.visible {
    display: flex;
}

@keyframes miniBarSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.terminal-mini-bar:hover {
    background: #232839;
    border-color: rgba(255, 255, 255, 0.12);
}

.terminal-mini-bar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3fb950;
    flex-shrink: 0;
    animation: statusPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.3);
}

.terminal-mini-bar-dot.completed {
    background: #58a6ff;
    animation: none;
}

.terminal-mini-bar-dot.error {
    background: #f85149;
    animation: none;
}

.terminal-mini-bar-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.terminal-mini-bar-title {
    color: #e6edf3;
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

.terminal-mini-bar-status {
    color: #8b949e;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terminal-mini-bar-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #6e7681;
}

.terminal-mini-bar-stats i {
    font-size: 10px;
    margin-right: 3px;
}

.terminal-mini-bar-stats strong {
    color: #c9d1d9;
    font-weight: 600;
}

.terminal-mini-bar-expand {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #58a6ff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-weight: 500;
}

.terminal-mini-bar-expand:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: rgba(88, 166, 255, 0.3);
}

/* Mini-bar light theme */
.light .terminal-mini-bar {
    background: #f8f9fb;
    border-color: rgba(0, 0, 0, 0.08);
}
.light .terminal-mini-bar:hover {
    background: #f0f2f5;
    border-color: rgba(0, 0, 0, 0.12);
}
.light .terminal-mini-bar-title { color: #24292f; }
.light .terminal-mini-bar-status { color: #57606a; }
.light .terminal-mini-bar-stats { color: #8b949e; }
.light .terminal-mini-bar-stats strong { color: #24292f; }
.light .terminal-mini-bar-dot { background: #1a7f37; }
.light .terminal-mini-bar-dot.completed { background: #0969da; }
.light .terminal-mini-bar-dot.error { background: #cf222e; }
.light .terminal-mini-bar-expand {
    color: #0969da;
    border-color: rgba(0, 0, 0, 0.1);
}
.light .terminal-mini-bar-expand:hover {
    background: rgba(9, 105, 218, 0.08);
    border-color: rgba(9, 105, 218, 0.25);
}

/* RTL for mini-bar */
[dir="rtl"] .terminal-mini-bar-stats i { margin-right: 0; margin-left: 3px; }

/* Responsive mini-bar */
@media (max-width: 768px) {
    .terminal-mini-bar {
        margin: 0 8px 4px;
        border-radius: 8px 8px 0 0;
        padding: 7px 12px;
    }
    .terminal-mini-bar-stats { display: none; }
}

/* RTL: panel on left side */
[dir="rtl"] .embedded-terminal.et-maximized {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    animation: etSlideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* FIXED: RTL uses min() to sync with terminal max-width */
[dir="rtl"] body.terminal-panel-open .chat-container {
    margin-right: 0;
    margin-left: min(38%, 720px);
}

@keyframes etSlideInLeft {
    from { transform: translateX(-100%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}

/* Light theme panel border */
.light .embedded-terminal.et-maximized {
    background: #ffffff;
    border-left-color: rgba(0, 0, 0, 0.1);
}
.light[dir="rtl"] .embedded-terminal.et-maximized {
    border-right-color: rgba(0, 0, 0, 0.1);
}

/* --- Terminal panel backdrop for mobile --- */
.terminal-panel-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1049;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.terminal-panel-backdrop.visible {
    display: block;
    opacity: 1;
}

/* Show backdrop on tablet when terminal overlays */
@media (min-width: 769px) and (max-width: 1024px) {
    .terminal-panel-backdrop.visible {
        display: block;
    }
}

/* RTL responsive breakpoints */
@media (min-width: 1025px) and (max-width: 1200px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: min(36%, 440px);
        margin-right: 0;
    }
}

/* RTL Standard Desktop (1201px - 1440px) */
@media (min-width: 1201px) and (max-width: 1440px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: min(36%, 520px);
        margin-right: 0;
    }
}

/* RTL Large Desktop (1441px - 1919px) */
@media (min-width: 1441px) and (max-width: 1919px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: min(36%, 760px);
        margin-right: 0;
    }
}

/* RTL Full HD (1920px - 2559px) */
@media (min-width: 1920px) and (max-width: 2559px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: min(32%, 800px);
        margin-right: 0;
    }
}

/* RTL 2K/QHD (2560px+) */
@media (min-width: 2560px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: min(28%, 900px);
        margin-right: 0;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    [dir="rtl"] body.terminal-panel-open .chat-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    [dir="rtl"] .embedded-terminal.et-maximized {
        width: 50%;
        min-width: 320px;
        max-width: 500px;
    }
}
@media (min-width: 769px) {
    .terminal-panel-backdrop { display: none !important; }
}

/* =============================================================================
   SIDEBAR + TERMINAL COMBINED STATES
   Handle cases when both sidebar and terminal panel are open
   ============================================================================= */

/* LTR: Sidebar left + Terminal right */
@media (min-width: 1025px) {
    html[dir="ltr"] body.terminal-panel-open .sidebar.open ~ .chat-container {
        margin-left: 0;
        margin-right: min(38%, 720px);
        width: auto;
    }
    
    html[dir="ltr"] body.terminal-panel-open .sidebar:not(.open) ~ .chat-container {
        margin-left: 0;
        margin-right: min(38%, 720px);
        width: auto;
    }
}

/* RTL: Sidebar right + Terminal left */
@media (min-width: 1025px) {
    html[dir="rtl"] body.terminal-panel-open .sidebar.open ~ .chat-container {
        margin-right: 0;
        margin-left: min(38%, 720px);
        width: auto;
        flex: 1;
    }
    
    html[dir="rtl"] body.terminal-panel-open .sidebar:not(.open) ~ .chat-container {
        margin-right: 0;
        margin-left: min(38%, 720px);
        width: auto;
    }
    
    /* RTL without terminal - sidebar is in flex flow, chat fills remaining space */
    html[dir="rtl"] body:not(.terminal-panel-open) .sidebar.open ~ .chat-container {
        margin-right: 0;
        margin-left: 0;
        width: auto;
        flex: 1;
    }
    
    html[dir="rtl"] body:not(.terminal-panel-open) .sidebar:not(.open) ~ .chat-container {
        margin-right: 0;
        margin-left: 0;
        width: 100%;
    }
}

/* Large screens 1920px+ */
@media (min-width: 1920px) {
    html[dir="rtl"] body.terminal-panel-open .sidebar.open ~ .chat-container {
        margin-left: min(32%, 800px);
    }
    
    html[dir="rtl"] body.terminal-panel-open .sidebar:not(.open) ~ .chat-container {
        margin-left: min(32%, 800px);
    }
}

/* 2K/QHD 2560px+ */
@media (min-width: 2560px) {
    html[dir="rtl"] body.terminal-panel-open .sidebar.open ~ .chat-container {
        margin-left: min(28%, 900px);
    }
    
    html[dir="rtl"] body.terminal-panel-open .sidebar:not(.open) ~ .chat-container {
        margin-left: min(28%, 900px);
    }
}


/* =============================================================================
   SECTION 2: SIDE PANEL TERMINAL
   ============================================================================= */
/* Terminal Interface Styles */
/* Modern Manus-style terminal with clean design */

:root {
    --terminal-bg: #0f0f0f;
    --terminal-text: #00bb00;
    --terminal-header-bg: rgba(255, 255, 255, 0.03);
    --terminal-border: rgba(255, 255, 255, 0.1);
    --terminal-border-dark: rgba(0, 0, 0, 0.3);
    --terminal-prompt: #00bb00;
    --terminal-command: #acacac;
    --terminal-output: #c9d1d9;
    --terminal-error: #ff6b6b;
    --terminal-success: #00bb00;
    --terminal-warning: #f59e0b;
    --terminal-info: #71A3CD;
    --terminal-shadow: rgba(0, 0, 0, 0.15);
    --terminal-blue: #71A3CD;
}

/* Terminal Side Panel Container - Manus-style slide animation */
.terminal-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 0;
    height: 100vh;
    background: var(--bg-card, #ffffff);
    border-left: 1px solid var(--terminal-border-dark);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0.35s,
                box-shadow 0.35s ease;
    opacity: 0;
    visibility: hidden;
}

.terminal-container.open {
    width: 40%;
    opacity: 1;
    visibility: visible;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0s,
                box-shadow 0.35s ease;
}

.terminal-container.maximized {
    width: 60%;
}

/* Side panel minimized to bottom bar */
.terminal-container.minimized {
    width: 0;
    opacity: 0;
    visibility: hidden;
}

/* Side panel overlay backdrop for mobile */
.terminal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.terminal-backdrop.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* RTL Support */
html[dir="rtl"] .terminal-container {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--terminal-border-dark);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

/* Hidden state - deprecated, use !open */
.terminal-overlay {
    display: none;
}

.terminal-overlay.hidden {
    display: none;
}

/* Terminal Window - now just the content wrapper */
.terminal-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    overflow: hidden;
}

/* Terminal window maximized state handled by container */

/* Terminal Header */
.terminal-header {
    background: transparent;
    padding: 16px 16px 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
    cursor: default;
    user-select: none;
}

.terminal-header:active {
    cursor: default;
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    line-height: 22px;
}

.terminal-title i {
    display: none;
}

.terminal-status {
    display: none;
}

.terminal-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.terminal-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--icon-secondary, #6b7280);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 16px;
}

.terminal-btn:hover {
    background: var(--fill-tsp-gray-main, rgba(0, 0, 0, 0.05));
    color: var(--icon-primary, #1f2937);
}

.terminal-btn.close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.terminal-btn.minimize-btn:hover,
.terminal-btn.maximize-btn:hover,
.terminal-btn.clear-btn:hover {
    background: var(--fill-tsp-gray-main, rgba(0, 0, 0, 0.05));
}

/* Chat Container Adjustments */
.chat-container.terminal-open {
    margin-right: 40%;
    transition: margin-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-container.terminal-open.terminal-maximized {
    margin-right: 60%;
}

html[dir="rtl"] .chat-container.terminal-open {
    margin-right: 0;
    margin-left: 40%;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

html[dir="rtl"] .chat-container.terminal-open.terminal-maximized {
    margin-left: 60%;
}

/* Side panel responsiveness for smaller desktops */
@media (min-width: 1025px) and (max-width: 1200px) {
    .terminal-container.open {
        width: 38%;
    }

    .terminal-container.maximized {
        width: 55%;
    }

    .chat-container.terminal-open {
        margin-right: 38%;
    }

    .chat-container.terminal-open.terminal-maximized {
        margin-right: 55%;
    }

    html[dir="rtl"] .chat-container.terminal-open {
        margin-left: 38%;
    }

    html[dir="rtl"] .chat-container.terminal-open.terminal-maximized {
        margin-left: 55%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .terminal-container.open {
        width: 45%;
    }

    .terminal-container.maximized {
        width: 60%;
    }

    /* Overlay mode — don't push chat */
    .chat-container.terminal-open {
        margin-right: 0;
    }

    .chat-container.terminal-open.terminal-maximized {
        margin-right: 0;
    }

    html[dir="rtl"] .chat-container.terminal-open {
        margin-left: 0;
    }

    html[dir="rtl"] .chat-container.terminal-open.terminal-maximized {
        margin-left: 0;
    }

    .terminal-backdrop.visible {
        display: block;
    }
}

/* Terminal Body */
.terminal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    padding: 0 16px 16px 16px;
}

.terminal-output {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--terminal-output);
    scrollbar-width: thin;
    scrollbar-color: var(--terminal-border) transparent;
    background: var(--terminal-bg);
    border-radius: 12px;
    border: 1px solid var(--terminal-border-dark);
    box-shadow: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.05);
}

.terminal-output::-webkit-scrollbar {
    width: 6px;
}

.terminal-output::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-output::-webkit-scrollbar-thumb {
    background: var(--terminal-border);
    border-radius: 3px;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Welcome Message */
.terminal-welcome {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ascii-art {
    display: none;
}

.welcome-text p {
    margin: 6px 0;
    color: var(--terminal-output);
    font-size: 12px;
}

.text-success {
    color: var(--terminal-success);
    font-weight: 600;
}

.text-info {
    color: var(--terminal-info);
    font-weight: 600;
}

.text-warning {
    color: var(--terminal-warning);
    font-weight: 600;
}

/* Terminal Command */
.terminal-command {
    margin: 12px 0;
    animation: slideInLeft 0.2s ease;
}

.command-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.prompt {
    color: var(--terminal-prompt);
    font-weight: 600;
    font-size: 13px;
}

.tool-name {
    color: var(--terminal-output);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.timestamp {
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    margin-left: auto;
}

.command-text {
    color: var(--terminal-command);
    padding-left: 0;
    word-break: break-all;
    font-size: 13px;
}

/* Terminal Output Text */
.terminal-output-text {
    margin: 10px 0;
    padding-left: 20px;
    animation: fadeIn 0.3s ease;
}

.terminal-output-text pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--terminal-output);
}

.terminal-output-text.success pre {
    color: var(--terminal-success);
}

.terminal-output-text.error pre {
    color: var(--terminal-error);
}

.terminal-output-text.warning pre {
    color: var(--terminal-warning);
}

/* System Messages */
.terminal-system-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    padding: 10px 15px;
    border-radius: 6px;
    animation: slideInLeft 0.3s ease;
}

.terminal-system-msg.info {
    background: rgba(97, 175, 239, 0.1);
    border-left: 3px solid var(--terminal-info);
    color: var(--terminal-info);
}

.terminal-system-msg.success {
    background: rgba(152, 195, 121, 0.1);
    border-left: 3px solid var(--terminal-success);
    color: var(--terminal-success);
}

.terminal-system-msg.error {
    background: rgba(224, 108, 117, 0.1);
    border-left: 3px solid var(--terminal-error);
    color: var(--terminal-error);
}

.terminal-system-msg.warning {
    background: rgba(229, 192, 123, 0.1);
    border-left: 3px solid var(--terminal-warning);
    color: var(--terminal-warning);
}

.terminal-system-msg i {
    font-size: 16px;
}

.terminal-system-msg .timestamp {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.7;
}

/* Separator */
.terminal-separator {
    margin: 20px 0;
    text-align: center;
}

.terminal-separator hr {
    border: none;
    border-top: 1px solid var(--terminal-border);
    margin: 0;
}

.terminal-separator span {
    background: var(--terminal-bg);
    padding: 0 15px;
    color: #666;
    font-size: 12px;
    position: relative;
    top: -10px;
}

/* Agent Phase */
.terminal-phase {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    background: rgba(97, 175, 239, 0.1);
    border: 1px solid var(--terminal-info);
    animation: slideInRight 0.3s ease;
}

.terminal-phase.started {
    border-color: var(--terminal-info);
    background: rgba(97, 175, 239, 0.1);
}

.terminal-phase.running {
    border-color: var(--terminal-warning);
    background: rgba(229, 192, 123, 0.1);
}

.terminal-phase.completed {
    border-color: var(--terminal-success);
    background: rgba(152, 195, 121, 0.1);
}

.terminal-phase.failed {
    border-color: var(--terminal-error);
    background: rgba(224, 108, 117, 0.1);
}

.phase-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: bold;
}

.phase-header > i:first-child {
    font-size: 18px;
    color: var(--terminal-info);
}

.phase-name {
    flex: 1;
    color: #fff;
}

.phase-status {
    color: var(--terminal-success);
}

/* Terminal Input Container */
.terminal-input-container {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--terminal-border);
    gap: 10px;
}

.terminal-prompt {
    color: var(--terminal-prompt);
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    font-weight: bold;
    white-space: nowrap;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--terminal-text);
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    padding: 8px;
}

.terminal-input::placeholder {
    color: #666;
    font-style: italic;
}

/* Terminal Footer */
.terminal-footer {
    background: var(--bg-card, #ffffff);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--terminal-border);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    margin: 0;
}

.terminal-stats {
    display: flex;
    gap: 16px;
    color: var(--text-tertiary, #9ca3af);
}

.terminal-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.terminal-stats strong {
    color: var(--text-primary, #1f2937);
    font-weight: 600;
}

.terminal-stats i {
    font-size: 12px;
    color: var(--icon-tertiary, #9ca3af);
}

.terminal-actions {
    display: flex;
    gap: 8px;
}

.terminal-action-btn {
    padding: 6px 12px;
    border: 1px solid var(--terminal-border);
    background: transparent;
    color: var(--text-tertiary, #9ca3af);
    border-radius: 8px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    font-weight: 500;
}

.terminal-action-btn:hover {
    background: var(--fill-tsp-gray-main, rgba(0, 0, 0, 0.05));
    color: var(--text-primary, #1f2937);
    border-color: var(--border-main, rgba(0, 0, 0, 0.1));
}

.terminal-action-btn i {
    font-size: 12px;
}

/* Minimized Terminal Bar */
.terminal-minimized-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--terminal-header-bg);
    border: 1px solid var(--terminal-border);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 12px var(--terminal-shadow);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
}

.terminal-minimized-bar:hover {
    background: #3d3d3d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--terminal-shadow);
}

.terminal-minimized-bar.hidden {
    display: none;
}

.minimized-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    color: #fff;
}

.minimized-content i {
    color: var(--terminal-prompt);
    font-size: 16px;
}

.minimized-content .terminal-status {
    font-size: 11px;
}

.restore-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--terminal-border);
    color: #999;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restore-btn:hover {
    background: var(--terminal-prompt);
    color: var(--terminal-bg);
    border-color: var(--terminal-prompt);
}

/* Responsive Design for Side Panel Terminal */
@media (max-width: 1200px) {
    .terminal-container.open {
        width: 45%;
    }
    
    .terminal-container.maximized {
        width: 65%;
    }
    
    .chat-container.terminal-open {
        margin-right: 45%;
    }
    
    .chat-container.terminal-open.terminal-maximized {
        margin-right: 65%;
    }
    
    html[dir="rtl"] .chat-container.terminal-open {
        margin-right: 0;
        margin-left: 45%;
    }
    
    html[dir="rtl"] .chat-container.terminal-open.terminal-maximized {
        margin-left: 65%;
    }
}

@media (max-width: 768px) {
    .terminal-container.open,
    .terminal-container.maximized {
        width: 100%;
    }
    
    .chat-container.terminal-open,
    .chat-container.terminal-open.terminal-maximized {
        margin-right: 100%;
    }
    
    html[dir="rtl"] .chat-container.terminal-open,
    html[dir="rtl"] .chat-container.terminal-open.terminal-maximized {
        margin-right: 0;
        margin-left: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.terminal-slide-in {
    animation: terminalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.terminal-slide-out {
    animation: terminalSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes terminalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes terminalSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .terminal-window {
        width: 95%;
        height: 90vh;
    }

    .terminal-window.maximized {
        width: 100%;
        height: 100vh;
    }

    .terminal-header {
        padding: 10px 12px;
    }

    .terminal-title {
        font-size: 13px;
    }

    .terminal-title span:nth-child(2) {
        display: none; /* Hide "Agent Terminal" text on mobile */
    }

    .terminal-output {
        padding: 15px;
        font-size: 12px;
    }

    .ascii-art {
        font-size: 8px;
    }

    .terminal-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .terminal-stats {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 11px;
    }

    .terminal-actions {
        justify-content: stretch;
    }

    .terminal-action-btn {
        flex: 1;
        justify-content: center;
    }

    .terminal-minimized-bar {
        bottom: 10px;
        right: 10px;
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .terminal-output {
        font-size: 11px;
    }

    .terminal-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .command-text {
        padding-left: 10px;
        font-size: 11px;
    }

    .terminal-output-text {
        padding-left: 10px;
    }

    .terminal-stats {
        font-size: 10px;
    }
}

/* Loading Spinner for commands */
.terminal-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 255, 65, 0.3);
    border-top-color: var(--terminal-prompt);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Syntax Highlighting for Output */
.terminal-output .highlight-error {
    color: var(--terminal-error);
    font-weight: bold;
}

.terminal-output .highlight-success {
    color: var(--terminal-success);
    font-weight: bold;
}

.terminal-output .highlight-url {
    color: #61afef;
    text-decoration: underline;
}

.terminal-output .highlight-ip {
    color: #c678dd;
}

.terminal-output .highlight-port {
    color: #e5c07b;
}

/* Accessibility */
.terminal-btn:focus,
.terminal-action-btn:focus,
.terminal-input:focus {
    outline: 2px solid var(--terminal-prompt);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .terminal-overlay {
        position: static;
        background: white;
    }

    .terminal-window {
        box-shadow: none;
        border: 1px solid #000;
    }

    .terminal-header,
    .terminal-footer {
        background: #f0f0f0;
    }

    .terminal-controls,
    .terminal-actions {
        display: none;
    }

    .terminal-output {
        color: #000;
        background: #fff;
    }
}

/* Terminal Entry Output Status Classes - defined in Section 1 (Embedded Terminal) above */

/* =========================================================================
   APPROVAL SYSTEM STYLES
   ========================================================================= */

/* Approval Entry Container - standalone card outside terminal */
.terminal-entry.approval-entry {
    border-left: 3px solid #f59e0b;
    padding: 12px 14px;
    margin: 12px auto;
    max-width: 50rem;
    width: 100%;
    box-sizing: border-box;
    background: #1a1f2e;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.25);
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
    font-size: 12.5px;
    direction: ltr !important;
    animation: terminalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.light .terminal-entry.approval-entry {
    background: #ffffff;
    border-color: rgba(245, 158, 11, 0.3);
}

/* Approval Request Box */
.approval-request {
    margin-top: 12px;
    padding: 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(245, 158, 11, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    }
}

/* Risk Level Styling */
.approval-request.risk-low {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.approval-request.risk-medium {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.approval-request.risk-high {
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.3);
}

.approval-request.risk-critical {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    animation: pulse-glow-critical 1.5s ease-in-out infinite;
}

@keyframes pulse-glow-critical {
    0%, 100% {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
    }
}

/* Approval Info Section */
.approval-info {
    margin-bottom: 12px;
}

.approval-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.approval-icon {
    font-size: 18px;
}

.approval-title {
    font-weight: 600;
    color: #f5f5f5;
    font-size: 14px;
}

.risk-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.risk-badge.risk-low {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.risk-badge.risk-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.risk-badge.risk-high {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.risk-badge.risk-critical {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.approval-message {
    color: #a0a0a0;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* Approval Timer */
.approval-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #888;
    font-size: 12px;
}

.approval-timer i {
    color: #f59e0b;
}

.timer-countdown {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-weight: 600;
    color: #f59e0b;
}

.timer-countdown.timer-warning {
    color: #f97316;
}

.timer-countdown.timer-critical {
    color: #ef4444;
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Approval Action Buttons */
.approval-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.approval-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.approval-btn i {
    font-size: 12px;
}

/* Approve Button - Green */
.approval-btn.approve-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.approval-btn.approve-btn:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transform: translateY(-1px);
}

/* Reject Button - Red */
.approval-btn.reject-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.approval-btn.reject-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

/* Suggest Button - Blue */
.approval-btn.suggest-btn {
    background: linear-gradient(135deg, #8595AE, #143668);
    color: white;
    box-shadow: 0 2px 8px rgba(61, 83, 121, 0.3);
}

[data-theme="dark"] .approval-btn.suggest-btn,
.dark .approval-btn.suggest-btn {
    background: linear-gradient(135deg, #71A3CD, #D0DBE8);
    color: #262626;
    box-shadow: 0 2px 8px rgba(113, 163, 205, 0.3);
}

.approval-btn.suggest-btn:hover {
    background: linear-gradient(135deg, #143668, #0d2545);
    box-shadow: 0 4px 12px rgba(61, 83, 121, 0.4);
    transform: translateY(-1px);
}

[data-theme="dark"] .approval-btn.suggest-btn:hover,
.dark .approval-btn.suggest-btn:hover {
    background: linear-gradient(135deg, #D0DBE8, #ffffff);
    box-shadow: 0 4px 12px rgba(113, 163, 205, 0.4);
}

/* Suggestion Submit/Cancel Buttons */
.approval-btn.suggest-submit-btn {
    background: linear-gradient(135deg, #8595AE, #143668);
    color: white;
}

[data-theme="dark"] .approval-btn.suggest-submit-btn,
.dark .approval-btn.suggest-submit-btn {
    background: linear-gradient(135deg, #71A3CD, #D0DBE8);
    color: #262626;
}

.approval-btn.suggest-submit-btn:hover {
    background: linear-gradient(135deg, #143668, #0d2545);
}

[data-theme="dark"] .approval-btn.suggest-submit-btn:hover,
.dark .approval-btn.suggest-submit-btn:hover {
    background: linear-gradient(135deg, #D0DBE8, #ffffff);
}

.approval-btn.suggest-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #a0a0a0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.approval-btn.suggest-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #f5f5f5;
}

/* Decided badge — replaces buttons after approve/reject */
.approval-decided-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.approval-decided-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.approval-decided-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Suggestion Input Container */
.suggestion-input-container {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.suggestion-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #f5f5f5;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 10px;
}

.suggestion-input:focus {
    outline: none;
    border-color: #71A3CD;
    box-shadow: 0 0 0 2px rgba(113, 163, 205, 0.2);
}

.suggestion-input::placeholder {
    color: #666;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
}

/* Decision Result Styling */
.approval-request.decision-made {
    animation: none;
    opacity: 0.8;
}

.approval-request.decision-approved {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
}

.approval-request.decision-rejected {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.approval-request.decision-suggested {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.approval-request.timed-out {
    background: rgba(100, 100, 100, 0.15);
    border-color: rgba(100, 100, 100, 0.4);
    animation: none;
    opacity: 0.7;
}

.approval-decision-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.decision-icon {
    font-size: 20px;
}

.decision-text {
    color: #c9d1d9;
    font-size: 13px;
}

/* RTL Support for Approval System */
html[dir="rtl"] .approval-header,
html[dir="rtl"] .approval-timer,
html[dir="rtl"] .approval-actions,
html[dir="rtl"] .suggestion-actions,
html[dir="rtl"] .approval-decision-result {
    flex-direction: row-reverse;
}

html[dir="rtl"] .terminal-entry.approval-entry {
    border-left: none;
    border-right: 3px solid #f59e0b;
    padding-left: 0;
    padding-right: 12px;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .approval-actions {
        flex-direction: column;
    }
    
    .approval-btn {
        width: 100%;
        justify-content: center;
    }
    
    .suggestion-actions {
        flex-direction: column;
    }
}



/* ========================================
   APPROVAL SYSTEM STYLES
   ======================================== */

/* Approval pending entry styling */
.terminal-entry.approval-pending {
    border-left: 3px solid #f59e0b;
    background: rgba(245, 158, 11, 0.03);
}

/* Approval container */
.approval-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Approval header */
.approval-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.approval-icon {
    font-size: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.approval-title {
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
}

/* Risk badge styling */
.approval-risk-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.approval-risk-badge.low {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid #22c55e;
}

.approval-risk-badge.medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid #f59e0b;
}

.approval-risk-badge.high {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid #ef4444;
}

.approval-risk-badge.critical {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
    border: 1px solid #dc2626;
}

/* Approval info section */
.approval-info {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary, #888);
}

.approval-timer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.timer-value {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
}

.timer-value.warning {
    color: #f59e0b;
}

.timer-value.critical {
    color: #ef4444;
}

/* Approval action buttons */
.approval-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.approval-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.approval-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.approval-btn:active {
    transform: translateY(0);
}

.approval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.approve-btn {
    background: #22c55e;
    color: white;
}

.approve-btn:hover:not(:disabled) {
    background: #16a34a;
}

.reject-btn {
    background: #ef4444;
    color: white;
}

.reject-btn:hover:not(:disabled) {
    background: #dc2626;
}

.suggest-btn {
    background: #3D5379;
    color: white;
}

[data-theme="dark"] .suggest-btn,
.dark .suggest-btn {
    background: #71A3CD;
    color: #262626;
}

.suggest-btn:hover:not(:disabled) {
    background: #143668;
}

[data-theme="dark"] .suggest-btn:hover:not(:disabled),
.dark .suggest-btn:hover:not(:disabled) {
    background: #D0DBE8;
}

/* Suggestion input container */
.suggestion-input-container {
    margin-top: 12px;
    animation: slideIn 0.2s ease-out;
}

.suggestion-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-primary, #333);
    border-radius: 6px;
    background: var(--bg-secondary, #1a1a1a);
    color: var(--text-primary, #f0f0f0);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
}

.suggestion-input:focus {
    outline: none;
    border-color: #71A3CD;
    box-shadow: 0 0 0 3px rgba(113, 163, 205, 0.2);
}

.suggestion-input::placeholder {
    color: var(--text-tertiary, #666);
}

/* Skipped status styling */
.terminal-entry-output.skipped {
    border-left-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 8px;
}

/* Approved/Rejected status after decision */
.approval-container.decided {
    padding: 12px 16px;
}

.approval-container.decided .approval-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* RTL Support for approval system */
html[dir="rtl"] .approval-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .approval-btn {
    flex-direction: row-reverse;
}

html[dir="rtl"] .approval-timer {
    flex-direction: row-reverse;
}

html[dir="rtl"] .approval-header {
    flex-direction: row-reverse;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .approval-actions {
        flex-direction: column;
    }
    
    .approval-btn {
        width: 100%;
        justify-content: center;
    }
    
    .approval-header {
        flex-wrap: wrap;
    }
    
    .approval-risk-badge {
        margin-top: 4px;
    }
}

/* =============================================================================
   SECTION: TERMINAL ANSI COLOR CLASSES
   Real terminal-style ANSI color palette for output text
   ============================================================================= */

/* ANSI Standard Colors */
.term-black { color: #282c34; }
.term-red { color: #ff6b6b; }
.term-green { color: #39d353; }
.term-yellow { color: #e3b341; }
.term-blue { color: #58a6ff; }
.term-magenta { color: #bc8cff; }
.term-cyan { color: #56d4dd; }
.term-white { color: #c9d1d9; }

/* ANSI Bright Colors */
.term-bright-red { color: #ff7b72; }
.term-bright-green { color: #56d364; }
.term-bright-yellow { color: #f2cc60; }
.term-bright-blue { color: #79c0ff; }
.term-bright-magenta { color: #d2a8ff; }
.term-bright-cyan { color: #76e4f7; }
.term-bright-white { color: #f0f6fc; }

/* Terminal text styles */
.term-bold { font-weight: 700; }
.term-dim { opacity: 0.6; }
.term-italic { font-style: italic; }
.term-underline { text-decoration: underline; }
.term-strikethrough { text-decoration: line-through; }

/* Success/Error/Warning/Info semantic terminal colors */
.terminal-entry-output .text-success { color: #39d353; }
.terminal-entry-output .text-error { color: #ff7b72; }
.terminal-entry-output .text-warning { color: #e3b341; }
.terminal-entry-output .text-info { color: #58a6ff; }
.terminal-entry-output .text-muted { color: #484f58; }

/* Terminal cursor styles */
.terminal-block-cursor {
    background: #39d353;
    color: #0d1117;
    animation: cursorBlink 1s step-end infinite;
}

/* Scanline effect for retro terminal feel (optional class) */
.terminal-scanline .embedded-terminal-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.015) 2px,
        rgba(0, 255, 0, 0.015) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* Terminal glow effect for important outputs */
.terminal-entry-output.glow-green {
    text-shadow: 0 0 4px rgba(57, 211, 83, 0.3);
}

.terminal-entry-output.glow-red {
    text-shadow: 0 0 4px rgba(255, 123, 114, 0.3);
}

.terminal-entry-output.glow-blue {
    text-shadow: 0 0 4px rgba(88, 166, 255, 0.3);
}

/* =========================================================================
   PANEL-ONLY TERMINAL: Hidden from chat, shown only as side panel/fullscreen
   ========================================================================= */
.embedded-terminal.et-panel-only:not(.et-maximized):not(.et-fullscreen) {
    display: none !important;
}

/* =========================================================================
   RIGHT SPACING: Ensure input & mini-bar edges are visible when panel open
   ========================================================================= */
/* (Rules merged into the main terminal-panel-open block above) */

/* =========================================================================
   MINI-BAR APPROVAL POPUP: Floating card above mini-bar
   ========================================================================= */
.mini-bar-approval {
    display: none;
    max-width: 50rem;
    margin: 0 auto 6px;
    border-radius: 12px;
    background: #1a1f2e;
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(245, 158, 11, 0.1);
    overflow: hidden;
    z-index: 3;
    position: relative;
    animation: approvalPopupIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mini-bar-approval.visible {
    display: block;
}

.mini-bar-approval.hiding {
    animation: approvalPopupOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes approvalPopupIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes approvalPopupOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
}

/* Approval Card inside the popup */
.mini-bar-approval .approval-card {
    padding: 14px 16px;
}

.mini-bar-approval .approval-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    font-size: 12.5px;
    overflow-x: auto;
    white-space: nowrap;
}

.mini-bar-approval .approval-card-prompt {
    color: #3fb950;
    font-weight: 600;
    flex-shrink: 0;
}

.mini-bar-approval .approval-card-cmd {
    color: #e6edf3;
}

.mini-bar-approval .approval-request {
    margin-top: 8px;
    padding: 12px;
    border-radius: 8px;
}

.mini-bar-approval .approval-actions {
    margin-top: 10px;
}

.mini-bar-approval .approval-btn {
    padding: 7px 14px;
    font-size: 12px;
}

/* Approval Card header/cmd (also used inside panel) */
.approval-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    font-size: 12.5px;
    overflow-x: auto;
    white-space: nowrap;
}

.approval-card-prompt {
    color: #3fb950;
    font-weight: 600;
    flex-shrink: 0;
}

.approval-card-cmd {
    color: #e6edf3;
}

/* =========================================================================
   MINI-BAR APPROVAL: Light Theme
   ========================================================================= */
.light .mini-bar-approval {
    background: #ffffff;
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(245, 158, 11, 0.15);
}

.light .mini-bar-approval .approval-card-header {
    background: rgba(0, 0, 0, 0.04);
}

.light .mini-bar-approval .approval-card-prompt {
    color: #1a7f37;
}

.light .mini-bar-approval .approval-card-cmd {
    color: #24292f;
}

.light .approval-card-header {
    background: rgba(0, 0, 0, 0.04);
}

.light .approval-card-prompt {
    color: #1a7f37;
}

.light .approval-card-cmd {
    color: #24292f;
}

/* =========================================================================
   MINI-BAR APPROVAL: RTL Support
   ========================================================================= */
[dir="rtl"] .mini-bar-approval .approval-card-header {
    direction: ltr;
    text-align: left;
}

[dir="rtl"] .approval-card-header {
    direction: ltr;
    text-align: left;
}

/* =========================================================================
   MINI-BAR APPROVAL: Responsive
   ========================================================================= */
@media (max-width: 768px) {
    .mini-bar-approval {
        margin: 0 8px 4px;
        max-width: none;
        border-radius: 10px;
    }

    .mini-bar-approval .approval-card {
        padding: 10px 12px;
    }

    .mini-bar-approval .approval-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .mini-bar-approval .approval-card-header {
        font-size: 11px;
        padding: 6px 10px;
    }

    .mini-bar-approval .approval-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .mini-bar-approval .approval-btn span {
        display: none;
    }

    .mini-bar-approval .approval-btn {
        padding: 8px 10px;
    }
}