/* CJQuant Terminal - Modern Terminal UI Theme */

/* CSS Variables */
:root {
    --bg-primary: #080808;
    --bg-secondary: #0d0d0d;
    --bg-terminal: rgba(18, 18, 18, 0.9);
    --accent: #f5f5f5;
    --accent-dim: rgba(245, 245, 245, 0.15);
    --accent-glow: rgba(245, 245, 245, 0.2);
    --text-primary: #e5e5e5;
    --text-dim: #9b9b9b;
    --text-bright: #ffffff;
    --text-green: #ffffff;
    --text-red: #f87171;
    --text-orange: #fb923c;
    --text-purple: #c084fc;
    --text-blue: #94a3b8;
    --border-color: rgba(245, 245, 245, 0.06);
    --border-highlight: rgba(245, 245, 245, 0.08);
    --shadow-terminal: rgba(0, 0, 0, 0.6);
    --shadow-glow: rgba(245, 245, 245, 0.05);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
}

body {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(245, 245, 245, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(245, 245, 245, 0.015) 0%, transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(245, 245, 245, 0.02) 0%, transparent 35%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.015'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Source Code Pro', 'Hack', 'Consolas', monospace;
    font-weight: 400 500;
    min-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    line-height: 1.6;
}

/* Terminal Window */
.terminal {
    width: 100%;
    max-width: 1400px;
    height: 87vh;
    background: var(--bg-terminal);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 0 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        inset 0 -1px 0 rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Subtle glow effect on terminal */
.terminal::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(245, 245, 245, 0.1) 0%, transparent 40%, transparent 60%, rgba(245, 245, 245, 0.08) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.5;
}

/* Inner shadow for depth */
.terminal::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1;
}

/* Title Bar */
.terminal-titlebar {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.005) 100%);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    position: relative;
}

.terminal-controls {
    display: none;
}

.terminal-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 1px;
    opacity: 0.8;
}

.terminal-tabs {
    display: flex;
    gap: 4px;
    position: absolute;
    right: 20px;
}

.tab {
    font-size: 11px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.tab:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.tab.active {
    background: rgba(245, 245, 245, 0.08);
    color: var(--text-primary);
    opacity: 1;
    font-weight: 600;
}

/* Terminal Body */
.terminal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px 20px 2px;
    font-size: 14px;
}

#terminal-output {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 12px;
    scroll-behavior: smooth;
    user-select: text;
}

/* Scrollbar Styling */
#terminal-output::-webkit-scrollbar {
    width: 8px;
}

#terminal-output::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

#terminal-output::-webkit-scrollbar-thumb {
    background: rgba(245, 245, 245, 0.1);
    border-radius: 4px;
    transition: background 0.2s, transform 0.2s;
}

#terminal-output::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 245, 245, 0.2);
    transform: scaleY(1.1);
}

#terminal-output::-webkit-scrollbar-thumb:active {
    background: rgba(245, 245, 245, 0.25);
}

#terminal-output::-webkit-scrollbar-corner {
    background: transparent;
}

/* Terminal Lines */
.terminal-line {
    margin-bottom: 6px;
    line-height: 1.75;
    animation: fadeIn 0.25s ease-out;
    user-select: text;
}

/* Enable text selection in all output content */
.command-display,
.output-line,
.output-content,
.output-content h1,
.output-content h2,
.output-content h3,
.output-content p,
.output-content li,
.output-content code,
.output-content pre {
    user-select: text;
}

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

/* Command Display */
.command-display {
    color: var(--text-dim);
    margin: 4px 0 8px 0;
    opacity: 0.7;
}

.command-display .prompt {
    color: var(--accent);
    margin-right: 6px;
}

.command-display .path {
    color: var(--text-blue);
    margin-right: 4px;
}

.command-display .prompt-end {
    color: var(--accent);
    margin-left: 6px;
    margin-right: 8px;
}

.command-display .cmd {
    color: var(--text-primary);
}

