/* Pisces Moon OS — IDE Styles
   Copyright (C) 2026 Eric Becker / Fluid Fortune
   SPDX-License-Identifier: AGPL-3.0-or-later */

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

:root {
  --bg-deep:    #0a0e14;
  --bg-panel:   #11161e;
  --bg-input:   #1a212c;
  --border:     #2a3441;
  --text-main:  #e6edf3;
  --text-dim:   #7a8590;
  --green:      #00ff88;
  --green-dim:  #00aa55;
  --amber:      #ffaa00;
  --red:        #ff4466;
  --blue:       #4499ff;
  --purple:     #aa88ff;
}

html, body {
  height: 100%;
  font-family: -apple-system, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text-main);
  overflow: hidden;
}

/* ─── TOP BAR ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 48px;
  background: linear-gradient(to bottom, #131a24, #0d121a);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  font-size: 22px;
  color: var(--green);
  text-shadow: 0 0 12px var(--green-dim);
}

.brand h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand .dim {
  color: var(--text-dim);
  font-weight: 400;
}

.brand .version {
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  margin-left: 4px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 6px 14px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: #232c38;
  border-color: var(--green-dim);
}

.btn.primary {
  background: var(--green-dim);
  color: var(--bg-deep);
  border-color: var(--green);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--green);
  box-shadow: 0 0 12px var(--green-dim);
}

/* ─── MAIN WORKSPACE ─── */
.workspace {
  display: grid;
  grid-template-columns: 240px 1fr 380px;
  height: calc(100vh - 48px);
}

.sidebar {
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 12px;
}

.sidebar.left  { border-right: 1px solid var(--border); }
.sidebar.right { border-left:  1px solid var(--border); }

.panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.panel-title:first-child { margin-top: 0; }

/* ─── APP TYPE TOGGLE ─── */
.app-type-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: 4px;
  padding: 2px;
}

.seg {
  flex: 1;
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
}

.seg.active {
  background: var(--green-dim);
  color: var(--bg-deep);
  font-weight: 600;
}

/* ─── FILE LIST ─── */
.file-list { list-style: none; }

.file-item {
  padding: 6px 8px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}

.file-item:hover { background: var(--bg-input); }

.file-item.active {
  background: var(--bg-input);
  color: var(--green);
}

.file-icon { font-size: 11px; opacity: 0.7; }

/* ─── API REFERENCE ─── */
.api-search input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
}

.api-search input:focus {
  outline: none;
  border-color: var(--green-dim);
}

.api-tree {
  margin-top: 8px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.api-cat {
  margin-bottom: 6px;
}

.api-cat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--amber);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.api-item {
  padding: 3px 6px;
  cursor: pointer;
  color: var(--text-dim);
  border-radius: 2px;
}

.api-item:hover {
  color: var(--text-main);
  background: var(--bg-input);
}

.api-item-name { color: var(--blue); }

/* ─── EDITOR PANE ─── */
.editor-pane {
  display: flex;
  flex-direction: column;
  background: #0d1117;
  overflow: hidden;
}

.editor-tabs {
  display: flex;
  background: #0a0e14;
  border-bottom: 1px solid var(--border);
  height: 32px;
}

.tab {
  padding: 7px 18px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: var(--text-dim);
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.tab.active {
  background: #0d1117;
  color: var(--green);
  border-bottom: 2px solid var(--green);
}

#editor {
  flex: 1;
  overflow: hidden;
}

.status-bar {
  display: flex;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
}

.status-spacer { flex: 1; }

#status-msg.success { color: var(--green); }
#status-msg.error   { color: var(--red); }
#status-msg.info    { color: var(--blue); }

