/* ============================================================
   Terminal Container
   ============================================================ */
#terminal-container {
    width: 100%;
    height: 100%;
    max-width: 1100px;
    max-height: 780px;
    background: var(--background);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 0 1px rgba(0, 255, 65, 0.08),
        0 0 40px rgba(0, 255, 65, 0.08),
        0 24px 64px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    position: relative;
}

/* ============================================================
   Titlebar
   ============================================================ */
#terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--titlebar-bg);
    padding: 10px 16px;
    border-bottom: 1px solid #1f1f1f;
    user-select: none;
    flex-shrink: 0;
}

.titlebar-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    cursor: default;
}

.btn-close    { background: #ff5f57; }
.btn-minimize { background: #ffbd2e; }
.btn-maximize { background: #28c840; }

.titlebar-title {
    flex: 1;
    text-align: center;
    color: var(--titlebar-fg);
    font-size: 12px;
    letter-spacing: 0.02em;
}

.titlebar-spacer {
    width: 52px; /* balances the buttons */
    flex-shrink: 0;
}

/* ============================================================
   Terminal Body
   ============================================================ */
#terminal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--terminal-padding);
    overflow: hidden;
    cursor: text;
}

/* ============================================================
   Output area
   ============================================================ */
#terminal-output {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 4px;
}

/* ============================================================
   Output lines
   ============================================================ */
.output-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: calc(var(--font-size) * var(--line-height));
}

/* Semantic line types */
.output-line.error   { color: var(--color-error); }
.output-line.warning { color: var(--color-warning); }
.output-line.info    { color: var(--color-info); }
.output-line.success { color: var(--color-success); }
.output-line.dim     { color: var(--color-dim); }

/* Echoed command lines (prompt + typed command) */
.output-line.command-echo {
    color: var(--foreground);
    opacity: 0.75;
}

/* ASCII art / banners */
.output-line.ascii {
    color: var(--accent);
    font-weight: bold;
}

/* Glow on accent lines */
.output-line.accent {
    color: var(--accent);
    text-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
}

/* Images rendered via `cat` on an image-type VFS node */
.terminal-image {
    display: block;
    max-width: 100%;
    max-height: 360px;
    margin: 6px 0;
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-radius: 4px;
}

/* ============================================================
   File type colors (used in ls / tree / autocomplete)
   ============================================================ */
.ft-dir  { color: var(--prompt-path); }
.ft-exe  { color: var(--accent); }
.ft-log  { color: var(--color-warning); }
.ft-txt  { color: var(--foreground); }

/* ============================================================
   Input line
   ============================================================ */
#terminal-input-line {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-height: calc(var(--font-size) * var(--line-height));
    position: relative;
}

/* Prompt */
#prompt {
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 0px;
    user-select: none;
}

.prompt-user   { color: var(--prompt-user); }
.prompt-at     { color: var(--prompt-user); }
.prompt-host   { color: var(--prompt-host); }
.prompt-colon  { color: var(--foreground); }
.prompt-path   { color: var(--prompt-path); }
.prompt-symbol { color: var(--prompt-symbol); }

/* Input wrapper */
#input-wrapper {
    flex: 1;
    position: relative;
    display: block;
    overflow: hidden;
    line-height: var(--line-height);
}

/* Visual text display (mirrors the real input) */
#input-display {
    display: inline;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--foreground);
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: var(--line-height);
    pointer-events: none;
}

#text-before-cursor,
#text-after-cursor {
    display: inline;
    }

/* Blinking block cursor */
#cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background: var(--cursor);
    vertical-align: text-bottom;
    margin-bottom: -1px;
}

/* Real input — invisible, captures keyboard events */
#terminal-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: transparent;
    caret-color: transparent;
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: var(--line-height);
    padding: 0;
    z-index: 1;
}

/* ============================================================
   Input hint (shown below the input line while in a special
   mode, e.g. "Ctrl+C or /quit to leave chat")
   ============================================================ */
#input-hint {
    font-size: 11px;
    color: var(--color-dim);
    padding-top: 2px;
    flex-shrink: 0;
}

/* ============================================================
   Chat message lines (rendered by the `chat` command)
   ============================================================ */
.chat-user  { color: var(--prompt-user); }
.chat-self  { color: var(--color-info); }
.chat-stamp { color: var(--color-dim); }
.chat-sep   { color: var(--prompt-symbol); }

/* ============================================================
   Autocomplete candidates row
   ============================================================ */
.autocomplete-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 20px;
    color: var(--color-info);
}

.autocomplete-row span {
    min-width: 8ch;
}

/* ============================================================
   Mobile / responsive
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --font-size: 12px;
        --terminal-padding: 10px;
    }

    #terminal-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    .titlebar-title {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size: 11px;
        --terminal-padding: 8px;
    }
}