/* Output Styling */
.output-line {
    color: var(--text-dim);
    margin: 4px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-line.error {
    color: var(--text-red);
    background: rgba(248, 113, 113, 0.08);
    padding: 6px 10px;
    border-radius: 6px;
    margin: 8px 0;
    border-left: 2px solid var(--text-red);
}

/* Photo Gallery */
.photo-gallery {
    margin: 12px 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 50%;
    white-space: normal;
}

.photo-gallery p {
    grid-column: 1 / -1;
    color: var(--text-dim);
    margin-bottom: 4px;
    white-space: normal;
}

.photo-item {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.photo-item:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    border-color: rgba(245, 245, 245, 0.2);
}

/* Photo Lightbox */
.photo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

.photo-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
}

.photo-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.photo-lightbox-close:hover {
    opacity: 1;
}

/* Markdown Content in Output */
.output-content {
    margin: 8px 0 12px 0;
    padding-left: 0;
}

.output-content h1,
.output-content h2,
.output-content h3 {
    color: var(--accent);
    margin: 16px 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.output-content h1 {
    font-size: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.output-content h2 {
    font-size: 16px;
}

.output-content p {
    margin: 10px 0;
    color: var(--text-primary);
    line-height: 1.75;
}

.output-content ul,
.output-content ol {
    margin: 10px 0;
    padding-left: 24px;
}

.output-content li {
    margin: 6px 0;
    color: var(--text-primary);
}

.output-content li::marker {
    color: var(--accent);
}

.output-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.output-content a:hover {
    border-bottom-color: var(--accent);
}

/* Code Blocks */
.output-content pre {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
    overflow-x: auto;
    position: relative;
}

.output-content pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
    opacity: 0.5;
}

.output-content code {
    font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Source Code Pro', 'Hack', 'Consolas', monospace;
    font-weight: 400 500;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

.output-content code:not(pre code) {
    background: rgba(245, 245, 245, 0.1);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Syntax Highlighting in Code Blocks */
.output-content pre code .keyword {
    color: var(--text-purple);
    font-weight: 500;
}

.output-content pre code .string {
    color: var(--text-primary);
}

.output-content pre code .comment {
    color: #666666;
    font-style: italic;
}

.output-content pre code .function {
    color: var(--text-blue);
}

.output-content pre code .number {
    color: var(--text-orange);
}

.output-content pre code .operator {
    color: var(--accent);
}

.output-content pre code .tag {
    color: var(--text-blue);
}

.output-content pre code .attr-name {
    color: var(--text-orange);
}

.output-content pre code .attr-value {
    color: var(--text-primary);
}

/* Horizontal Rule */
.output-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

.output-content hr::after {
    content: '·· · ···';
    display: block;
    text-align: center;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 8px;
    margin-top: 8px;
}

/* Command Line Input Area */
.command-line {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    flex-wrap: wrap;
    position: relative;
}

.command-line .prompt {
    color: var(--accent);
    font-weight: 600;
    margin-right: 6px;
}

.command-line .path {
    color: var(--text-blue);
    margin-right: 4px;
}

.command-line .path-separator {
    color: var(--text-dim);
    margin-right: 6px;
}

.command-line .prompt-end {
    color: var(--accent);
    margin-left: 6px;
    margin-right: 8px;
}

#terminal-input {
    flex: 1;
    min-width: 200px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    position: relative;
}

/* Ghost autocomplete text */
.input-ghost {
    position: absolute;
    pointer-events: none;
    color: var(--text-dim);
    opacity: 0.5;
    font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Source Code Pro', 'Hack', 'Consolas', monospace;
    font-size: 14px;
    white-space: pre;
    visibility: hidden;
    z-index: 5;
}

.input-ghost.visible {
    visibility: visible;
}

#terminal-input {
    caret-color: var(--accent);
    padding: 4px 0;
}

#terminal-input::placeholder {
    color: var(--text-dim);
    opacity: 0.5;
}

