/* Global Reset & Base Styling */
:root {
  --bg-color: #05060b;
  --panel-bg: rgba(13, 16, 27, 0.75);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(0, 240, 255, 0.15);
  
  --text-main: #f0f3fa;
  --text-muted: #8a92b2;
  
  --accent-cyan: #00f0ff;
  --accent-pink: #ff007f;
  --accent-yellow: #ffee00;
  
  --shadow-cyan: 0 0 15px rgba(0, 240, 255, 0.4);
  --shadow-pink: 0 0 15px rgba(ff, 0, 127, 0.4);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Glowing Accents */
.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(255, 0, 127, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(13, 16, 27, 1) 0%, #030407 100%);
  background-size: cover;
}

/* Layout Utilities */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.text-center {
  text-align: center;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin: 25px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.divider:not(:empty)::before {
  margin-right: .75em;
}

.divider:not(:empty)::after {
  margin-left: .75em;
}

/* Header Styling */
header {
  border-bottom: 1px solid var(--border-color);
  background: rgba(5, 6, 11, 0.8);
  backdrop-filter: blur(8px);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

header .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: pulse 2s infinite;
}

.status-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 240, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

/* Glassmorphism Panel system */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: rgba(0, 240, 255, 0.15);
  box-shadow: 0 8px 32px 0 rgba(0, 240, 255, 0.02), 0 0 15px var(--border-glow);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.panel-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-main);
}

.panel-num {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--accent-pink);
  background: rgba(255, 0, 127, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 0, 127, 0.2);
}

.accent-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--accent-cyan);
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
}

/* Quick Demo Selector */
.demo-selector-card {
  padding: 16px 24px;
  margin-top: 24px;
}
.demo-selector-card .panel-header {
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: none;
}
.demo-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Layout Grid */
.grid-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

/* Inputs & Forms */
.input-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.url-input-wrapper {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 6px;
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

input[type="text"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 12px 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  text-transform: uppercase;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 4px 14px rgba(0, 240, 255, 0.2);
}

.btn-primary:hover {
  background: #33f3ff;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4), var(--shadow-cyan);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.btn-action {
  background: linear-gradient(135deg, rgba(20, 24, 40, 0.8), rgba(10, 12, 22, 0.9));
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 16px 24px;
  font-size: 0.85rem;
  flex: 1;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-action:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
  transform: translateY(-2px);
}

.btn-action:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-pink), #cc0066);
  color: #fff;
  border: none;
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff3399, #e60073);
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.4), var(--shadow-pink);
  transform: translateY(-2px);
}

.btn-icon {
  margin-right: 8px;
}

/* File Upload Row & Drag zones */
.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-box {
  background: rgba(0, 0, 0, 0.25);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 20px 10px;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.upload-box:hover, .upload-box.dragover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.02);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.upload-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
  transition: var(--transition);
}

.upload-box:hover .upload-icon {
  transform: scale(1.15);
}

