/* Reusable component patterns — see docs/brandbook.md */

/* ---------- Nav ---------- */
.navbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 40;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: 56px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.brand-mark:hover {
  text-decoration: none;
}

.brand-mark .brand-accent { color: var(--accent); }

.nav-links {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-surface-raised);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-toggle {
  display: inline-flex;
}

@media (min-width: 768px) {
  .nav-links { display: flex; }
  .nav-toggle { display: none; }
}

.mobile-menu {
  display: none;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) 0 var(--space-4);
  border-top: 1px solid var(--border);
}

.mobile-menu.open { display: flex; }

.mobile-menu a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.mobile-menu a:hover,
.mobile-menu a.active {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  text-decoration: none;
}

@media (min-width: 768px) {
  .mobile-menu { display: none !important; }
}

/* ---------- Icon / theme toggle button ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-raised);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--fs-xs);
}

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

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

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover { background: var(--bg-surface-raised); }

.btn-danger {
  background: transparent;
  border-color: var(--status-down);
  color: var(--status-down);
}

.btn-danger:hover { background: var(--status-down-bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  height: auto;
  padding: var(--space-1) var(--space-2);
}

.btn-ghost:hover { color: var(--text-primary); background: var(--bg-surface-raised); }

.btn-block { width: 100%; }

/* ---------- Status badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

.status-up { color: var(--status-up); background: var(--status-up-bg); }
.status-degraded { color: var(--status-degraded); background: var(--status-degraded-bg); }
.status-down { color: var(--status-down); background: var(--status-down-bg); }
.status-paused { color: var(--status-paused); background: var(--status-paused-bg); }

/* dot-only variant for dense table rows */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-dot.status-up { background: var(--status-up); }
.status-dot.status-degraded { background: var(--status-degraded); }
.status-dot.status-down { background: var(--status-down); }
.status-dot.status-paused { background: var(--status-paused); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

@media (min-width: 768px) {
  .card { padding: var(--space-5); }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.stat-tile .stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-2);
}

.stat-tile .stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 600;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: var(--space-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-surface-raised); }

.table .num,
.table .url,
.table .timestamp {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.monitor-row-name {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.monitor-row-name .name-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.monitor-row-name .name-primary {
  font-weight: 500;
  color: var(--text-primary);
}

.monitor-row-name .name-url {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--fs-xs);
  color: var(--status-down);
  margin-top: var(--space-1);
}

.form-control {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
}

textarea.form-control {
  height: auto;
  padding: var(--space-3);
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  cursor: pointer;
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-row {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.checkbox-row input { width: 16px; height: 16px; }
.checkbox-row label { font-size: var(--fs-sm); color: var(--text-primary); margin: 0; }

/* ---------- Alerts / notices ---------- */
.alert {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.alert-error {
  border-color: var(--status-down);
  color: var(--status-down);
  background: var(--status-down-bg);
}

.alert-success {
  border-color: var(--status-up);
  color: var(--status-up);
  background: var(--status-up-bg);
}

.alert-info {
  color: var(--text-secondary);
}

/* ---------- Incident timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  position: relative;
  padding: 0 0 var(--space-5) var(--space-6);
  border-left: 2px solid var(--border);
}

.timeline-item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--status-down);
  border: 2px solid var(--bg-surface);
}

.timeline-item.resolved::before { background: var(--status-up); }
.timeline-item.degraded::before { background: var(--status-degraded); }

.timeline-time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.timeline-title {
  font-weight: 500;
  margin: var(--space-1) 0;
}

/* ---------- Badges/pills generic ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* ---------- Sparkline ---------- */
.sparkline {
  width: 96px;
  height: 28px;
  display: block;
}

.sparkline path.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
}

.sparkline path.spark-fill {
  fill: var(--accent-muted);
  stroke: none;
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-secondary);
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-5) 0;
  margin-top: var(--space-10);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  text-align: center;
}

.site-footer a { color: var(--text-tertiary); }