/* ─── DEVICE PREVIEW ─── */
.device-frame {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

/* Device-picker pills above the canvas */
.device-picker {
  display: flex;
  gap: 4px;
  padding: 6px 8px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dev-pill {
  background: #0a0e14;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}
.dev-pill:hover {
  border-color: var(--green-dim);
  color: var(--green);
}
.dev-pill.active {
  background: var(--green-dim);
  color: #000;
  border-color: var(--green);
  font-weight: 600;
}
.dev-pill.kdt {
  /* KodeDot uses a different accent to flag "hypothetical" status */
  border-style: dashed;
}
.dev-pill.kdt.active {
  background: #ffb800;
  color: #000;
  border-color: #ffb800;
  border-style: solid;
}
.device-meta {
  padding: 4px 8px 8px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  border-bottom: 1px solid var(--border);
}
#device-meta-name { color: var(--green); font-weight: 600; }
#device-meta-res  { color: var(--blue);  }

/* Per-device bezel styles */
.device-bezel {
  background: linear-gradient(135deg, #1a1f2a, #0d1117);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.05),
    0 4px 16px rgba(0,0,0,0.4);
  transition: all 0.25s;
}
.device-bezel.bezel-tdeck {
  /* T-Deck Plus — rectangular, dark, standard handheld */
  border-radius: 12px;
  border-color: #2a3340;
}
.device-bezel.bezel-pager {
  /* T-LoRa Pager — wider aspect, top-corner rotary marker */
  border-radius: 10px;
  border-color: #3a3340;
  background: linear-gradient(135deg, #1a1a22, #0d0d14);
  position: relative;
}
.device-bezel.bezel-pager::before {
  content: '◉';
  position: absolute;
  top: 4px;
  right: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.device-bezel.bezel-cardputer {
  /* Cardputer ADV — orange M5 accent, brick proportions */
  border-radius: 6px;
  border-color: #d97706;
  background: linear-gradient(135deg, #1a1410, #0d0a08);
  padding: 8px;
}
.device-bezel.bezel-cardputer::after {
  content: 'NO PSRAM';
  position: absolute;
  bottom: 2px;
  right: 8px;
  font-size: 8px;
  color: #d97706;
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
}
.device-bezel.bezel-kodedot {
  /* KodeDot — round/square hybrid, amber dashed accent */
  border-radius: 24px;
  border-color: #ffb800;
  border-style: dashed;
  background: linear-gradient(135deg, #1a1a1f, #0a0a0d);
}
.device-bezel.bezel-c28p {
  /* C28P — kiosk fixture, deep blue accent, taller portrait aspect */
  border-radius: 8px;
  border-color: #2a4060;
  background: linear-gradient(135deg, #0d1422, #08101a);
  position: relative;
}
.device-bezel.bezel-c28p::after {
  content: 'KIOSK · AUDIO';
  position: absolute;
  bottom: 2px;
  right: 8px;
  font-size: 8px;
  color: #4080c0;
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
}

#preview-canvas {
  display: block;
  background: #000;
  border: 1px solid #333;
  image-rendering: pixelated;
  /* Width/height are set via JS on device switch; max sizes below cap layout */
  width: 320px;
  height: 240px;
  max-width: 100%;
  cursor: crosshair;
  outline: none;
  transition: width 0.25s, height 0.25s;
}

/* Per-device canvas display sizing — scaled to fit sidebar consistently
   while preserving aspect ratio. Canvas backing dims (set by JS via
   canvas.width / canvas.height) drive the pixel grid; CSS controls the
   visible rendering size. */
.bezel-tdeck     #preview-canvas { width: 320px; height: 240px; }
.bezel-pager     #preview-canvas { width: 360px; height: 167px; } /* 480x222 scaled to fit */
.bezel-cardputer #preview-canvas { width: 320px; height: 180px; } /* 240x135 scaled 1.33x for visibility */
.bezel-c28p      #preview-canvas { width: 240px; height: 320px; } /* 240x320 native portrait */
.bezel-kodedot   #preview-canvas { width: 320px; height: 320px; } /* 480x480 scaled */

#preview-canvas:focus {
  border-color: var(--green-dim);
}

.device-controls {
  margin-top: 8px;
  text-align: center;
}

.key-hint {
  font-size: 10px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
}

/* ─── CONSOLE ─── */
.console {
  background: #050810;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  height: 140px;
  overflow-y: auto;
  color: var(--green);
}

.console .line { margin-bottom: 2px; }
.console .err  { color: var(--red); }
.console .warn { color: var(--amber); }
.console .info { color: var(--blue); }
.console .ts   { color: var(--text-dim); margin-right: 6px; }

/* ─── HW STATS ─── */
.hw-stats { font-size: 12px; }

.hw-stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, monospace;
}
.hw-stat:last-child { border-bottom: none; }
.hw-stat span { color: var(--text-dim); }
.hw-stat b { color: var(--green); font-weight: 500; }

/* ─── MODALS ─── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-content h2 {
  color: var(--green);
  margin-bottom: 14px;
  font-size: 18px;
}

.modal-content h3 {
  color: var(--amber);
  margin: 18px 0 8px;
  font-size: 14px;
}

.modal-content p,
.modal-content li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-content ul {
  margin-left: 20px;
  margin-bottom: 12px;
}

.modal-content code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 2px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--green);
}

.modal-content table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
}

.modal-content td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.modal-content td:first-child {
  color: var(--blue);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}

.modal-content .btn { margin-top: 18px; }

/* ─── TEMPLATE GRID ─── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.template-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.template-card:hover {
  border-color: var(--green-dim);
  background: #1f2733;
}

.template-card h4 {
  color: var(--green);
  margin-bottom: 4px;
  font-size: 14px;
}

.template-card p {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ─── SCROLLBARS ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #3a4555; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 200px 1fr 340px;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .sidebar { max-height: 200px; }
}

/* ─── MOONSHOT BUTTON ─── */
.btn.moonshot {
  background: linear-gradient(90deg, #ff8c00, #ff4466);
  color: #fff;
  border-color: #ffaa44;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.btn.moonshot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.btn.moonshot:hover::before { transform: translateX(100%); }

.btn.moonshot:hover {
  box-shadow: 0 0 20px rgba(255, 100, 100, 0.5);
}

/* ─── BUILD MODAL ─── */
.build-modal-content {
  max-width: 580px;
  width: 90vw;
}

.build-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.moonshot-icon {
  font-size: 28px;
  background: linear-gradient(135deg, #ff8c00, #ff4466);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 18px rgba(255, 100, 100, 0.4);
}

.build-stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.build-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.3s;
}

.build-stage .stage-icon {
  font-size: 18px;
  color: var(--text-dim);
  width: 20px;
  text-align: center;
}

.build-stage.active {
  border-color: var(--green);
  background: rgba(0, 255, 136, 0.05);
}

.build-stage.active .stage-icon {
  color: var(--green);
}

.build-stage.done .stage-icon {
  color: var(--green);
}

.build-stage.done .stage-icon::before {
  content: "✓";
}

.build-stage.active .stage-icon::before {
  content: "◐";
  animation: spin 1.5s linear infinite;
  display: inline-block;
}

.build-stage.error {
  border-color: var(--red);
  background: rgba(255, 68, 102, 0.05);
}

.build-stage.error .stage-icon {
  color: var(--red);
}

.build-stage.error .stage-icon::before {
  content: "✗";
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.stage-detail {
  font-size: 11px;
  color: var(--text-dim);
}

.progress-bar-wrap {
  margin: 16px 0;
}

.progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  transition: width 0.3s;
  width: 0%;
}

.progress-msg {
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  margin-top: 6px;
}

.build-console {
  background: #050810;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  height: 140px;
  overflow-y: auto;
  color: var(--green);
  margin-bottom: 12px;
}

.build-console .err  { color: var(--red); }
.build-console .info { color: var(--blue); }

.build-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.build-note {
  font-size: 11px !important;
  color: var(--text-dim) !important;
  text-align: center;
  margin-top: 12px;
}

.build-note strong {
  color: var(--amber);
}
