/* VGA 13h WASM Playground Styles */

:root {
    --bg-dark: #000428;
    --bg-light: #004e92;
    --cyan: #00FFFF;
    --magenta: #FF00FF;
    --yellow: #FFFF00;
    --green: #00FF00;
    --red: #FF0066;
    --panel-bg: rgba(0, 20, 40, 0.9);
    --border: #00FFFF;
}

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-light) 100%);
    color: var(--cyan);
    min-height: 100vh;
    overflow-x: hidden;
}

.scanline-overlay {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 9999;
    opacity: 0.3;
}

.header {
    text-align: center;
    padding: 30px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid var(--cyan);
    position: relative;
}

.title {
    font-family: 'Press Start 2P', cursive;
    font-size: 32px;
    color: var(--cyan);
    text-shadow: 0 0 10px var(--cyan), 0 0 20px var(--magenta);
    margin-bottom: 10px;
}

.subtitle {
    font-family: 'VT323', monospace;
    font-size: 20px;
    color: var(--yellow);
}

.main-container {
    display: grid;
    grid-template-columns: 40% 60px 1fr;
    gap: 0;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

.panel {
    background: var(--panel-bg);
    border: 2px solid var(--border);
    padding: 15px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--yellow);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--cyan);
}

.metrics {
    display: flex;
    gap: 15px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: var(--green);
}

.ai-prompt-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#aiPrompt {
    flex: 1;
    background: #000;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

#aiPrompt::placeholder {
    color: rgba(0, 255, 255, 0.5);
}

.examples-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.examples-bar select {
    flex: 1;
    background: #000;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 8px;
    font-family: 'Courier New', monospace;
}

#codeEditor {
    width: 100%;
    height: 400px;
    background: #000;
    border: 1px solid var(--cyan);
    color: var(--green);
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    tab-size: 2;
}

.error-display {
    display: none;
    background: #000;
    border: 1px solid var(--red);
    color: var(--red);
    padding: 10px;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
}

.editor-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.dos-button {
    background: linear-gradient(180deg, #444 0%, #222 100%);
    border: 2px solid var(--cyan);
    color: var(--cyan);
    padding: 12px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.1s;
    text-shadow: 0 0 5px var(--cyan);
}

.dos-button:hover {
    background: linear-gradient(180deg, #555 0%, #333 100%);
    box-shadow: 0 0 10px var(--cyan);
}

.dos-button:active {
    transform: translateY(2px);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.dos-button.primary {
    border-color: var(--yellow);
    color: var(--yellow);
    text-shadow: 0 0 5px var(--yellow);
}

.dos-button.primary:hover {
    box-shadow: 0 0 10px var(--yellow);
}

.dos-button.generate-btn {
    border-color: var(--magenta);
    color: var(--magenta);
    text-shadow: 0 0 5px var(--magenta);
}

.dos-button.generate-btn:hover {
    box-shadow: 0 0 10px var(--magenta);
}

.control-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 10px;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(180deg, #444 0%, #222 100%);
    border: 2px solid var(--cyan);
    color: var(--cyan);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.1s;
}

.control-btn:hover {
    background: linear-gradient(180deg, #555 0%, #333 100%);
    box-shadow: 0 0 10px var(--cyan);
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 20px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    text-align: center;
}

#fpsSlider {
    writing-mode: bt-lr;
    -webkit-appearance: slider-vertical;
    height: 100px;
}

.crt-monitor {
    position: relative;
    background: #000;
    padding: 20px;
    border: 4px solid #333;
    border-radius: 10px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

.crt-monitor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
    z-index: 1;
}

.crt-monitor.no-scanlines::before {
    display: none;
}

#vgaCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 1280px;
    height: 960px;
    margin: 0 auto;
    background: #000;
    position: relative;
    z-index: 0;
}

.crt-monitor:not(.no-crt) #vgaCanvas {
    filter: contrast(1.1) brightness(1.05);
}

.display-controls {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    filter: grayscale(1);
    transition: filter 0.2s;
}

.icon-btn:hover {
    filter: grayscale(0);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--cyan);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
}

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

.modal-header h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    color: var(--yellow);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--red);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body section {
    margin-bottom: 30px;
}

.modal-body h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--cyan);
    margin-bottom: 15px;
}

.help-text {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: var(--green);
    margin-bottom: 10px;
}

#promptTemplate {
    width: 100%;
    min-height: 150px;
    background: #000;
    border: 1px solid var(--cyan);
    color: var(--green);
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
}

.char-count {
    text-align: right;
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: var(--yellow);
    margin-top: 5px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.scale-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.scale-control select {
    background: #000;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 8px;
    font-family: 'Courier New', monospace;
}

.memory-inspector {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 300px;
    background: var(--panel-bg);
    border: 2px solid var(--yellow);
    z-index: 999;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.3);
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--yellow);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--yellow);
}

.hex-dump {
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--green);
    overflow-y: auto;
    max-height: 250px;
}

.footer {
    text-align: center;
    padding: 30px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 2px solid var(--cyan);
    margin-top: 40px;
}

.footer p {
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: var(--cyan);
    margin: 10px 0;
}

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

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

.footer .tip {
    color: var(--green);
    font-style: italic;
    margin-top: 15px;
}

@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .control-bar {
        flex-direction: row;
        justify-content: center;
    }
    
    #fpsSlider {
        writing-mode: initial;
        -webkit-appearance: slider-horizontal;
        width: 150px;
        height: auto;
    }
    
    #vgaCanvas {
        width: 640px;
        height: 480px;
    }
}

@media (max-width: 768px) {
    .title {
        font-size: 20px;
    }
    
    .subtitle {
        font-size: 16px;
    }
    
    #vgaCanvas {
        width: 320px;
        height: 240px;
    }
    
    .dos-button {
        font-size: 9px;
        padding: 10px 15px;
    }
}