/* DOPPLER Demo - Minimal Styling */

:root {
  /* ---- DOPPLER Palette (Purple + Red/Blue) ---- */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --text-primary: #e0e0e0;
  --text-secondary: #888888;
  --text-muted: #555555;

  /* ---- Primary (Purple) ---- */
  --accent: #a855f7;
  --accent-hover: #c084fc;
  --accent-dim: rgba(168, 85, 247, 0.15);
  --accent-glow: 0 0 10px rgba(168, 85, 247, 0.4);

  /* ---- Secondary (Red) ---- */
  --accent-secondary: #ef4444;
  --accent-secondary-hover: #f87171;
  --accent-secondary-dim: rgba(239, 68, 68, 0.15);

  /* ---- Tertiary (Blue) ---- */
  --accent-tertiary: #3b82f6;
  --accent-tertiary-hover: #60a5fa;
  --accent-tertiary-dim: rgba(59, 130, 246, 0.15);

  /* ---- Semantic ---- */
  --success: #3b82f6;    /* Use brand blue for success */
  --warning: #fbbf24;
  --error: #ef4444;

  --border: #333333;
  --radius: 8px;
  --radius-sm: 4px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-tertiary) 0%, var(--accent) 50%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.status-indicator {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.ready { background: var(--success); }
.status-dot.loading { background: var(--accent-secondary); animation: pulse 1s infinite; }
.status-dot.error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 420px;
  min-width: 380px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Model List */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Model Sections */
.model-section {
  margin-bottom: 16px;
}

.model-section:last-child {
  margin-bottom: 0;
}

.model-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.model-section-title {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-section-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.model-section-ready .model-section-title {
  color: var(--success);
}

.model-section-remote .model-section-title {
  color: var(--text-secondary);
}


.model-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 8px;
  border: 2px solid transparent;
}

.model-item:last-child {
  margin-bottom: 0;
}

.model-item:hover {
  background: #2a2a2a;
}

.model-item.active {
  border: 2px solid var(--accent);
  box-shadow: var(--accent-glow);
}

.model-item.downloading {
  position: relative;
  overflow: hidden;
}

.model-item.downloading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  width: var(--download-progress, 0%);
  transition: width 0.3s;
}

.model-name {
  font-weight: 500;
  font-size: 14px;
}

.model-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.model-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.model-btn {
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  white-space: nowrap;
}

.model-btn.download {
  background: var(--accent);
  color: white;
}

.model-btn.download:hover {
  background: var(--accent-hover);
}

.model-btn.run {
  color: white;
}

/* Run from Server - blue */
.model-btn.run-server,
.model-btn.run[data-source="server"] {
  background: var(--accent-tertiary);
}

.model-btn.run-server:hover,
.model-btn.run[data-source="server"]:hover {
  background: var(--accent-tertiary-hover);
}

/* Run from Cache - purple */
.model-btn.run-cached,
.model-btn.run[data-source="browser"] {
  background: var(--accent);
}

.model-btn.run-cached:hover,
.model-btn.run[data-source="browser"]:hover {
  background: var(--accent-hover);
}

.model-btn.cache {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.model-btn.cache:hover {
  background: var(--accent);
  color: white;
}

.model-btn.download-run {
  background: var(--accent);
  color: white;
}

.model-btn.download-run:hover {
  background: var(--accent-hover);
}

.model-btn.quick-start {
  background: linear-gradient(135deg, var(--accent), var(--accent-tertiary));
  color: white;
  font-weight: 600;
}

.model-btn.quick-start:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent-tertiary-hover));
}

.model-btn.delete {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
}

.model-btn.delete:hover {
  background: var(--error);
  color: white;
}

.model-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Storage Info */
.storage-info {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Capabilities List */
.capabilities-list {
  list-style: none;
  font-size: 13px;
}

.capabilities-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-secondary);
}

.cap-icon {
  width: 16px;
  text-align: center;
}

.capabilities-list li.supported { color: var(--success); }
.capabilities-list li.supported .cap-icon::before { content: '✓'; }

.capabilities-list li.unsupported { color: var(--text-muted); }
.capabilities-list li.unsupported .cap-icon::before { content: '✗'; }

/* Attention Kernel Select */
.attention-select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}

.attention-select:focus {
  outline: none;
  border-color: var(--accent);
}

.attention-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Sampling Controls */
.sampling-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.sampling-row label {
  flex: 1;
}

.sampling-input {
  width: 80px;
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}

.sampling-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Progress Overlay - Multi-Phase */
.progress-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.progress-overlay[hidden] {
  display: none;
}