.upload-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.upload-subtext {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.file-info-badge {
  margin-top: 10px;
  font-size: 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.upload-box.file-loaded {
  border-style: solid;
  border-color: var(--accent-pink);
  background: rgba(255, 0, 127, 0.02);
}

.upload-box.file-loaded .file-info-badge {
  background: rgba(255, 0, 127, 0.1);
  border-color: rgba(255, 0, 127, 0.3);
  color: var(--accent-pink);
  font-weight: 600;
}

/* Settings Panels Elements */
.settings-group {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.15);
}

legend {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0 8px;
  color: var(--accent-cyan);
}

/* Custom Radios */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-container {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  user-select: none;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  margin-bottom: 0;
}

.radio-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radio-checkmark {
  position: absolute;
  top: 4px;
  left: 0;
  height: 16px;
  width: 16px;
  background-color: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  transition: var(--transition);
}

.radio-container:hover input ~ .radio-checkmark {
  border-color: var(--accent-cyan);
}

.radio-container input:checked ~ .radio-checkmark {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.radio-checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.radio-container input:checked ~ .radio-checkmark:after {
  display: block;
}

.radio-container .radio-checkmark:after {
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #000;
}

.radio-label-desc {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label-desc .title {
  font-weight: 600;
  font-size: 0.85rem;
}

.radio-label-desc .desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Custom Switch Toggle */
.toggle-setting {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.switch-container {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  margin-bottom: 0;
}

.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  transition: .4s;
  border-radius: 34px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .4s;
  border-radius: 50%;
}

.switch-container input:checked + .switch-slider {
  background-color: rgba(255, 0, 127, 0.2);
  border-color: var(--accent-pink);
}

.switch-container input:checked + .switch-slider:before {
  transform: translateX(22px);
  background-color: var(--accent-pink);
  box-shadow: 0 0 8px var(--accent-pink);
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-text .title {
  font-weight: 600;
  font-size: 0.85rem;
}

.toggle-text .desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Select Control */
.select-group {
  margin-bottom: 16px;
}

select {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

select:focus {
  border-color: var(--accent-cyan);
}

/* Slider Controls */
.slider-group {
  margin-bottom: 16px;
}

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

.slider-header label {
  margin-bottom: 0;
}

.slider-val {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
  outline: none;
  border: 1px solid var(--border-color);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: var(--shadow-cyan);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Previews Component */
.previews-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.preview-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.preview-frame {
  aspect-ratio: 4/3;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#original-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder-icon {
  font-size: 2.2rem;
  opacity: 0.15;
}

/* Speccy Screen BG pattern */
.speccy-border-bg {
  background-color: #d3d3d3; /* Standard light-gray Speccy border color */
  padding: 10px; /* simulating the border */
}

#speccy-canvas {
  width: 100%;
  height: auto;
  display: block;
  background-color: #000;
  image-rendering: pixelated;
}

/* Metrics Dashboard */
.compilation-metrics {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.05);
}

.metric:last-of-type {
  border-bottom: none;
  margin-bottom: 12px;
  padding-bottom: 0;
}

.metric.highlight {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  color: var(--accent-cyan);
}

.metric-label {
  color: var(--text-muted);
}

.metric-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
}

.memory-bar-wrapper {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  height: 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
  transition: width 0.5s ease-out;
}

.memory-bar-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 900;
  color: #fff;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Emulator Panel & CRT Monitor Casing */
.emulator-outer {
  display: flex;
  justify-content: center;
  margin: 15px 0 20px 0;
}

/* CRT Screen Chassis */
.crt-monitor-case {
  background: radial-gradient(circle at 50% 10%, #30333e 0%, #15171d 100%);
  border: 10px solid #20222a;
  border-radius: 24px;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.6), 
    inset 0 2px 5px rgba(255, 255, 255, 0.1),
    0 0 20px rgba(0, 0, 0, 0.4);
  padding: 20px;
  width: 100%;
  max-width: 440px;
}

.crt-screen-wrapper {
  background: #111;
  border-radius: 12px;
  padding: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 1);
}

/* Reflection overlays & CRT curved effect */
.crt-screen-wrapper::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.08) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  z-index: 2;
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
}

.crt-screen-wrapper::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.12) 100%);
  z-index: 3;
  pointer-events: none;
  border-radius: 12px;
}

.crt-screen {
  background: #222;
  border-radius: 4px;
  overflow: hidden;
}

/* TV screen container for border color changes */
.speccy-tv-border {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.05s ease;
  background-color: #ffffff; /* standard spectrum loading border (flashes) */
}

#emulator-canvas {
  width: 80%; /* 256 pixels in a 320 boundary = 80% */
  height: auto;
  image-rendering: pixelated;
  background-color: #000;
  box-shadow: 0 0 10px rgba(0,0,0,0.8);
}

.retro-badge {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.55rem;
  color: #5d637c;
  text-align: center;
  margin-top: 14px;
  letter-spacing: 0.1em;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.8);
}

.emulator-controls {
  display: flex;
  gap: 16px;
  margin-top: 15px;
}

.tape-status {
  text-align: center;
  margin-top: 12px;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.5rem;
  color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  line-height: 1.5;
}

/* Footer style */
footer {
  margin-top: 60px;
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Responsive breakpoint */
@media(max-width: 900px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* Action button pulse highlight when tape compiled */
@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(0, 240, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

.pulse-glow {
  animation: btnPulse 1.5s infinite !important;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

/* Horizontal select row layout */
.select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.select-row .select-group {
  margin-bottom: 0;
}

@media(max-width: 500px) {
  .select-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Sticky Preview Panel for Desktop View */
@media(min-width: 901px) {
  .column-right {
    align-self: stretch;
  }
  
  #preview-panel {
    position: sticky;
    top: 100px; /* Offset to clear the floating header */
    z-index: 5;
  }
}
