/* ==========================================
   1. Темы оформления (CSS Переменные)
   ========================================== */
:root {
    --bg-page: #0f172a;
    --text-primary: #38bdf8;
    --text-output: #facc15;
    --bg-card: #1e293b;
    --border-color: #334155;
    --input-bg: #1e293b;
    --input-text: #f8fafc;
    --prompt-color: #4ade80;
    --chip-bg: #1e293b;
    --chip-text: #94a3b8;
    --chip-border: #334155;
    --chip-hover-bg: #334155;
    --chip-hover-text: #f8fafc;
}

[data-theme="light"], .theme-light {
    --bg-page: #f8fafc;
    --text-primary: #0284c7;
    --text-output: #b45309;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --input-text: #0f172a;
    --prompt-color: #16a34a;
    --chip-bg: #ffffff;
    --chip-text: #334155;
    --chip-border: #cbd5e1;
    --chip-hover-bg: #f1f5f9;
    --chip-hover-text: #0f172a;
}

/* ==========================================
   2. Основные сбросы и структура страницы
   ========================================== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Главный контейнер терминала на весь экран */
.terminal-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    gap: 8px;
    line-height: 1.5em;
    overflow: hidden;
}

/* Окно вывода истории команд */
#terminal {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 6px;
    font-size: 14px;
}

#terminal-output, 
#terminal, 
#terminal div {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}

#terminal-output {
    box-sizing: border-box;
}

.quick-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0;
    flex-shrink: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.quick-bar::-webkit-scrollbar {
    display: none;
}
.quick-chip {
    background: var(--chip-bg);
    color: var(--chip-text);
    border: 1px solid var(--chip-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.quick-chip:hover {
    background: var(--chip-hover-bg);
    color: var(--chip-hover-text);
}
.quick-chip.chip-login {
    background: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
    font-weight: 600;
}
.quick-chip.chip-login:hover {
    background: #1d4ed8;
}

/* ==========================================
   3. Панель ввода (аккуратный инпут внизу)
   ========================================== */
.input-line {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    border-radius: 8px;
    box-sizing: border-box;
    gap: 4px;
    height: auto;
    overflow: visible;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.prompt {
    font-size: 13px;
    color: var(--prompt-color);
    font-weight: 600;
    user-select: none;
    word-break: break-all;
    padding: 2px 4px 0 4px;
    line-height: 1.3;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#command-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--input-text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    resize: none;
    
    box-sizing: border-box;
    padding: 6px 8px;
    line-height: 1.5em;
    min-height: 1.5em;
    max-height: calc(7 * 1.5em); /* Ограничение ровно на 7 строк текста */
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

#send-btn {
    background: #38bdf8;
    color: #0f172a;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    height: 38px; /* Фиксированная высота под размер стандартной строки ввода */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

#send-btn:active {
    background: #0ea5e9;
}

/* ==========================================
   4. Классы стилизации вывода сообщений
   ========================================== */
.output-error { 
    color: #f87171; 
}

.output-success { 
    color: #4ade80; 
}

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

[data-theme="light"] .terminal-line,
.theme-light .terminal-line {
    color: #1e293b;
}

[data-theme="light"] .output-error,
.theme-light .output-error {
    color: #dc2626;
}

[data-theme="light"] .output-success,
.theme-light .output-success {
    color: #16a34a;
}

[data-theme="light"] .output-info,
.theme-light .output-info {
    color: #0284c7;
}

[data-theme="light"] .terminal-output,
.theme-light .terminal-output {
    color: #b45309;
}
