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

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #1c2128;
  --border:      #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #58a6ff;
  --accent-hover:#79b8ff;
  --green:       #3fb950;
  --red:         #f85149;
  --yellow:      #d29922;
  --purple:      #bc8cff;
  --radius:      10px;
  --font-mono:   'Cascadia Code', 'Fira Code', 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --sidebar-w:   260px;
  --transition:  0.15s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Layout ─── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  overflow-y: auto;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-icon {
  font-size: 24px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.provider-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.provider-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.provider-btn:hover {
  background: var(--surface2);
}

.provider-btn.active {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.provider-btn .p-emoji {
  font-size: 18px;
  flex-shrink: 0;
}

.provider-btn .p-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.github-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition);
}

.github-link:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ─── Main ─── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.main-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Welcome state ─── */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  gap: 12px;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 8px;
}

.welcome-state h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.welcome-state p {
  color: var(--text-muted);
  max-width: 400px;
  font-size: 14px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin-top: 24px;
}

.provider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform 0.1s ease;
  text-align: center;
}

.provider-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-2px);
}

.provider-card .pc-emoji {
  font-size: 32px;
}

.provider-card .pc-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* ─── Download form ─── */
.download-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.form-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.05) 0%, transparent 100%);
}

.form-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.form-emoji {
  font-size: 28px;
}

.form-title {
  font-size: 20px;
  font-weight: 700;
}

.form-desc {
  color: var(--text-muted);
  font-size: 13px;
}

.form-fields {
  padding: 20px 24px 24px;
}

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.field-group label .required-badge {
  color: var(--red);
  margin-left: 2px;
  font-size: 11px;
}

.field-group label .optional-badge {
  color: var(--text-muted);
  margin-left: 4px;
  font-size: 11px;
  font-weight: 400;
}

.field-group input,
.field-group select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.field-group input:focus,
.field-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.field-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field-group select option {
  background: var(--surface2);
  color: var(--text);
}

/* ─── Buttons ─── */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 0.1s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-icon {
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

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

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

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.25);
}

/* ─── Terminal ─── */
.terminal-section {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.terminal-dots {
  display: flex;
  gap: 6px;
  margin-right: 4px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }

.terminal-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  flex: 1;
  text-align: center;
}

.terminal-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.terminal-clear:hover {
  color: var(--text);
  background: var(--surface2);
}

.terminal-body {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 240px;
  max-height: 480px;
  overflow-y: auto;
  color: #c9d1d9;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.terminal-body::-webkit-scrollbar {
  width: 6px;
}

.terminal-body::-webkit-scrollbar-track {
  background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Terminal text colours */
.t-green  { color: var(--green); }
.t-red    { color: var(--red); }
.t-yellow { color: var(--yellow); }
.t-blue   { color: var(--accent); }
.t-purple { color: var(--purple); }
.t-muted  { color: var(--text-muted); }

/* Status indicator */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 1.5s infinite;
}

.status-dot.idle {
  background: var(--text-muted);
}

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

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

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

::-webkit-scrollbar-track {
  background: transparent;
}

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

/* ─── Responsive ─── */
@media (max-width: 700px) {
  .layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 12px;
  }

  .main {
    padding: 16px;
  }

  .provider-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .provider-btn {
    width: auto;
    flex: 1;
    min-width: 120px;
  }
}
