/* ============================================================
   BatchBinary Internal AI — Stylesheet
   Theme: Utilitarian Dark · Monospace · Precision Grid
   ============================================================ */

/* ── Custom properties ──────────────────────────────────────── */
:root {
  --bg:           #0c0d0f;
  --surface:      #141618;
  --surface-2:    #1c1e22;
  --surface-3:    #24272d;
  --border:       #2a2d35;
  --border-light: #353942;
  --accent:       #00e5b0;       /* BB teal */
  --accent-dim:   #00b38a;
  --accent-glow:  rgba(0, 229, 176, 0.15);
  --danger:       #ff4d6d;
  --warn:         #f0a500;
  --text-primary: #e8eaee;
  --text-secondary: #8b909e;
  --text-muted:   #545a69;
  --user-bg:      #1a2535;
  --user-border:  #2a3d55;
  --font-mono:    "JetBrains Mono", "Fira Code", monospace;
  --font-sans:    "Syne", "Trebuchet MS", sans-serif;
  --radius:       6px;
  --radius-lg:    10px;
  --sidebar-w:    260px;
  --transition:   0.18s ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; }
textarea { font-family: inherit; font-size: inherit; resize: none; outline: none; border: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }

/* ── Layout ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.main {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar header ─────────────────────────────────────────── */
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.logo-bracket { color: var(--accent); }
.logo-text    { color: var(--text-primary); }

.logo-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Mode nav ───────────────────────────────────────────────── */
.mode-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.mode-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.mode-btn.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 176, 0.25);
}

.mode-icon {
  font-size: 16px;
  opacity: 0.9;
  line-height: 1;
}

/* ── Param panels ───────────────────────────────────────────── */
.param-panel {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.param-row--stack {
  flex-direction: column;
  align-items: flex-start;
}

.param-val {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--border-light);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.system-input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  width: 100%;
  transition: border-color var(--transition);
}

.system-input:focus {
  border-color: var(--accent);
}

.system-input::placeholder { color: var(--text-muted); }

.clear-btn {
  padding: 7px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-2);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  align-self: flex-start;
  margin-top: 2px;
}

.clear-btn:hover {
  background: var(--surface-3);
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Image size inputs ──────────────────────────────────────── */
.size-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-field {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.size-field-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.size-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 7px;
  outline: none;
  transition: border-color var(--transition);
  -moz-appearance: textfield;
}

.size-input::-webkit-outer-spin-button,
.size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.size-input:focus {
  border-color: var(--accent);
}

.size-unit {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.size-cross {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Sidebar footer ─────────────────────────────────────────── */
.sidebar-footer {
  padding: 14px 16px;
  margin-top: auto;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.status-dot.loading {
  background: var(--warn);
  animation: pulse 1.2s infinite;
}

.status-dot.error {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 165, 0, 0.5); }
  50%       { box-shadow: 0 0 0 5px transparent; }
}

/* ── Mobile sidebar toggle ──────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  align-items: center;
  justify-content: center;
}

/* ── Views ──────────────────────────────────────────────────── */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.view.hidden { display: none; }

/* ── Chat view ──────────────────────────────────────────────── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 8px;
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Welcome screen ─────────────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px 20px;
  gap: 12px;
  animation: fadeIn 0.4s ease;
}

.welcome-logo {
  font-family: var(--font-sans);
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.welcome h1 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.welcome p {
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 420px;
  line-height: 1.7;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-2);
  transition: all var(--transition);
  font-family: var(--font-mono);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Messages ───────────────────────────────────────────────── */
.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: slideIn 0.2s ease;
}

.message--user { align-items: flex-end; }
.message--assistant { align-items: flex-start; }

.message-meta {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 2px;
}

.bubble {
  max-width: 75%;
  padding: 11px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  word-wrap: break-word;
}

.message--user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius) var(--radius-lg);
  color: var(--text-primary);
  white-space: pre-wrap;
}

.message--assistant .bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius);
  color: var(--text-primary);
}

.message--error .bubble {
  border-color: var(--danger);
  background: rgba(255, 77, 109, 0.08);
  color: var(--danger);
}

/* ── Inline code & code blocks ──────────────────────────────── */
.inline-code {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--border);
}

.code-block {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0;
  overflow-x: auto;
  position: relative;
}

.code-lang {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 12px 0;
}

.code-block pre {
  padding: 8px 12px 12px;
  overflow-x: auto;
}

.code-block code {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ── Typing indicator ───────────────────────────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 18px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Chat input bar ─────────────────────────────────────────── */
.input-bar {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px 10px 16px;
  max-width: 800px;
  margin: 0 auto;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.message-input {
  flex: 1;
  background: transparent;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

.message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}

.send-btn:hover { background: var(--accent-dim); transform: scale(1.05); }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.input-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Image generation view ──────────────────────────────────── */
.image-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.image-header {
  padding: 28px 32px 16px;
  border-bottom: 1px solid var(--border);
}

.image-header h2 {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.image-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.image-output {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.image-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  min-height: 280px;
  padding: 40px;
}

.placeholder-icon {
  font-size: 40px;
  opacity: 0.3;
}

.image-placeholder p { font-size: 13px; }

/* ── Image cards ─────────────────────────────────────────────── */
.image-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeIn 0.3s ease;
}

.image-card img {
  width: 100%;
  max-height: 600px;
  object-fit: contain;
  display: block;
  background: var(--surface-3);
}

.image-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.image-prompt-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-btn {
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-glow);
  flex-shrink: 0;
  letter-spacing: 0.05em;
  transition: background var(--transition);
}

.download-btn:hover {
  background: rgba(0, 229, 176, 0.25);
  text-decoration: none;
}

/* Loading card */
.image-card--loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 24px;
  min-height: 200px;
  border-style: dashed;
}

.image-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* Image input bar */
.image-input-bar {
  padding: 12px 32px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Toast notification ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 500;
  max-width: 480px;
  width: calc(100% - 48px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast-icon { color: var(--danger); font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.5; }

.toast-close {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px;
  flex-shrink: 0;
  transition: color var(--transition);
}

.toast-close:hover { color: var(--text-primary); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-toggle {
    display: flex;
  }

  .main { width: 100%; }

  .messages {
    padding: 60px 16px 16px;
  }

  .bubble { max-width: 90%; }

  .input-bar {
    padding: 10px 16px 14px;
  }

  .image-header  { padding: 60px 20px 14px; }
  .image-output  { padding: 16px 20px; }
  .image-input-bar { padding: 10px 20px 16px; }

  .welcome { padding: 60px 16px 16px; }
}
