/* =================================================================== */
/* --- Тема "Retro Terminal / CRT" --- v1.0 --- */
/* =================================================================== */

/* --- 1. Анимации и ключевые кадры --- */

@keyframes blink-caret {
    50% { background-color: transparent; }
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

@keyframes text-flicker {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* --- 2. Общие настройки темы --- */

body.theme-terminal {
    font-family: 'Consolas', 'Menlo', 'Courier New', monospace !important;
    font-smooth: never;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    cursor: text; /* Курсор как для ввода текста */
    animation: text-flicker 0.1s infinite;
}

/* --- 3. Переменные для ТЕМНОЙ темы (Classic Green) --- */
body.theme-terminal:not(.gsearch-light-theme) {
    --term-bg: #0a0e0c;
    --term-surface: transparent;
    --term-text: #33ff66;
    --term-text-secondary: #00802b;
    --term-accent: #33ff66;
    --term-link: #33ff66;
    --term-glow: rgba(51, 255, 102, 0.3);
    --term-input-bg: #111;
    --term-border: #00802b;
    --term-cursor-color: #33ff66;
}

/* --- 4. Переменные для СВЕТЛОЙ темы (Paperwhite) --- */
body.theme-terminal.gsearch-light-theme {
    --term-bg: #f5f5f5;
    --term-surface: transparent;
    --term-text: #1c1e21;
    --term-text-secondary: #606770;
    --term-accent: #0d6efd;
    --term-link: #0d6efd;
    --term-glow: rgba(13, 110, 253, 0.3);
    --term-input-bg: #e9e9e9;
    --term-border: #cccccc;
    --term-cursor-color: #1c1e21;
}

/* --- 5. Применение стилей --- */

body.theme-terminal {
    background-color: var(--term-bg);
    color: var(--term-text);
    text-shadow: 0 0 5px var(--term-glow);
    position: relative;
    overflow-x: hidden;
}

/* Эффект сканирующих линий, как на старых мониторах */
body.theme-terminal::after {
    content: ' ';
    display: block;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 200%; /* Увеличиваем высоту для плавной анимации */
    background: linear-gradient(to bottom, rgba(18, 16, 16, 0) 0%, rgba(18, 16, 16, 0.3) 50%, rgba(18, 16, 16, 0) 100%);
    background-size: 100% 4px;
    z-index: 100;
    pointer-events: none;
    animation: scanline 0.2s linear infinite;
}

/* Шапка */
.theme-terminal .gsearch-header-container {
    background: var(--term-bg) !important;
    border-bottom: 1px solid var(--term-border);
    box-shadow: none;
    position: relative;
}

/* Оформляем поле ввода как командную строку */
.theme-terminal .gsearch-input-wrapper::before {
    content: 'C:\\>_';
    color: var(--term-text);
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 16px;
    animation: blink-caret 1s step-end infinite;
}

.theme-terminal .gsearch-header-input {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding-left: 70px !important; /* Освобождаем место для "C:\>_" */
    caret-color: var(--term-cursor-color);
}

.theme-terminal .gsearch-header-submit,
.theme-terminal .gsearch-ai-btn {
    display: none !important; /* Убираем кнопки, ввод по Enter */
}

/* Табы */
.theme-terminal .gsearch-tab {
    color: var(--term-text-secondary);
}
.theme-terminal .gsearch-tab.active {
    background: var(--term-text);
    color: var(--term-bg);
    text-shadow: none;
}

/* Оформляем результаты как вывод в консоли */
.theme-terminal .gsearch-result-item,
.theme-terminal .gsearch-ai-box,
.theme-terminal .gsearch-info-panel,
.theme-terminal .calculator-widget,
.theme-terminal .weather-widget {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 0 15px 0;
    animation: none;
}

/* Добавляем "приглашение" командной строки перед каждым результатом */
.theme-terminal .gsearch-result-item::before {
    content: 'C:\\RESULTS>';
    display: block;
    margin-bottom: 5px;
    color: var(--term-text-secondary);
}
.theme-terminal .gsearch-ai-box::before {
    content: '[AI_BOT]$';
    color: var(--term-accent);
}
.theme-terminal .gsearch-info-panel::before {
    content: 'INFO>';
    color: var(--term-text-secondary);
}

.theme-terminal .gsearch-result-title a {
    color: var(--term-link) !important;
    text-decoration: underline !important;
}

.theme-terminal .gsearch-result-meta,
.theme-terminal .gsearch-result-desc {
    color: var(--term-text) !important;
}

/* Убираем лишние отступы и рамки внутри окон */
.theme-terminal .gsearch-result-item > div, .theme-terminal .gsearch-result-item > h2, .theme-terminal .gsearch-result-item > p,
.theme-terminal .gsearch-ai-box > div, .theme-terminal .gsearch-info-panel > div {
    padding: 0;
}

/* Кнопки пагинации в стиле терминала */
.theme-terminal .gsearch-pagination-link,
.theme-terminal .gsearch-pagination-current {
    background: transparent !important;
    border: 1px solid var(--term-border) !important;
    color: var(--term-text) !important;
    border-radius: 0 !important;
    padding: 2px 8px;
    text-decoration: none;
}

.theme-terminal .gsearch-pagination-link:hover,
.theme-terminal .gsearch-pagination-current {
    background: var(--term-text) !important;
    color: var(--term-bg) !important;
    text-shadow: none;
}

/* Скроллбар */
.theme-terminal ::-webkit-scrollbar { width: 16px; }
.theme-terminal ::-webkit-scrollbar-track { background: var(--term-border); }
.theme-terminal ::-webkit-scrollbar-thumb {
    background: var(--term-text);
    border-radius: 0;
}