/* chrishan.xyz — Design System Tokens & Styles
   
   NOTE: Structural tokens (typography, spacing, radius, motion) are canonical
   in ~/workspace/shared/css/tokens.css. This file duplicates them because
   chrishan.xyz has no build step. Keep in sync with shared/css/tokens.css.
*/

:root {
  /* ── Shared structural tokens (from @chrishan/tokens) ── */
  --font-system: Inter, -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-card: 12px;
  --radius-lg: 16px;
  --radius-pill: 100px;

  /* ── Shared dark theme (from @chrishan/tokens) ── */
  --bg-base: #0A0A0A;
  --bg-surface: #141414;
  --bg-elevated: #1C1C1C;
  --bg-hover: #242424;
  --text-primary: #F0F0F0;
  --text-secondary: #9A9A9A;
  --text-tertiary: #6A6A6A;
  --green: #30D158;
  --green-soft: rgba(48, 209, 88, 0.12);
  --red: #FF453A;
  --red-soft: rgba(255, 69, 58, 0.12);
  --yellow: #FFD60A;
  --yellow-soft: rgba(255, 214, 10, 0.12);
  --orange: #FF9F0A;
  --divider: rgba(34, 34, 34, 1);

  /* ── App-specific: Accent — Silver ── */
  --accent: #E5E5E5;
  --accent-soft: rgba(229,229,229,0.12);
  --text-on-accent: #000000;

  /* ── App-specific extras ── */
  --blue: #3b82f6;
  --blue-soft: rgba(59,130,246,0.12);
  --purple: #8b5cf6;
  --border-subtle: #2a2a2a;
  --border-medium: #333;
  --text-muted: #444;
  --scrim: rgba(0,0,0,0.7);
  --scrim-heavy: rgba(0,0,0,0.75);
  --tap-highlight: rgba(255, 255, 255, 0.05);

  /* App brand colors */
  --brand-arlo: #1a1a2e;
  --brand-feed: #1a2233;
  --brand-recharge: #1a2e1a;
  --brand-aneysha: #2e1a2e;
  --brand-monitor: #1a2e2e;
}

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

/* ── Base ── */
body {
  font-family: var(--font-system);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  max-width: 480px;
  width: 100%;
  padding: 2rem;
}

/* ── Header ── */
.header { margin-bottom: 3rem; }

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header p {
  color: var(--text-tertiary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

/* ── App Cards ── */
.apps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  min-height: 44px;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: var(--tap-highlight);
}

.app-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
}

.app-card:active {
  background: var(--bg-elevated);
  transform: scale(0.98);
}

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.app-icon.arlo { background: var(--brand-arlo); }
.app-icon.feed { background: var(--brand-feed); }
.app-icon.recharge { background: var(--brand-recharge); }
.app-icon.aneysha { background: var(--brand-aneysha); }
.app-icon.monitor { background: var(--brand-monitor); }

.app-info h2 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.app-info p {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: 0.125rem;
}

.app-url {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}

.app-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-medium);
  transition: background 0.3s ease;
}

.status-dot.up { background: var(--green); }
.status-dot.down { background: var(--red); }

.status-ms {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: right;
}

