/**
 * BEERUS PHOTO — RETRO-OS 1980S MASTER STYLESHEET (src/index.css)
 * [Khu vực 1 - Design SSOT] Tuân thủ tuyệt đối skill `ux-ui-beerus-retro`:
 * - Nền giấy kỹ thuật #FAF6EE, khay cửa sổ #EFECE6, cam tín hiệu #FF4814
 * - Viền khung 2px solid #18181B + bóng cứng 6px 6px 0px #18181B
 * - Màn hình đo sáng CRT #141417
 */

:root {
  --bg-canvas: #FAF6EE;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EFECE6;
  --bg-oscilloscope: #141417;
  --text-primary: #18181B;
  --text-secondary: #3F3F46;
  --text-muted: #71717A;
  --accent-orange: #FF4814;
  --accent-orange-hover: #E03A0B;
  --accent-amber: #F59E0B;
  --crt-green: #00E5A3;
  --border-ink: 2px solid #18181B;
  --shadow-hard: 6px 6px 0px #18181B;
  --shadow-hard-sm: 3px 3px 0px #18181B;
  --bevel-light: inset 2px 2px 0px #FFFFFF, inset -2px -2px 0px #D6D1C4;
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

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

html, body {
  width: 100%;
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(rgba(24, 24, 27, 0.14) 1px, transparent 0);
  background-size: 16px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
}

.retro-container-fluid {
  width: 100vw;
  min-height: 100dvh;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* TOPBAR */
.retro-topbar {
  background: var(--bg-subtle);
  border: var(--border-ink);
  box-shadow: var(--shadow-hard);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-sun {
  width: 40px;
  height: 40px;
  background: var(--accent-orange);
  border: var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 15px;
  display: grid;
  place-items: center;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.telemetry-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crt-pill {
  background: var(--bg-oscilloscope);
  color: #FAF6EE;
  border: var(--border-ink);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #71717A;
}

.led-dot.ready {
  background: var(--crt-green);
  box-shadow: 0 0 6px var(--crt-green);
}

.led-dot.orange {
  background: var(--accent-amber);
  box-shadow: 0 0 6px var(--accent-amber);
}

/* LƯỚI 3 CỘT FULL-VIEWPORT */
.retro-workstation-3col {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(440px, 1.45fr) minmax(320px, 1.05fr);
  gap: 14px;
  align-items: stretch;
}

.retro-col-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.retro-window {
  background: var(--bg-surface);
  border: var(--border-ink);
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
}

.retro-window.fill-height {
  flex: 1;
}

.retro-window-header {
  background: var(--accent-orange);
  color: #FFFFFF;
  border-bottom: var(--border-ink);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.retro-window-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.retro-window-stripes {
  flex: 1;
  height: 10px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.45) 0px,
    rgba(255, 255, 255, 0.45) 2px,
    transparent 2px,
    transparent 5px
  );
}

.retro-window-controls {
  display: flex;
  gap: 4px;
}

.retro-win-dot {
  width: 16px;
  height: 16px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1.5px solid #18181B;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.retro-window-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* BUTTONS */
.retro-btn {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: var(--border-ink);
  box-shadow: var(--bevel-light), var(--shadow-hard-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.retro-btn:hover {
  background: #E5E0D5;
}

.retro-btn:active,
.retro-btn.active {
  transform: translate(2px, 2px);
  box-shadow: none;
  background: var(--accent-orange);
  color: #FFFFFF;
}

.retro-btn.primary {
  background: var(--accent-orange);
  color: #FFFFFF;
}

.retro-btn.primary:hover {
  background: var(--accent-orange-hover);
}

.retro-btn.sm {
  font-size: 10.5px;
  padding: 4px 8px;
}

/* KHAY THẢ ẢNH THÔ (RAW DROPZONE) */
.raw-dropzone {
  background: var(--bg-subtle);
  border: 2px dashed #18181B;
  padding: 14px 10px;
  text-align: center;
  transition: background 0.15s ease;
}

.raw-dropzone.dragover {
  background: #FFE5DC;
  border-color: var(--accent-orange);
}

.raw-dropzone-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-primary);
}

.raw-dropzone-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* MÀN HÌNH CRT ĐO SÁNG & TELEMETRY */
.crt-screen {
  background: var(--bg-oscilloscope);
  color: #FAF6EE;
  border: var(--border-ink);
  padding: 9px;
  font-family: var(--font-mono);
}

.crt-readout-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.crt-metric-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #27272A;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crt-metric-label {
  font-size: 9px;
  color: #A1A1AA;
}

.crt-metric-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--crt-green);
}

/* KHO PRESET MÀU */
.preset-grid-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 2px;
}

.preset-item-card {
  background: var(--bg-subtle);
  border: 1.5px solid #18181B;
  padding: 7px 9px;
  cursor: pointer;
}

.preset-item-card:hover {
  background: #E5E0D5;
}

.preset-item-card.active {
  background: #FFF1EC;
  border: 2px solid var(--accent-orange);
  box-shadow: var(--shadow-hard-sm);
}

.preset-item-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.preset-item-desc {
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

/* BÀN SOI ẢNH BEFORE / AFTER */
.photo-viewport-stage {
  position: relative;
  flex: 1;
  min-height: 360px;
  background: var(--bg-oscilloscope);
  border: var(--border-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

#photoPreviewCanvas {
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
  display: block;
  border: 1.5px solid #27272A;
  cursor: ew-resize;
}

.split-tag {
  position: absolute;
  top: 12px;
  background: rgba(20, 20, 23, 0.86);
  color: #FAF6EE;
  border: 1.5px solid #18181B;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  pointer-events: none;
}

.split-tag.left {
  left: 12px;
}

.split-tag.right {
  right: 12px;
  color: var(--crt-green);
}

/* BÀN TRƯỢT 12 KÊNH QUANG HỌC */
.sliders-scroll-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  background: var(--bg-subtle);
  border: var(--border-ink);
  padding: 9px;
  max-height: 295px;
  overflow-y: auto;
}

.grade-slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.grade-slider-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
}

.grade-slider-val {
  color: var(--accent-orange);
}

.grade-range-input {
  width: 100%;
  accent-color: var(--accent-orange);
  cursor: pointer;
}

/* LỊCH SỬ CLOUD D1 */
.d1-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.d1-history-card {
  background: var(--bg-subtle);
  border: 1.5px solid #18181B;
  padding: 6px 8px;
}

/* THÔNG BÁO */
.retro-notice {
  display: none;
  background: var(--bg-oscilloscope);
  color: var(--crt-green);
  border: var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.retro-notice.show {
  display: flex;
}

.retro-notice.error {
  color: #FCA5A5;
}

@media (max-width: 1180px) {
  .retro-workstation-3col {
    grid-template-columns: 1fr;
  }
}
