@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Inter:wght@300;400;600;800&display=swap');

:root {
    --bg-dark: #050510;
    --bg-panel: rgba(20, 25, 40, 0.7);
    --accent: #00f0ff;
    --accent-glow: rgba(0, 240, 255, 0.3);
    --secondary: #7000ff;
    --text-main: #e0e6ed;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: blur(12px);
    --font-mono: 'Space Mono', monospace;
    --font-sans: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    overflow: hidden; /* App-like feel */
    height: 100vh;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(112, 0, 255, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.1) 0%, transparent 20%);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

/* Side Navigation */
.side-nav {
    background: rgba(10, 12, 20, 0.9);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 1px;
    color: var(--accent);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    box-shadow: 0 0 15px var(--accent-glow);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    color: var(--text-dim);
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link.active {
    border-left: 3px solid var(--accent);
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.1), transparent);
}

.nav-status {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #333;
}

.status-dot.active {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

.mono {
    font-family: var(--font-mono);
    color: var(--accent);
}

/* Main Content */
.content-area {
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.section {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out;
}

.section.active {
    display: block;
}

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

/* Simulation Grid */
.simulation-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    grid-template-rows: auto 250px;
    gap: 24px;
    height: calc(100vh - 120px);
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Inputs */
.control-panel {
    grid-row: 1 / -1;
}

.input-group {
    margin-bottom: 24px;
}

/* File Upload Styles */
.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-drop-zone:hover, .file-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 240, 255, 0.05);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 2;
}

.drop-content .icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.drop-text {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
}

.drop-sub {
    color: var(--text-dim);
    font-size: 0.7rem;
}

#preview-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    z-index: 1;
}

#preview-img.hidden {
    display: none;
}

label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 600;
}

textarea {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-main);
    font-family: var(--font-sans);
    resize: none;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="range"] {
    width: 100%;
    background: transparent;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -6px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
}

.slider-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.value-badge {
    color: var(--accent);
    font-family: var(--font-mono);
}

select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 6px;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 6px;
    font-weight: 800;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Director Mode Styles */
.director-controls {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.director-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.switch-container input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 20px;
    background: #333;
    border-radius: 20px;
    position: relative;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

input:checked + .toggle-slider {
    background: var(--secondary);
}

input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.frame-count {
    font-family: var(--font-mono);
    color: var(--secondary);
    font-size: 0.8rem;
}

.director-actions {
    display: flex;
    gap: 12px;
}

.btn-secondary, .btn-danger {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--text-main);
    color: #000;
}

.btn-danger {
    background: rgba(255, 0, 85, 0.1);
    color: #ff0055;
    border: 1px solid rgba(255, 0, 85, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: #ff0055;
    color: #fff;
}

.btn-secondary:disabled, .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Visualization Panel */
.visualization-panel {
    grid-column: 2;
    grid-row: 1;
    padding: 0; /* Custom padding for tabs */
    overflow: hidden;
}

.viz-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
}

.viz-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    border-right: 1px solid var(--border);
}

.viz-tab.active {
    color: var(--accent);
    background: rgba(0, 240, 255, 0.05);
}

.viz-content {
    flex: 1;
    position: relative;
    background: #000;
}

.viz-view {
    display: none;
    width: 100%;
    height: 100%;
}

.viz-view.active {
    display: block;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.overlay-stats {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    color: var(--accent);
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 16px;
    border: 1px solid var(--accent);
    pointer-events: none;
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 240, 255, 0.3);
    opacity: 0.3;
    animation: scan 3s linear infinite;
    pointer-events: none;
}

@keyframes scan {
    0% { top: 0%; }
    100% { top: 100%; }
}

.entropy-readout {
    position: absolute;
    bottom: 16px;
    right: 16px;
    font-family: var(--font-mono);
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--secondary);
}

/* Terminal */
.terminal-panel {
    grid-column: 2;
    grid-row: 2;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0;
    background: #0a0a12;
}

.terminal-header {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    color: var(--text-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.terminal-status {
    color: #00ff88;
}

.terminal-body {
    padding: 16px;
    overflow-y: auto;
    color: #d0d0d0;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-line {
    opacity: 0.8;
    border-left: 2px solid transparent;
    padding-left: 8px;
}

.log-line.info { border-color: var(--accent); }
.log-line.warn { border-color: #ffcc00; color: #ffcc00; }
.log-line.error { border-color: #ff0055; color: #ff0055; }
.log-line.success { border-color: #00ff88; color: #00ff88; }

.ts {
    color: #666;
    margin-right: 8px;
}

/* Document Styles */
.document-wrapper {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
}

.document-wrapper h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
    background: linear-gradient(90deg, #fff, var(--text-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lead {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 32px;
    border-left: 4px solid var(--accent);
    padding-left: 16px;
}

h3 {
    margin: 32px 0 16px;
    color: var(--accent);
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 1rem;
    letter-spacing: 1px;
}

p {
    margin-bottom: 16px;
    color: #c0c0c0;
}

.metric-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 32px 0;
}

.card {
    background: rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.metric-val {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
}

.specs-table {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 24px 0;
}

.spec-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr 1fr;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.spec-row:last-child {
    border-bottom: none;
}

.spec-row.header {
    background: rgba(255, 255, 255, 0.05);
    font-weight: bold;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.spec-row span {
    font-size: 0.9rem;
}

/* Timeline */
.timeline {
    position: relative;
    margin: 32px 0;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -37px;
    top: 6px;
    width: 12px;
    height: 12px;
    background: var(--bg-dark);
    border: 2px solid var(--accent);
    border-radius: 50%;
}

.phase {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 0.8rem;
    margin-bottom: 4px;
}

/* Architecture specific */
.architecture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 32px;
}

.arch-card {
    background: rgba(255,255,255,0.03);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.arch-card h3 {
    margin-top: 0;
    font-size: 0.9rem;
}

.arch-card ul {
    list-style: none;
    padding: 0;
}

.arch-card li {
    margin-bottom: 8px;
    font-size: 0.85rem;
    padding-left: 16px;
    position: relative;
}

.arch-card li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent);
}

#architecture-canvas {
    height: 300px;
    width: 100%;
    background: #0f111a;
    border-radius: 8px;
    margin: 24px 0;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .side-nav {
        display: none;
    }
    .simulation-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .visualization-panel {
        grid-column: 1;
        grid-row: 2;
        height: 400px;
    }
    .terminal-panel {
        grid-column: 1;
        grid-row: 3;
    }
}