/* Blinking Cursor */
.cursor {
    display: inline-block;
    width: 9px;
    height: 18px;
    background: var(--accent);
    vertical-align: middle;
    border-radius: 2px;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
    box-shadow: 0 0 8px var(--accent-glow);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Status Bar */
.terminal-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-left::before {
    content: '→';
    color: var(--accent);
    font-size: 10px;
}

.status-right::after {
    content: '⌤';
    color: var(--text-dim);
    margin-left: 4px;
    font-size: 12px;
}

/* Help Command Styling */
.help-section {
    margin: 0;
}

.help-command {
    color: var(--accent);
    font-weight: 500;
    margin-right: 8px;
}

.help-desc {
    color: var(--text-dim);
}

.help-divider {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 12px 0;
}

/* Typing Animation Container */
.typing-container {
    display: inline;
}

.typing-char {
    opacity: 0;
    animation: typeReveal 0.03s ease-out forwards;
}

@keyframes typeReveal {
    from {
        opacity: 0;
        transform: translateY(1px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading Animation */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out;
}

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

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Focus States */
#terminal-input:focus {
    background: transparent;
}

/* Selection */
::selection {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-bright);
}

/* Responsive Design */
@media (max-width: 640px) {
    body {
        padding: 12px;
    }

    .terminal {
        height: 94vh;
        border-radius: 10px;
    }

    .terminal-titlebar {
        padding: 10px 12px;
    }

    .terminal-controls {
        display: none;
    }

    .terminal-title {
        text-align: left;
        font-size: 11px;
    }

    .terminal-tabs {
        right: 12px;
    }

    .tab {
        font-size: 10px;
        padding: 3px 8px;
    }

    .terminal-body {
        padding: 12px 14px;
        font-size: 13px;
    }

    .command-line {
        font-size: 13px;
        padding: 10px 0 6px 0;
    }

    .terminal-status {
        font-size: 10px;
        padding: 8px 12px;
    }

    .output-content pre {
        padding: 10px 12px;
    }

    .output-content code {
        font-size: 12px;
    }
}

/* Animation for new message appearance */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.terminal-line.new {
    animation: slideUp 0.3s ease-out;
}

/* Print styles */
@media print {
    .terminal-controls,
    .terminal-tabs,
    .terminal-status,
    .command-line {
        display: none;
    }

    .terminal {
        height: auto;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    body {
        background: white;
        color: black;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px 0 8px 0;
    font-size: 12px;
    color: var(--text-dim);
}

.footer .line {
    margin: 4px 0;
}

.footer .separator {
    margin: 0 8px;
    color: var(--text-dim);
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--text-primary);
}

/* Upload Modal */
.upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.upload-modal.show {
    display: flex;
}

.upload-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.upload-modal-content {
    position: relative;
    background: var(--bg-terminal);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.upload-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.upload-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.upload-close:hover {
    color: var(--text-primary);
}

.upload-form {
    padding: 20px;
}

.upload-field {
    margin-bottom: 16px;
}

.upload-field label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.upload-field input[type="email"],
.upload-field input[type="text"],
.upload-field select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.upload-field input[type="email"]:focus,
.upload-field input[type="text"]:focus,
.upload-field select:focus {
    border-color: var(--accent);
}

.upload-field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23909090' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.upload-field select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.upload-field textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
}

.upload-field textarea:focus {
    border-color: var(--accent);
}

.upload-drop-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-drop-zone:hover,
.upload-drop-zone.upload-drop-active {
    border-color: var(--accent);
    background: rgba(245, 245, 245, 0.03);
}

.upload-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-drop-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.upload-drop-text {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.upload-drop-hint {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
}

.upload-file-info {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(245, 245, 245, 0.05);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-file-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-size {
    font-size: 11px;
    color: var(--text-dim);
}

.upload-progress {
    margin: 16px 0;
}

.upload-progress-bar {
    height: 4px;
    background: rgba(245, 245, 245, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

.upload-progress-text {
    font-size: 12px;
    color: var(--text-dim);
}

.upload-message {
    margin: 12px 0;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.upload-message-success {
    display: block;
    background: rgba(0, 255, 213, 0.1);
    color: var(--text-green);
    border: 1px solid rgba(0, 255, 213, 0.2);
}

.upload-message-error {
    display: block;
    background: rgba(248, 113, 113, 0.1);
    color: var(--text-red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.upload-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.upload-btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
}

.upload-btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.upload-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-btn-secondary {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-color);
}

.upload-btn-secondary:hover {
    background: rgba(245, 245, 245, 0.05);
    color: var(--text-primary);
}

/* Terminal drag over state */
.terminal-drag-over {
    box-shadow: 0 0 0 2px var(--accent) !important;
}