.progress-content {
  width: 400px;
  max-width: 90%;
}

.progress-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-primary);
}

.progress-phases {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-phase-row {
  display: grid;
  grid-template-columns: 80px 1fr 140px;
  gap: 12px;
  align-items: center;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.progress-phase-row.active,
.progress-phase-row.complete {
  opacity: 1;
}

.progress-phase-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-phase-row.active .progress-phase-label {
  color: var(--text-primary);
}

.progress-phase-row.complete .progress-phase-label {
  color: var(--success);
}

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

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease-out;
}

.progress-phase-bar {
  border-radius: 4px;
}

.progress-phase-value {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.progress-phase-row.complete .progress-phase-value {
  color: var(--success);
}

/* Indeterminate animation */
@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
    width: 30%;
  }
  50% {
    transform: translateX(150%);
    width: 30%;
  }
  100% {
    transform: translateX(-100%);
    width: 30%;
  }
}

/* Legacy single bar support */
.progress-label {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
  text-align: center;
}

.progress-detail {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

/* Quick-Start Overlay */
.quickstart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.quickstart-overlay[hidden] {
  display: none;
}

.quickstart-content {
  width: 360px;
  max-width: 90%;
}

.quickstart-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.quickstart-panel[hidden] {
  display: none;
}

.quickstart-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.quickstart-title.error {
  color: #ef4444;
}

.quickstart-title.success {
  color: var(--accent-tertiary);
}

.quickstart-info {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.quickstart-info .info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
}

.quickstart-info .info-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.quickstart-info .info-label {
  color: var(--text-muted);
  font-size: 13px;
}

.quickstart-info .info-value {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.quickstart-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

.quickstart-note.error {
  color: #ef4444;
}

.quickstart-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.quickstart-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.quickstart-btn.primary {
  background: var(--accent);
  color: white;
}

.quickstart-btn.primary:hover {
  background: var(--accent-secondary);
}

.quickstart-btn.cancel {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.quickstart-btn.cancel:hover {
  background: var(--bg-primary);
}

.quickstart-progress {
  margin-bottom: 12px;
}

.quickstart-stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.quickstart-stats span {
  color: var(--text-secondary);
}

.quickstart-stats span:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

.quickstart-detail {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.welcome-message h2 {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.welcome-message p {
  margin: 8px 0;
}

.requirements-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
}

.message {
  max-width: 800px;
  margin: 0 auto 16px;
  padding: 16px;
  border-radius: var(--radius);
}

.message.user {
  background: var(--bg-tertiary);
  margin-left: 60px;
  border-left: 3px solid var(--accent-tertiary);
}

.message.assistant {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.message-role {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.message-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-content .cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.message-stats {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Chat Input */
.chat-input-container {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 150px;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.action-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.action-btn#stop-btn {
  border-color: var(--error);
  color: var(--error);
}

.action-btn#stop-btn:hover {
  background: var(--error);
  color: white;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--error);
  margin-bottom: 12px;
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-close {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--border);
}

/* Convert Panel */
.convert-panel {
  border-top: 1px solid var(--border);
}

.convert-description {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 12px 0;
}

.convert-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.convert-btn:hover {
  background: var(--accent-hover);
}

.convert-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.convert-status {
  margin-top: 12px;
}

.convert-progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.convert-progress {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.convert-message {
  font-size: 12px;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel {
    padding: 12px;
  }

  .capabilities-panel,
  .stats-panel {
    display: none;
  }

  .model-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
  }

  .model-item {
    min-width: 150px;
    flex-shrink: 0;
  }

  .message.user {
    margin-left: 20px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* GPU Info Panel */
.gpu-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gpu-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.gpu-label {
  color: var(--text-muted);
}

.gpu-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Memory Bars Panel */
.memory-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.memory-label {
  width: 70px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.memory-bar-container {
  flex: 1;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

.memory-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.memory-bar-gpu {
  background: var(--success);
}

/* Stacked memory bar (total) */
.memory-total-row {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.memory-total-row .memory-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.memory-sub-row .memory-label {
  font-size: 11px;
}

.memory-sub-row .memory-value {
  font-size: 11px;
}

.memory-bar-stacked {
  display: flex;
  position: relative;
}

.memory-bar-heap-stacked {
  background: var(--accent);
  z-index: 1;
}

.memory-bar-gpu-stacked {
  background: var(--success);
  z-index: 0;
}

.memory-bar-opfs {
  background: var(--accent-tertiary);  /* Blue for disk/cache */
}

.memory-value {
  width: 70px;
  text-align: right;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
