/**
 * CLI Terminal Styles
 *
 * Ubuntu 24.04 CLI Emulator Styling
 *
 * @package DevOps_Coach
 * @since 2.7.1
 */

/* Terminal Container Wrapper */
.cli-terminal-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    contain: layout style;
}

/* Terminal Container */
.cli-terminal {
    background: #2d0922;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    margin: 24px 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    transition: box-shadow 0.3s ease;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    contain: layout style paint;
}

.cli-terminal:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Terminal Header */
.cli-header {
    background: linear-gradient(135deg, #5a1e6b 0%, #3d1252 50%, #2d0a3d 100%);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cli-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.cli-icon {
    font-size: 18px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.cli-header-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    align-items: center;
}

.cli-status {
    color: #4ade80;
    font-weight: 600;
    padding: 4px 12px;
    background: rgba(74, 222, 128, 0.15);
    border-radius: 12px;
    border: 1px solid rgba(74, 222, 128, 0.3);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.cli-status:hover {
    background: rgba(74, 222, 128, 0.25);
    border-color: rgba(74, 222, 128, 0.5);
}

/* Terminal Output */
.cli-output {
    background: linear-gradient(180deg, #2d0922 0%, #1f0618 100%);
    color: #f5f5f5;
    padding: 20px;
    min-height: 320px;
    max-height: 520px;
    height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    line-height: 1.7;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    flex: 1;
}

/* Terminal scan line effect */
.cli-output::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        transparent 0%,
        rgba(255, 255, 255, 0.015) 50%,
        transparent 100%
    );
    background-size: 100% 4px;
    pointer-events: none;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { background-position: 0 0; }
    100% { background-position: 0 100%; }
}

.cli-output::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.cli-output::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.cli-output::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #5a1e6b 0%, #4a148c 100%);
    border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.cli-output::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #6a2e7b 0%, #5a249c 100%);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Output Lines */
.cli-line-command {
    color: #5eead4;
    font-weight: 600;
    margin-bottom: 8px;
    word-break: break-word;
    overflow-wrap: break-word;
    text-shadow: 0 0 10px rgba(94, 234, 212, 0.3);
    position: relative;
    z-index: 1;
    max-width: 100%;
    min-width: 0;
}

.cli-line-output,
.cli-line-response {
    color: #f1f5f9;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    min-width: 0;
    overflow: hidden;
}

.cli-line-response * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Markdown styling in responses */
.cli-line-response pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-left: 3px solid #8b5cf6;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.cli-line-response code {
    background: rgba(139, 92, 246, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: inherit;
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.cli-line-response pre code {
    background: none;
    padding: 0;
    border: none;
    color: #e0e7ff;
}

.cli-line-response h1,
.cli-line-response h2,
.cli-line-response h3,
.cli-line-response h4 {
    color: #fcd34d;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cli-line-response strong {
    color: #fcd34d;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cli-line-response ul,
.cli-line-response ol {
    margin-left: 20px;
    margin-bottom: 8px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.cli-line-response p {
    margin: 0 0 8px 0;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.cli-line-response a {
    color: #60a5fa;
    text-decoration: underline;
}

.cli-line-error {
    color: #fca5a5;
    font-weight: 600;
    background: rgba(220, 38, 38, 0.15);
    padding: 8px 12px;
    border-left: 3px solid #ef4444;
    border-radius: 4px;
    margin: 8px 0;
}

.cli-line-system {
    color: #cbd5e1;
    font-style: italic;
    opacity: 0.8;
}

.cli-line-loading {
    color: #fcd34d;
    animation: blink 1s infinite;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cli-line-loading::after {
    content: '●●●';
    display: inline-block;
    animation: dots 1.5s steps(4, end) infinite;
    letter-spacing: 2px;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

@keyframes dots {
    0%, 20% { content: '●'; }
    40% { content: '●●'; }
    60%, 100% { content: '●●●'; }
}

/* Input Line */
.cli-input-line {
    background: linear-gradient(180deg, #2d0922 0%, #240719 100%);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 2px solid rgba(139, 92, 246, 0.2);
    position: relative;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cli-input-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(139, 92, 246, 0.05) 50%, transparent 100%);
    pointer-events: none;
}

.cli-prompt {
    color: #5eead4;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    text-shadow: 0 0 8px rgba(94, 234, 212, 0.4);
    position: relative;
    z-index: 1;
}

.cli-input {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px;
    color: #f5f5f5;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    flex: 1;
    padding: 8px 12px;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.cli-input:focus {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.cli-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

/* Help Section */
.cli-help {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.4) 100%);
    padding: 14px 20px;
    border-top: 2px solid rgba(139, 92, 246, 0.15);
    color: #cbd5e1;
    font-size: 12px;
    line-height: 1.6;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cli-help strong {
    color: #fcd34d;
}

.cli-help code {
    background: rgba(139, 92, 246, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    color: #c4b5fd;
    font-family: inherit;
    border: 1px solid rgba(139, 92, 246, 0.3);
    font-weight: 600;
}

.cli-help kbd {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .cli-terminal {
        font-size: 13px;
    }

    .cli-output {
        min-height: 250px;
        max-height: 400px;
    }

    .cli-help {
        font-size: 11px;
    }
}

/* Accessibility */
.cli-terminal:focus-within {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(139, 92, 246, 0.4);
}

/* Animation for new output */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cli-output > div {
    animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Typing cursor effect for input */
.cli-input {
    caret-color: #5eead4;
}

/* Terminal glow effect */
.cli-terminal::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: -1;
}

.cli-terminal:focus-within::after {
    opacity: 1;
}
