/* Terminal component styles */

/* Terminal cursor animations */
.terminal-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1em;
    background: #000;
    margin-left: 2px;
    vertical-align: bottom;
    animation: blink-cursor 1s steps(1) infinite;
}

.llm-cursor {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: bottom;
    margin-left: 1px;
    margin-right: 0px;
    margin-bottom: 4px;
    background: none;
    animation: blink-psai-cursor 1s steps(1) infinite;
}

.llm-cursor img {
    width: 1em;
    height: 1em;
    display: block;
    pointer-events: none;
    user-select: none;
}

@keyframes blink-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes blink-psai-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Terminal simulation container */
.terminal-sim {
    background: #fff;
    color: #111;
    font-family: 'IBM Plex Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    padding: 0.5rem;
    border-radius: 0;
    font-size: 0.9rem;
    width: calc(100vw - 2rem);
    height: calc(100vh - 108px);
    overflow: hidden;
    position: fixed;
    top: 68px;
    left: 1rem;
    z-index: 9999;
    display: flex;
    gap: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding-top: 2.5rem;
    transform: translateY(-100%) scale(0.95);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    visibility: hidden;
}

.terminal-sim.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* Terminal backdrop */
.terminal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 17, 17, 0.7);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.terminal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Terminal header */
.terminal-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 0.72rem;
    color: #000;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: #fff;
    padding:5px 5px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 2;
    z-index: 10;
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.terminal-header::before {
    content: "●";
    font-size: 0.5rem;
}

/* Terminal close button */
.terminal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #000;
    padding: 0.65rem;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s ease, color 0.2s ease;
}

.terminal-close:hover {
    background: #000;
    color: #fff;
}

/* Terminal main content area */
.terminal-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

#terminal-commands {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#terminal-commands::-webkit-scrollbar {
    width: 8px;
}

#terminal-commands::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#terminal-commands::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

#terminal-commands::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.55);
}

/* Terminal divider */
.terminal-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.12);
    margin: .5rem 0;
    width: 100%;
    position: relative;
}

.terminal-divider::before {
    display: none;
}

/* Quick questions */
.quick-questions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0rem;
    margin-left: 0.0rem;
    width: calc(100% - 1rem);
}

.quick-question {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.18);
    color: #000;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.quick-question::before {
    display: none;
}

.quick-question:hover {
    background: #000;
    color: #fff;
    border-color: #000;
    transform: translateY(-2px);
}

.quick-question:active {
    transform: translateY(0) scale(0.98);
}

/* Conversation blocks */

.conversation-block {
    background: rgba(0, 0, 0, 0.02);
    padding: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    margin-bottom: 0rem;
    position: relative;
    margin-left: 0.1rem;
    width: calc(100% - 0.2rem);
}

.conversation-block.user {
    background: #fff;
    border: 0px solid #fff;
}

.conversation-block.ai {
    background: #fefefe;
    border-top: 1px dotted #dedede;
    border-bottom: 1px dotted #dedeDe;
    border-left: none;
    border-right: none;
}

.conversation-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.conversation-header.user,
.conversation-header.ai {
    color: #000;
}

.conversation-header::before {
    font-size: 0.8rem;
}

.conversation-header::before {
    content: "●";
    font-size: 0.5rem;
}

.conversation-content {
    color: #111;
    line-height: 1.6;
    font-size: 0.85rem;
}

/* Terminal input and output styling */
.terminal-sim .prompt {
    color: #000;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.terminal-sim .ascii-art {
    color: #00ff00;
    font-size: 0.75em;
    margin-bottom: 0.5em;
    line-height: 1.1;
}

.terminal-sim .output {
    color: #111;
}

.terminal-sim .input-line {
    display: flex;
    align-items: center;
    width: calc(100% - 1rem);
    font-size: 0.85rem;
    background: #fff;
    border-radius: 0;
    padding: 0.2rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: none;
}

.terminal-sim .input-line:focus-within {
    border-color: #000;
    box-shadow: none;
    background: #f5f5f5;
}

.terminal-sim .input-line input {
    flex: 1 1 0%;
    min-width: 0;
    background: transparent;
    border: none;
    color: #000;
    font-family: inherit;
    outline: none;
    width: auto;
    max-width: 100%;
    font-size: 0.85rem;
}

