/* ============================================================
   SNTQNBUY Creative Generation — Dark Premium Design System
   ============================================================ */

:root {
  /* Background layers */
  --bg-base:     #0A0A0B;
  --bg-surface:  #111113;
  --bg-elevated: #18181B;
  --bg-overlay:  #1E1E22;

  /* Borders */
  --line:        rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --ink:         #F4F4F5;
  --ink-2:       #A1A1AA;
  --ink-3:       #71717A;

  /* Accent — emerald */
  --accent:      #34D399;
  --accent-dim:  #059669;
  --accent-glow: #6EE7B7;
  --accent-bg:   rgba(52, 211, 153, 0.08);
  --accent-bg2:  rgba(52, 211, 153, 0.14);

  /* Danger */
  --danger:      #F87171;
  --danger-bg:   rgba(248, 113, 113, 0.1);

  /* Amber (admin role) */
  --amber:       #FBBF24;
  --amber-bg:    rgba(251, 191, 36, 0.1);

  /* Radius & shadow */
  --radius-sm:   10px;
  --radius:      14px;
  --radius-lg:   20px;
  --shadow:      0 8px 32px rgba(0, 0, 0, 0.48);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.32);

  font-family: "SF Pro Display", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* ── Base ── */
body {
  margin: 0;
  background: var(--bg-base);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(52,211,153,0.06) 0%, transparent 70%),
              var(--bg-base);
}

.auth-card {
  width: min(480px, 100%);
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.auth-logo {
  margin-bottom: 28px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 16px 20px;
  border-right: 1px solid var(--line);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand-logo {
  display: block;
  height: 32px;
  width: auto;
}

/* ── Nav ── */
.nav {
  display: grid;
  gap: 20px;
  flex: 1;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 0 10px;
  margin-bottom: 2px;
}

.nav-link,
button,
select,
input,
textarea {
  font: inherit;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}

.nav-link.is-active {
  border-color: var(--accent-dim);
  background: var(--accent-bg);
  color: var(--accent-glow);
}

.nav-icon {
  font-style: normal;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Sidebar footer ── */
.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
  padding: 28px 32px;
  background: var(--bg-base);
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--ink-2);
  margin: 0;
  font-size: 14px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Views ── */
.view {
  display: none;
}

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

/* ============================================================
   CARDS (stat tiles)
   ============================================================ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card,
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card {
  padding: 18px;
}

.card-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.panel h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* ============================================================
   LAYOUTS
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.grid-editor {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

/* ============================================================
   FORMS
   ============================================================ */
label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}

.field-note {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}

input,
select,
textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  padding: 9px 12px;
  background: var(--bg-elevated);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-dim);
}

select {
  cursor: pointer;
}

.editor {
  min-height: 560px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.scope-select {
  display: block;
  margin-bottom: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: #0A0A0B;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-glow);
}

button.ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
}

button.ghost:hover:not(:disabled) {
  background: var(--bg-overlay);
  color: var(--ink);
}

button.sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ============================================================
   PRESET SELECTOR
   ============================================================ */
.preset-selector-wrap {
  display: grid;
  gap: 8px;
}

.preset-label-text {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}

.preset-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--accent-dim);
  color: var(--ink);
}

.preset-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-bg2);
  color: var(--accent-glow);
}

.preset-label {
  font-weight: 600;
  font-size: 13px;
}

.preset-stars {
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.preset-cost {
  font-size: 11px;
  color: var(--ink-3);
}

/* ============================================================
   RESULT / STATUS BOXES
   ============================================================ */
.result-box {
  margin: 0;
  min-height: 44px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 12px;
  white-space: pre-wrap;
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0 0;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.spinner {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-title {
  font-weight: 600;
  color: var(--ink);
}

.loading-copy {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
}

.loading-meta {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 12px;
}

.progress-track {
  margin-top: 10px;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-glow) 100%);
  transition: width 0.3s ease;
  border-radius: 999px;
}

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

/* ============================================================
   FILE LIST (editor / outputs)
   ============================================================ */
.file-list {
  display: grid;
  gap: 6px;
  max-height: 640px;
  overflow-y: auto;
}

.file-item {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-item:hover {
  border-color: var(--line-strong);
  background: var(--bg-overlay);
}

.file-item.is-active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.file-item-path {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
  word-break: break-word;
}

/* ============================================================
   COURSE LIST
   ============================================================ */
.course-row {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.course-row:last-child {
  border-bottom: 0;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-bg);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--accent-glow);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.role-pill.owner {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.35);
  color: #c084fc;
}

.role-pill.editor {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

.role-pill.admin {
  background: var(--amber-bg);
  border-color: rgba(251, 191, 36, 0.25);
  color: var(--amber);
}

.role-pill.viewer {
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(100, 116, 139, 0.25);
  color: var(--muted);
}

.role-pill.owner {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.role-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
}
.role-select:hover { border-color: var(--accent); }
.role-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(52,211,153,.15); }

.course-title {
  font-weight: 600;
  color: var(--ink);
}

.course-meta {
  color: var(--ink-2);
  font-size: 13px;
  margin-top: 3px;
}

.course-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   STRUCTURED RESULT (generation output)
   ============================================================ */
.structured-result {
  display: grid;
  gap: 18px;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.result-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-section-head h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.card-stack {
  display: grid;
  gap: 10px;
}

.prompt-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg-elevated);
}

.prompt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.prompt-kicker {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.prompt-title {
  margin-top: 4px;
  font-weight: 600;
  color: var(--ink);
}

.copy-field {
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* ============================================================
   HISTORY
   ============================================================ */
.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 12px 14px;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--line-strong);
}

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

.history-title {
  font-weight: 600;
  color: var(--ink);
}

.history-meta {
  color: var(--ink-2);
  font-size: 13px;
}

/* ============================================================
   PROMPT LAB
   ============================================================ */
.prompt-lab-layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 18px;
  align-items: start;
}

.lab-col {
  min-height: 600px;
}

/* Messages */
.lab-messages {
  min-height: 340px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.lab-message {
  max-width: 92%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.lab-message.user {
  align-self: flex-end;
  background: var(--accent-bg2);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--ink);
}

.lab-message.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.lab-message.thinking {
  align-self: flex-start;
  color: var(--ink-3);
  font-style: italic;
  font-size: 13px;
}

/* Input row */
.lab-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

/* Diff box */
.lab-diff-box {
  min-height: 120px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.diff-added {
  color: var(--accent-glow);
  background: rgba(52, 211, 153, 0.08);
  border-radius: 3px;
}

.diff-removed {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
  text-decoration: line-through;
  border-radius: 3px;
}

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

/* ============================================================
   USER BADGE
   ============================================================ */
.user-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  font-size: 13px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-3);
  background: var(--bg-elevated);
  text-align: center;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .prompt-lab-layout {
    grid-template-columns: 1fr 1fr;
  }
  .lab-improve {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .grid-2,
  .grid-editor {
    grid-template-columns: 1fr;
  }

  .prompt-lab-layout {
    grid-template-columns: 1fr;
  }

  .lab-col {
    min-height: 400px;
  }
}

/* Inline action buttons (small, borderless) */
.btn-inline {
  display: inline-block;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  line-height: 1.5;
  vertical-align: middle;
  transition: background .15s, color .15s;
}
.btn-inline:hover { background: rgba(255,255,255,.13); color: var(--text); }
.btn-danger-inline { border-color: #f87171; color: #f87171; }
.btn-danger-inline:hover { background: rgba(248,113,113,.12); }