.status-perc {
  font-size: 0.625rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* ── Containers Section ── */
.containers-section { margin-top: 2rem; }

.containers-section h3 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-header h3 { margin-bottom: 0; }

.container-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.container-item {
  padding: 0.625rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.container-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.375rem;
}

.container-name {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.8125rem;
}

.container-bars {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.bar-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.bar-label {
  font-size: 0.625rem;
  color: var(--text-muted);
  min-width: 2.5rem;
  text-align: right;
}

.bar-track {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.bar-fill.cpu { background: var(--blue); }
.bar-fill.mem { background: var(--purple); }

.bar-value {
  font-size: 0.625rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  min-width: 3rem;
}

.container-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
  font-size: 0.625rem;
  color: var(--border-medium);
  font-family: var(--font-mono);
}

/* ── Network Section ── */
.network-section { margin-top: 2rem; }

.network-section h3 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.network-chart {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.network-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.network-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.625rem;
  color: var(--text-tertiary);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

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

.legend-dot.rx { background: var(--blue); }
.legend-dot.tx { background: var(--green); }

.network-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.375rem;
  font-size: 0.625rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.network-empty {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--border-medium);
}

/* ── Security Section ── */
.security-section { margin-top: 2rem; }

.security-section h3 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.security-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.security-card {
  padding: 0.625rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
}

.security-card-label {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.security-card-value {
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
}

.security-card-value.ok { color: var(--green); }
.security-card-value.warn { color: var(--yellow); }
.security-card-value.bad { color: var(--red); }

.security-detail {
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  line-height: 1.6;
}

/* ── Caddy Logs Section ── */
.caddy-section { margin-top: 2rem; }

.caddy-section h3 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.caddy-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.caddy-stat {
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  text-align: center;
}

.caddy-stat-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.caddy-stat-label {
  font-size: 0.5625rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.125rem;
}

.caddy-table {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.caddy-table-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0.75rem;
  font-size: 0.6875rem;
  border-bottom: 1px solid var(--divider);
}

.caddy-table-row:last-child { border-bottom: none; }

.caddy-table-path {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 75%;
}

.caddy-table-count {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ── Cleanup Button ── */
.cleanup-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.cleanup-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.cleanup-btn:active { transform: scale(0.96); }
.cleanup-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cleanup-btn.running { color: var(--yellow); border-color: var(--yellow-soft); }

.cleanup-result {
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: none;
}

.cleanup-result.visible { display: block; }
.cleanup-result.success { border-color: var(--green-soft); }
.cleanup-result.error { border-color: var(--red-soft); color: var(--red); }

.cleanup-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.125rem 0;
}

.cleanup-stat-label { color: var(--text-tertiary); }

.cleanup-stat-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Confirm Dialog (inline) ── */
.confirm-dialog {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.confirm-dialog.visible { opacity: 1; pointer-events: auto; }

.confirm-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.confirm-box h4 {
  color: var(--text-primary);
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.confirm-box p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.confirm-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.confirm-buttons button {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--border-medium);
  transition: all 0.15s ease;
}

.btn-cancel {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.btn-confirm {
  background: var(--red);
  border-color: var(--red);
  color: var(--text-primary);
}

.btn-confirm:hover { background: var(--red); }

/* ── Settings ── */
.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  color: var(--text-muted);
  padding: 0.25rem;
  transition: color 0.15s ease, transform 0.3s ease;
  line-height: 1;
}

.settings-btn:hover { color: var(--text-secondary); transform: rotate(45deg); }

.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--scrim-heavy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.settings-overlay.visible { opacity: 1; pointer-events: auto; }

.settings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 360px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.settings-panel h3 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.settings-group-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.settings-group-label:first-of-type { margin-top: 0; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--divider);
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* ── Toggle Switch ── */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-subtle);
  border-radius: 11px;
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle input:checked + .toggle-track { background: var(--green-soft); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--green); }

/* ── Interval Selector ── */
.interval-selector { display: flex; gap: 0.375rem; }

.interval-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}

.interval-btn:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.interval-btn.active { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

.settings-close {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.625rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.settings-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Footer ── */
.footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer #greeting { color: var(--text-tertiary); }
.footer-meta { font-size: 0.6875rem; color: var(--text-muted); }
#visitors { margin-top: 0.25rem; }

/* ── Utility ── */
.loading-text { font-size: 0.75rem; color: var(--text-muted); }
.section-hidden { display: none !important; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .container { padding: 1.5rem 1.25rem; }
  .header { margin-bottom: 2rem; }
  .app-card { padding: 0.875rem 1rem; }
  .app-info p { font-size: 0.875rem; }
  .footer { margin-top: 2rem; font-size: 0.8125rem; }
}