.terminal-description {
    width: calc(100% - 1rem);
    margin-top: 0.2rem;
    padding: 0.2rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.02);
    font-size: 0.55rem;
    line-height: 1;
    color: #111;
    letter-spacing: 0.04em;
}

.terminal-description strong {
    font-weight: 600;
}

.terminal-sim .input-line .terminal-cursor {
    margin-left: 0;
}

/* Message styling */
.system-message {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0.6rem;
    margin: 0.4rem 0;
    color: #000;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.system-message::before {
    content: "●";
    font-size: 0.5rem;
}

.error-message {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0.6rem;
    margin: 0.4rem 0;
    color: #000;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.error-message::before {
    content: "●";
    font-size: 0.5rem;
}

.success-message {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0.6rem;
    margin: 0.4rem 0;
    color: #000;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.success-message::before {
    content: "●";
    font-size: 0.5rem;
}

/* Light theme enhancements for message accents */
.system-message {
    border-left: 3px solid rgba(0, 128, 255, 0.25);
    background: rgba(0, 0, 0, 0.02);
}

.success-message {
    border-left: 3px solid rgba(0, 180, 0, 0.25);
    background: rgba(0, 0, 0, 0.02);
}

.error-message {
    border-left: 3px solid rgba(220, 0, 0, 0.25);
    background: rgba(0, 0, 0, 0.02);
}

/* Status card visuals (light theme) */
.status-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-left: 3px solid rgba(0, 128, 255, 0.3);
    padding: 0.75rem;
    margin: 0.4rem 0;
}

.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.status-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #000;
}

.status-badge {
    display: inline-block;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0.2rem 0.45rem;
    color: #000;
    background: #fff;
}

.status-badge.status-ok {
    border-color: rgba(0, 180, 0, 0.25);
    background: rgba(0, 200, 0, 0.08);
}

.status-badge.status-warn {
    border-color: rgba(240, 180, 0, 0.35);
    background: rgba(240, 180, 0, 0.1);
}

.status-badge.status-err {
    border-color: rgba(220, 0, 0, 0.25);
    background: rgba(220, 0, 0, 0.08);
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem 0.75rem;
}

.kv {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.2rem;
}

.kv .k {
    font-size: 0.63rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #555;
}

.kv .v {
    color: #111;
    font-family: 'IBM Plex Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    word-break: break-word;
}

/* Loading animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #000;
    animation: loading-pulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loading-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Terminal output formatting */
.terminal-sim .output strong {
    font-weight: bold;
    color: #000;
}

.terminal-sim .output em {
    font-style: italic;
    color: #444;
}

.terminal-sim .output code {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 1px 3px;
    border-radius: 2px;
    font-family: monospace;
    color: #000;
}

.terminal-sim .output .separator {
    color: #111;
    font-weight: bold;
    margin: 8px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    padding-top: 8px;
}

/* Mobile terminal adjustments */
@media (max-width: 768px) {
    .terminal-sim {
        padding: 1rem;
        width: calc(100vw - 1rem);
        height: calc(100vh - 10rem);
        top: 0.5rem;
        left: 0.5rem;
        bottom: 8rem;
        position: fixed;
        overflow: hidden;
        border-radius: 12px;
        transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    .terminal-main {
        width: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .quick-questions-row {
        gap: 0.5rem;
        margin-bottom: 1rem;
        padding: 0.5rem;
        margin-left: 0.5rem;
        width: calc(100% - 1rem);
    }
    
    .quick-question {
        font-size: 0.7rem;
        padding: 0.4rem 0.6rem;
    }
    
    .conversation-block {
        padding: 0.5rem;
        margin-bottom: 0.4rem;
        margin-left: 0.1rem;
        width: calc(100% - 0.2rem);
    }
    
    .conversation-content {
        font-size: 0.8rem;
    }
    
    .terminal-sim .input-line {
        padding: 0.2rem;
        font-size: 0.8rem;
        margin-left: 0rem;
        width: calc(100% - 1rem);
    }
    
    .terminal-sim .input-line input {
        font-size: 16px;
    }
    
    #terminal-commands {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        gap: 0.4rem;
    }
    
    body.terminal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}