/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0b0b12;
  --surface:     #111120;
  --surface-2:   #18182a;
  --surface-3:   #1f1f35;
  --border:      #252540;
  --border-2:    #2e2e50;
  --text:        #ddddf5;
  --text-dim:    #6868a0;
  --text-muted:  #44445a;
  --accent:      #6366f1;
  --accent-2:    #818cf8;
  --accent-glow: rgba(99,102,241,.25);
  --success:     #4ade80;
  --error:       #f87171;
  --warning:     #fbbf24;
  --terminal-bg: #07070e;
  --radius:      8px;
  --radius-sm:   5px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -.2px;
}

.logo svg { color: var(--accent-2); }

.sidebar-section-label {
  padding: 18px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.games-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.game-item {
  display: flex;
  flex-direction: column;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: 2px;
  transition: background .15s;
}
.game-item:hover { background: var(--surface-2); }
.game-item.active { background: var(--surface-3); }
.game-item.active .game-item-name { color: var(--accent-2); }

.game-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-item-appid {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.btn-add-game {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-add-game:hover {
  border-color: var(--accent);
  color: var(--accent-2);
  background: var(--accent-glow);
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.btn-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-settings:hover { background: var(--surface-2); color: var(--text); }

/* ── Main Wrap ────────────────────────────────────────────────────────────── */
.main-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}
.empty-icon { opacity: .3; margin-bottom: 8px; }
.empty-state h2 { font-size: 18px; color: var(--text-dim); }
.empty-state p  { font-size: 13px; }

/* ── Game Header ──────────────────────────────────────────────────────────── */
.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.game-header-info { display: flex; flex-direction: column; gap: 5px; }

.game-appid-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent-2);
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 4px;
  padding: 2px 8px;
  width: fit-content;
}
.game-appid-badge::before { content: 'AppID '; color: var(--text-dim); }

.game-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
}

.game-header-actions { display: flex; gap: 8px; padding-top: 4px; }

/* ── Section Labels ───────────────────────────────────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Depots Grid ──────────────────────────────────────────────────────────── */
.depots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.depot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
}
.depot-card:hover { border-color: var(--border-2); }
.depot-card.ready { border-color: rgba(74,222,128,.25); }

.depot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.depot-info {}
.depot-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.depot-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.depot-status {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}
.depot-status.ready    { background: rgba(74,222,128,.12); color: var(--success); border: 1px solid rgba(74,222,128,.2); }
.depot-status.no-files { background: rgba(248,113,113,.1); color: var(--error); border: 1px solid rgba(248,113,113,.2); }

.depot-files {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  flex: 1;
}

.depot-files .file-entry {
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.depot-files .more {
  color: var(--text-muted);
  font-style: italic;
}

.btn-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  width: 100%;
}
.btn-upload:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--accent);
}

/* ── Deploy Panel ─────────────────────────────────────────────────────────── */
.deploy-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.deploy-form { display: flex; flex-direction: column; gap: 16px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-row .field-sm { }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.field input {
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus { border-color: var(--accent); }

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Branch selector ──────────────────────────────────────────────────────── */
.branch-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.branch-row select {
  flex: 1;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.branch-row select:focus { border-color: var(--accent); }
.branch-row select option { background: var(--surface-2); }

.branch-row input {
  width: 120px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.branch-row input::placeholder { color: var(--text-muted); }
.branch-row input:focus { border-color: var(--accent); }

.branch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 2px 8px 2px 10px;
  font-size: 11px;
  color: var(--text-dim);
}

.branch-tag-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  line-height: 1;
  transition: color .12s;
}
.branch-tag-remove:hover { color: var(--error); }

/* ── Depot checkbox ───────────────────────────────────────────────────────── */
.depot-check-label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.depot-checkbox {
  margin-top: 2px;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.depot-checkbox:disabled { cursor: not-allowed; opacity: .4; }

.deploy-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.deploy-status {
  font-size: 13px;
  font-weight: 500;
}
.deploy-status.success { color: var(--success); }
.deploy-status.error   { color: var(--error); }
.deploy-status.running { color: var(--accent-2); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  outline: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
  box-shadow: 0 0 30px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-danger-ghost:hover { color: var(--error); border-color: rgba(248,113,113,.3); }

.btn-sm { padding: 6px 11px; font-size: 12px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ── Terminal ─────────────────────────────────────────────────────────────── */
.terminal-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--terminal-bg);
  border-top: 1px solid var(--border);
  height: 220px;
  transition: height .2s ease;
}

.terminal-panel.collapsed { height: 36px; overflow: hidden; }

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  height: 36px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.terminal-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: background .3s;
}
.terminal-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }

.terminal-actions { display: flex; gap: 4px; }

.terminal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  border-radius: 3px;
  transition: all .12s;
}
.terminal-btn:hover { background: var(--surface-2); color: var(--text-dim); }

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
}

.terminal-line { white-space: pre-wrap; word-break: break-all; }
.terminal-line.output  { color: #c8c8e8; }
.terminal-line.info    { color: var(--accent-2); }
.terminal-line.status  { color: var(--text-dim); }
.terminal-line.phase   { color: var(--warning); font-weight: 600; }
.terminal-line.success { color: var(--success); font-weight: bold; }
.terminal-line.error   { color: var(--error); }
.terminal-line.dim     { color: var(--text-muted); }

.terminal-progress {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
}
.prog-label { color: var(--warning); font-weight: 600; min-width: 72px; }
.prog-bar   { color: var(--accent-2); letter-spacing: 1px; }
.prog-mb    { color: var(--text-dim); min-width: 80px; text-align: right; }
.prog-pct   { color: var(--success); font-weight: bold; min-width: 36px; text-align: right; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: modal-in .15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all .12s;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Depots Editor ────────────────────────────────────────────────────────── */
.depots-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.depot-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  gap: 8px;
  align-items: center;
}

.depot-edit-row input {
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.depot-edit-row input::placeholder { color: var(--text-muted); }
.depot-edit-row input:focus { border-color: var(--accent); }

.btn-remove-depot {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 6px;
  transition: all .12s;
  line-height: 1;
}
.btn-remove-depot:hover { color: var(--error); border-color: rgba(248,113,113,.3); }

/* ── Dropzone ─────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  transition: all .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
}
.dropzone-content svg { color: var(--text-muted); }
.dropzone-hint { font-size: 11px; color: var(--text-muted); }

.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width .2s ease;
  width: 0%;
}
.progress-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
