/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: color var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: transparent;
}
.btn-primary:hover:not(:disabled) { background: var(--bg-active); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-secondary:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }

.btn-success {
  background: transparent;
  color: var(--green);
  border-color: transparent;
}
.btn-success:hover:not(:disabled) { background: color-mix(in srgb, var(--green-bg) 70%, transparent); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: transparent;
  border-radius: var(--radius-sm);
}
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red-bg) 70%, transparent); }

.btn-icon {
  padding: 5px 6px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  gap: 5px;
}

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: none;
}

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-running  { color: var(--green);  background: color-mix(in srgb, var(--green-bg) 82%, transparent);  border-color: transparent;  }
.badge-running::before  { background: var(--green); }

.badge-stopped  { color: var(--text-secondary); background: var(--bg-hover); border-color: transparent; }
.badge-stopped::before  { background: var(--text-muted); }

.badge-deploying { color: var(--yellow); background: color-mix(in srgb, var(--yellow-bg) 82%, transparent); border-color: transparent; }
.badge-deploying::before { background: var(--yellow); animation: pulse 1.2s ease-in-out infinite; }

.badge-error { color: var(--red); background: color-mix(in srgb, var(--red-bg) 82%, transparent); border-color: transparent; }
.badge-error::before { background: var(--red); }

.badge-starting, .badge-stopping, .badge-restarting, .badge-pending {
  color: var(--yellow); background: color-mix(in srgb, var(--yellow-bg) 82%, transparent); border-color: transparent;
}
.badge-starting::before, .badge-stopping::before, .badge-restarting::before, .badge-pending::before {
  background: var(--yellow); animation: pulse 0.8s ease-in-out infinite;
}

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

/* ─── Form inputs ───────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

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

.field-label .req  { color: var(--accent); margin-left: 3px; }
.field-label .hint { color: var(--text-muted); font-weight: 400; margin-left: 6px; }

.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── Toggle switch ─────────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 22px;
  background: var(--bg-hover); border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted); top: 3px; left: 3px;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--green-bg); border-color: var(--green-border); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: var(--green); }
.toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

.input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), background var(--transition);
}

.input:focus {
  border-color: var(--border);
  box-shadow: none;
}

.input::placeholder { color: var(--text-muted); }
.input:disabled { opacity: 0.55; cursor: not-allowed; }

.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-left: 36px; }
.input-icon-wrap .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; }

/* Cert path input with scan button */
.input-scan-wrap { display: flex; gap: 6px; align-items: center; }
.input-scan-wrap .input { flex: 1; min-width: 0; }

/* Cert upload row (filename display + action buttons) */
.cert-upload-row { display: flex; gap: 6px; align-items: center; }
.cert-filename {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cert-filename.has-value { color: var(--text-primary); }
.btn-scan {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.btn-scan:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }
.btn-scan:disabled { opacity: 0.45; cursor: not-allowed; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

/* ─── Sections inside cards ─────────────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.section-title svg { color: var(--icon-color); }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid;
  box-shadow: none;
  animation: toast-in 0.18s ease;
  min-width: 260px;
}

.toast.success { background: var(--green-bg);  border-color: var(--green-border);  color: var(--green); }
.toast.error   { background: var(--red-bg);    border-color: var(--red-border);    color: var(--red); }

@keyframes toast-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Confirm dialog ────────────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 380px;
  box-shadow: none;
}

.dialog.dialog-modern {
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: none;
}

.dialog-modern .dialog-title {
  padding: 22px 24px 14px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-muted);
}

.dialog-modern .dialog-body {
  padding: 18px 24px;
  margin-bottom: 0;
}

.dialog-modern .dialog-actions {
  padding: 14px 24px 22px;
  border-top: 1px solid var(--border-muted);
}

.gh-token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-muted);
}

.gh-token-row-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.gh-token-row-hint {
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
}

.dialog-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; display:flex; align-items:center; }
.dialog-body  { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.nginx-dialog { max-width: 700px; width: 95%; max-height: 90vh; display: flex; flex-direction: column; }
.nginx-dialog .dialog-body { flex: 1; min-height: 0; margin-bottom: 0; overflow: hidden; display: flex; flex-direction: column; }
.nginx-textarea { flex: 1; min-height: 320px; resize: vertical; font-size: 12px; line-height: 1.6; padding: 12px; border-radius: 0; border-left: none; border-right: none; }

/* ─── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-sub   { font-size: 13px; color: var(--text-secondary); max-width: 320px; margin-bottom: 24px; }

/* ─── Loading skeleton ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Code / pre ────────────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
  color: var(--text-primary);
}

/* ─── Session timer bar ─────────────────────────────────────────────────── */
.session-timer-bar {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border-muted);
}

.session-timer-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-timer-track {
  height: 3px;
  background: var(--bg-muted);
  border-radius: 99px;
  overflow: hidden;
}

.session-timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 1s linear, background 0.5s ease;
}
