/* ============================================================
   NEXUS Portal - Distinctive cyber/terminal aesthetic
   Dark surface, electric accent, mono UI, serif italic for soul
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --bg: #0a0a0c;
  --bg-elev: #131318;
  --bg-elev-2: #1a1a22;
  --border: #26262e;
  --border-strong: #3a3a44;
  --text: #ececf0;
  --text-mute: #76767e;
  --text-faint: #4a4a52;
  --accent: #00ff9d;
  --accent-dim: #00b86f;
  --accent-glow: rgba(0, 255, 157, 0.18);
  --warn: #ffb547;
  --error: #ff5470;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

button {
  font-family: var(--mono);
  cursor: pointer;
  background: transparent;
  border: none;
  color: inherit;
}

.hidden { display: none !important; }
.dot { color: var(--text-faint); margin: 0 4px; }

/* ============================================================
   Grid background overlay - subtle scan
   ============================================================ */
.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 32px 32px;
  z-index: 0;
}
.grid-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top, transparent 0%, var(--bg) 80%);
}
.grid-overlay.subtle { opacity: 0.5; }

/* ============================================================
   Brand
   ============================================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark {
  color: var(--accent);
  font-size: 1.1em;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
.brand-text { font-size: 14px; }
.brand-accent { color: var(--accent); }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.auth-head { text-align: left; }
.auth-tag {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 8px;
  letter-spacing: 0.04em;
}

.auth-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 36px 32px 28px;
  box-shadow:
    0 0 0 1px rgba(0,255,157,0.04),
    0 30px 80px -20px rgba(0,0,0,0.8);
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 18px; height: 18px;
  border-top: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
}
.auth-card::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 18px; height: 18px;
  border-bottom: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
}

.auth-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  color: var(--text);
}
.auth-sub {
  font-size: 11px;
  color: var(--text-mute);
  margin: 6px 0 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-switch {
  font-size: 12px;
  color: var(--text-mute);
  text-align: center;
  margin-top: 16px;
}

.auth-foot {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 6px;
  align-items: center;
}

/* ============================================================
   FORMS
   ============================================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 18px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 18px;
  border: 1px solid var(--accent);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}
.btn-primary:hover {
  background: transparent;
  color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn-primary:disabled {
  background: var(--bg-elev-2);
  color: var(--text-faint);
  border-color: var(--border);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary.big {
  padding: 18px 22px;
  font-size: 13px;
}
.btn-arrow { font-size: 14px; }

.btn-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--accent); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-left: 2px solid var(--error);
  background: rgba(255, 84, 112, 0.08);
  color: var(--error);
  font-size: 12px;
  line-height: 1.5;
}
.alert.success {
  border-left-color: var(--accent);
  background: rgba(0, 255, 157, 0.08);
  color: var(--accent);
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-body {
  padding: 0;
  background: var(--bg);
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-mute);
}

.user-badge { color: var(--text); }
.queue-badge {
  color: var(--text-mute);
  padding: 3px 8px;
  border: 1px solid var(--border);
  font-size: 11px;
}
.queue-badge.busy {
  color: var(--warn);
  border-color: var(--warn);
}

.app-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1px;
  background: var(--border);
  min-height: calc(100vh - 57px);
  position: relative;
  z-index: 1;
}

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

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

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}

.panel-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
}

.panel-tag {
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================================
   CONTROL PANEL
   ============================================================ */
.control-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

.params-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-actions {
  margin-top: auto;
  padding-top: 24px;
}

/* Inline pair (e.g. width / height side by side) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ============================================================
   OUTPUT PANEL - Jobs / Gallery
   ============================================================ */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.7;
}
.empty-state .empty-mark {
  display: block;
  font-size: 48px;
  color: var(--text-faint);
  margin-bottom: 16px;
}

.job-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 16px;
  position: relative;
  transition: border-color 0.2s;
}
.job-card:hover { border-color: var(--border-strong); }

.job-card.queued { border-left: 2px solid var(--text-mute); }
.job-card.running {
  border-left: 2px solid var(--warn);
  box-shadow: inset 0 0 0 0 var(--warn);
  animation: pulse-border 1.4s ease-in-out infinite;
}
.job-card.done { border-left: 2px solid var(--accent); }
.job-card.error { border-left: 2px solid var(--error); }

@keyframes pulse-border {
  0%, 100% { box-shadow: -2px 0 0 var(--warn), 0 0 0 transparent; }
  50% { box-shadow: -2px 0 0 var(--warn), 0 0 14px var(--accent-glow); }
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.job-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}

.job-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid currentColor;
}
.job-status.queued { color: var(--text-mute); }
.job-status.running { color: var(--warn); }
.job-status.done { color: var(--accent); }
.job-status.error { color: var(--error); }

.job-prompt {
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.5;
  margin: 8px 0 12px;
  max-height: 4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.job-meta {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.job-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin-top: 12px;
}
.job-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.job-images img:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.job-error {
  font-size: 11px;
  color: var(--error);
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 84, 112, 0.06);
  border-left: 2px solid var(--error);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.95);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 32px;
  backdrop-filter: blur(4px);
}
.lightbox-inner {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
}
.lightbox img {
  max-width: 100%;
  max-height: 95vh;
  display: block;
  border: 1px solid var(--border-strong);
}
.lightbox-close {
  position: absolute;
  top: -36px;
  right: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  padding: 4px 8px;
}
.lightbox-close:hover { color: var(--accent); }

/* ============================================================
   SCROLLBARS
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
