/* ==========================================================================
   OrbitOS Shell (H209B)
   The Design v3 command dock (the input bar at the bottom of the terminal).
   Loaded after apps.css. Rules are keyed on #terminal-header / #command-input-area
   (id specificity) so they win over the many older .command declarations in
   components.css, apps.css and themes.css without touching those files.
   ========================================================================== */

:root {
    --shell-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Command dock ---------- */

body.new-design #command-input-area {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 54px;
    margin: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    padding: 6px 6px 6px 16px !important;
    width: auto !important;
    max-width: none !important;
    border-radius: 999px !important;
    overflow: visible !important;
    box-sizing: border-box;
    transition: border-color 0.2s ease, background-color 0.2s ease !important;
}

/* Default look: the theme's own surface color with just a hint of its text color,
   so the pill stays a dark gray that matches each theme instead of a light slab.
   Glass, Glow, Fluent and AMOLED keep the surface their theme scripts define. */
html:not(.theme-glassmorphism):not(.theme-glass):not(.theme-glass-static):not(.theme-glowmorphism):not(.theme-fluent-ui):not(.theme-amoled) body.new-design #command-input-area {
    background: color-mix(in srgb, var(--surface-color, #0d1117) 95%, var(--on-surface, #ffffff) 5%) !important;
    border: 1px solid color-mix(in srgb, var(--on-surface, #ffffff) 8%, transparent) !important;
    box-shadow: none !important;
}

html:not(.theme-glassmorphism):not(.theme-glass):not(.theme-glass-static):not(.theme-glowmorphism):not(.theme-fluent-ui):not(.theme-amoled) body.new-design #command-input-area:focus-within {
    border-color: color-mix(in srgb, var(--on-surface, #ffffff) 16%, transparent) !important;
    box-shadow: none !important;
}

html.theme-amoled body.new-design #command-input-area {
    border: 1px solid #262626 !important;
}

html.theme-amoled body.new-design #command-input-area:focus-within {
    border-color: #5a5a5a !important;
}

/* Prompt (plain text, no background) */
body.new-design #command-input-area #prompt {
    display: inline-flex !important;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
    max-width: 40% !important;
    height: 38px;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    color: var(--accent-primary, #4790e6) !important;
    opacity: 1 !important;
    font-family: var(--font-mono);
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    line-height: 38px !important;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

html.theme-amoled body.new-design #command-input-area #prompt {
    color: #ffffff !important;
}

/* Input */
body.new-design #command-input-area .input-field {
    flex: 1;
    min-width: 0;
    height: 40px !important;
    min-height: 40px !important;
    line-height: 40px !important;
    padding: 0 4px !important;
    margin: 0 !important;
    font-family: var(--font-mono);
    font-size: max(16px, var(--terminal-font-size, 1rem)) !important;
    caret-color: var(--accent-primary) !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

body.new-design #command-input-area .input-field::placeholder {
    color: var(--on-surface);
    opacity: 0.38;
}

/* Run button */
.cmd-run-btn {
    display: none;
}

body.new-design .cmd-run-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--on-surface);
    background: color-mix(in srgb, var(--on-surface, #ffffff) 8%, transparent);
    opacity: 0.5;
    transform: scale(0.92);
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease !important;
}

body.new-design #command-input-area.has-text .cmd-run-btn {
    opacity: 1;
    transform: scale(1);
    color: var(--background, #05080c);
    background: var(--accent-primary);
}

html.theme-amoled body.new-design #command-input-area.has-text .cmd-run-btn {
    background: #ffffff;
    color: #000000;
}

/* ---------- Overlays above the dock (floating input + suggestions) ---------- */

.cmd-overlay-stack {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    z-index: 10;
}

.cmd-suggestions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    mask-image: linear-gradient(to right, #000 88%, transparent);
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
}

.cmd-suggestions::-webkit-scrollbar {
    display: none;
}

.cmd-suggestions:empty {
    display: none;
}

.cmd-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--on-surface, #ffffff) 8%, transparent);
    background: color-mix(in srgb, var(--surface-color, #0d1117) 95%, var(--on-surface, #ffffff) 5%);
    color: var(--on-surface);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    animation: shellChipIn 0.24s var(--shell-ease) both;
}

.cmd-suggestion:nth-child(2) { animation-delay: 0.02s; }
.cmd-suggestion:nth-child(3) { animation-delay: 0.04s; }
.cmd-suggestion:nth-child(4) { animation-delay: 0.06s; }
.cmd-suggestion:nth-child(5) { animation-delay: 0.08s; }
.cmd-suggestion:nth-child(n+6) { animation-delay: 0.1s; }

.cmd-suggestion.is-active,
.cmd-suggestion:hover {
    border-color: color-mix(in srgb, var(--accent-primary, #4790e6) 60%, transparent);
}

.cmd-suggestion mark {
    background: transparent;
    color: var(--accent-primary);
    font-weight: 700;
}

.cmd-suggestion svg {
    opacity: 0.55;
    flex-shrink: 0;
}

.cmd-suggestion .cmd-suggestion-hint {
    opacity: 0.45;
    font-family: var(--font-main);
    font-size: 0.72rem;
}

@keyframes shellChipIn {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

html.theme-amoled .cmd-suggestion {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

/* Legacy design keeps the original bar, so the extras stay hidden there. */
body:not(.new-design) .cmd-suggestions {
    display: none;
}

/* Suggestions sit on a solid band so they never overlap the output text, and
   the output gets room at the bottom so its last line stays readable. */
body.new-design .cmd-overlay-stack:has(.cmd-suggestions:not(:empty)),
body.new-design .cmd-overlay-stack:has(#floating-input-box.visible) {
    left: -12px;
    right: -12px;
    padding: 14px 12px 4px;
    bottom: 100%;
    /* Solid under the chips so terminal text never shows through them; only
       the top edge fades. */
    background: linear-gradient(to bottom, transparent, var(--surface-color, #0d1117) 14px);
}
html.theme-amoled body.new-design .cmd-overlay-stack:has(.cmd-suggestions:not(:empty)),
html.theme-amoled body.new-design .cmd-overlay-stack:has(#floating-input-box.visible) {
    background: linear-gradient(to bottom, transparent, #000000 14px);
}

body.new-design .terminal:has(.cmd-suggestions:not(:empty)) .output {
    padding-bottom: 64px !important;
}
body.new-design .terminal:has(.cmd-suggestions:not(:empty)):has(#floating-input-box.visible) .output {
    padding-bottom: 116px !important;
}
