/* AI iOS Glassmorphic Console Styling */
.ai-terminal-console {
    position: fixed;
    top: 90px;
    right: 2rem;
    width: 460px;
    background: rgba(18, 18, 22, 0.82);
    backdrop-filter: blur(30px) saturate(190%);
    -webkit-backdrop-filter: blur(30px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35),
                0 30px 80px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 99999;
    font-family: 'Outfit', 'Inter', sans-serif;
    color: var(--text-primary);
    overflow: hidden;
    
    /* Cinematic spring transitions */
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                opacity 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                filter 0.5s ease;
    transform: scale(0.85) translateY(-30px);
    filter: blur(8px);
    opacity: 0;
}

/* Light Mode Theme Overrides */
[data-theme="light"] .ai-terminal-console {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08),
                0 30px 80px rgba(0, 0, 0, 0.12),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
}

/* Cinematic show & hide classes */
.ai-terminal-console.show {
    transform: scale(1) translateY(0);
    filter: blur(0);
    opacity: 1;
}

.ai-terminal-console.hide {
    transform: scale(0.88) translateY(-20px);
    filter: blur(6px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97),
                opacity 0.4s ease,
                filter 0.4s ease;
}

/* Header styling */
.terminal-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 14px 20px;
    display: flex;
    align-items: center;
}

[data-theme="light"] .terminal-header {
    background: rgba(0, 0, 0, 0.01);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.terminal-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.terminal-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Progress & Status area */
.terminal-progress-area {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .terminal-progress-area {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.terminal-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.terminal-progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .terminal-progress-bar-bg {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.terminal-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1d4ed8, var(--accent-blue));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Log / thoughts area with smooth vertical mask */
.terminal-logs {
    height: 220px;
    background: transparent;
    overflow: hidden; /* Hide outer overflows, scroll wrapper does scroll */
    position: relative;
    box-sizing: border-box;
    display: block;
    
    /* Smooth vertical fading mask */
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 18%, rgba(0,0,0,1) 100%);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 18%, rgba(0,0,0,1) 100%);
}

/* Scroll wrapper layer positioned relative so overflow handles normal page coordinates */
.terminal-logs-scroll-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 16px 20px;
    box-sizing: border-box;
    z-index: 2;
}

/* Bulletproof layout wrapper to push logs to bottom */
.terminal-logs-inner {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Hide scrollbars, let it scroll naturally */
.terminal-logs-scroll-wrapper::-webkit-scrollbar {
    display: none;
}

.terminal-line {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: 'Outfit', 'Inter', monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-primary);
    position: relative;
}

.terminal-line::before {
    content: "> ";
    font-weight: bold;
    margin-right: 4px;
    color: var(--accent-blue);
}

.terminal-line.active {
    opacity: 1;
    transform: translateY(0);
}

.matrix-error {
    color: #ef4444 !important;
}
.matrix-error::before {
    color: #ef4444 !important;
}

/* Custom terminal typewriter cursor */
.terminal-cursor {
    display: inline-block;
    width: 6px;
    height: 14px;
    background: var(--accent-blue);
    margin-left: 3px;
    vertical-align: middle;
    animation: blink 0.8s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

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