/**
 * GCSE Data Representation & Bitmaps Module Stylesheet
 * Integrates with shared/styles.css
 */
@import url('../../shared/styles.css');

/* Main Module Container */
.module-container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 20px 48px 20px;
  position: relative;
  z-index: 1;
}

/* Tab Navigation */
.view-tabs {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  gap: 4px;
}

.view-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.view-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.view-tab-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

/* Tab Views */
.tab-view {
  display: none;
  animation: fadeIn 200ms ease-out forwards;
}

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

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

/* Sub-header / Overview Banner */
.view-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.banner-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.banner-text h2 {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}

.banner-text p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0;
}

/* 2-Column Workspace Grid for Tab 1 */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (min-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

/* Panels */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  display: flex;
  flex-direction: column;
  position: relative;
  backdrop-filter: blur(12px);
}

.panel-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Controls Toolbar */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.control-select, .control-btn {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.control-select:hover, .control-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.control-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

/* Pixel Canvas Container */
.canvas-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  overflow: auto;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.pixel-grid {
  display: grid;
  gap: 1px;
  background: #334155;
  padding: 2px;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

.pixel-cell {
  background: #ffffff;
  width: 28px;
  height: 28px;
  cursor: pointer;
  transition: transform 60ms ease-out, filter 60ms ease-out;
  position: relative;
}

@media (max-width: 640px) {
  .pixel-cell {
    width: 18px;
    height: 18px;
  }
}

.pixel-cell:hover {
  filter: brightness(1.2);
  outline: 2px solid var(--accent-primary);
  outline-offset: -1px;
  z-index: 2;
}

.pixel-cell.active-bit-hover {
  outline: 2px solid #ec4899;
  z-index: 3;
}

/* Palette Swatches Bar */
.palette-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-sizing: border-box;
  width: 100%;
}

.palette-swatch {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.palette-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.palette-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary), 0 4px 12px rgba(99, 102, 241, 0.4);
  transform: scale(1.12);
}

.palette-swatch .swatch-label {
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 9px;
  pointer-events: none;
}

/* Calculation & Metadata Inspector Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  line-height: 1.2;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Calculation Formula Box */
.formula-box {
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
}

.formula-header {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-soft-text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.formula-step {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border-left: 3px solid var(--accent-primary);
  line-height: 1.5;
  overflow-x: auto;
}

.formula-step strong {
  color: #34d399;
}

/* Metadata Switch & Breakdown */
.metadata-toggle-card {
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

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

.metadata-breakdown {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.metadata-breakdown.visible {
  display: block;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-elevated);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 4px 4px 0 0;
}

/* Bottom Split View Pane */
.split-pane-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  .split-pane-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.stream-output-box {
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
  max-height: 240px;
  overflow-y: auto;
  word-break: break-all;
  color: var(--text-secondary);
}

.byte-block {
  display: inline-block;
  padding: 1px 4px;
  margin: 1px 2px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 11.5px;
  transition: background var(--transition-fast);
}

.byte-block:hover, .byte-block.highlight {
  background: var(--accent-primary);
  color: #ffffff;
}

.rle-run-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  margin: 3px;
  border-radius: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 120ms ease-out;
  user-select: none;
}

.rle-run-chip:hover, .rle-run-chip.active-rle {
  background: rgba(99, 102, 241, 0.22);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary), 0 2px 10px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

.pixel-cell.rle-highlighted {
  outline: 2px solid #38bdf8 !important;
  outline-offset: -1px;
  z-index: 10;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.95);
  filter: brightness(1.4) !important;
}

.rle-color-sample {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
}

/* Compression Stats Bar */
.compression-meter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.meter-track {
  width: 100%;
  height: 8px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Tab 2: Comparison Mode */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (min-width: 900px) {
  .comparison-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.comparison-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.comparison-canvas-frame {
  width: 100%;
  height: 280px;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}

.comparison-canvas-frame canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

/* Network Speed Simulator */
.network-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  margin-bottom: 24px;
}

.speed-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px 0;
}

.speed-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.speed-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

.speed-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.network-results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Tab 3: Revision Cards & Traps */
.trap-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 18px;
}

.trap-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.trap-title {
  font-size: 16px;
  font-weight: 800;
  color: #fbbf24;
  margin: 0;
}

.qa-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.qa-card:hover {
  border-color: var(--border-hover);
}

.qa-header {
  padding: 18px 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  user-select: none;
}

.qa-question {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
}

.qa-body {
  display: none;
  padding: 0 22px 20px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-root);
}

.qa-body.revealed {
  display: block;
}

.mark-scheme-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mark-badge {
  background: var(--bg-success-soft);
  color: var(--text-success);
  border: 1px solid var(--border-success);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Sound Sampling View */
.sound-canvas-container {
  position: relative;
  width: 100%;
  background: var(--bg-root);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  overflow: hidden;
}

.sound-wave-canvas {
  width: 100%;
  height: 280px;
  display: block;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
}

.waveform-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 14px;
  height: 4px;
  border-radius: 2px;
}

/* Photo Lab & Extended Palette Controls */
.photo-sample-btn.active, .photo-depth-btn.active {
  background: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
  color: #ffffff !important;
}

#full256PaletteGrid::-webkit-scrollbar {
  width: 6px;
}
#full256PaletteGrid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}
#full256PaletteGrid::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

.sound-wave-canvas {
  touch-action: none;
  cursor: crosshair;
}
