/* Dashboard page styles. Shared tokens, cards, badges and inputs come from
   /style.css; every rule here is scoped with the dashboard- prefix. */

.dashboard-page {
  /* Local aliases keep the page readable when the foundation exposes tokens
     under different names, while still inheriting the live theme. */
  --dashboard-text: var(--text, var(--foreground, currentColor));
  --dashboard-muted: var(--text-secondary);
  --dashboard-surface: var(--panel-2, var(--surface-2, rgba(127, 127, 127, 0.1)));
  --dashboard-line: var(--line, var(--border, rgba(127, 127, 127, 0.24)));
  --dashboard-blue: var(--accent, var(--accent-blue, #0a84ff));
  --dashboard-red: var(--danger, #ff453a);
  --dashboard-amber: var(--warn, var(--warning, #ff9f0a));
  --dashboard-green: var(--success, #30d158);

  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dashboard-notices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-notices:empty {
  display: none;
}

.dashboard-notice-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-notice-row > :first-child {
  flex: 1 1 320px;
  margin-bottom: 0;
}

.dashboard-retry-btn {
  flex: none;
  margin-top: 2px;
}

.dashboard-data {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dashboard-summary {
  min-width: 0;
}

.dashboard-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-stat-grid > *,
.dashboard-mini-grid > *,
.dashboard-lists-grid > *,
.dashboard-side-grid > * {
  min-width: 0;
  margin-bottom: 0;
}

.dashboard-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.dashboard-mini {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--dashboard-line);
  border-radius: 12px;
  background: var(--dashboard-surface);
}

.dashboard-mini-label {
  color: var(--dashboard-muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.dashboard-mini-value {
  color: var(--dashboard-text);
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dashboard-mini-danger .dashboard-mini-value {
  color: var(--dashboard-red);
}

.dashboard-mini-warning .dashboard-mini-value {
  color: var(--dashboard-amber);
}

.dashboard-mini-success .dashboard-mini-value {
  color: var(--dashboard-green);
}

/* --- header controls ----------------------------------------------------- */

.dashboard-protection-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  appearance: none;
  padding: 6px 12px;
  border: 1px solid var(--line, var(--border, rgba(127, 127, 127, 0.28)));
  border-radius: 999px;
  background: var(--panel-2, var(--surface-2, rgba(127, 127, 127, 0.1)));
  color: var(--text, var(--foreground, currentColor));
  font: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.dashboard-protection-pill:hover:not(:disabled) {
  border-color: var(--accent, var(--accent-blue, #0a84ff));
}

.dashboard-protection-pill:focus-visible {
  outline: 2px solid var(--accent, var(--accent-blue, #0a84ff));
  outline-offset: 2px;
}

.dashboard-protection-pill:disabled {
  cursor: default;
  opacity: 0.62;
}

.dashboard-protection-pill.is-on {
  border-color: rgba(48, 209, 88, 0.38);
  background: rgba(48, 209, 88, 0.1);
}

.dashboard-protection-pill.is-off {
  border-color: rgba(255, 69, 58, 0.34);
  background: rgba(255, 69, 58, 0.08);
}

.dashboard-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted, #8a8a8e);
}

.dashboard-protection-pill.is-on .dashboard-dot {
  background: var(--success, #30d158);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.16);
}

.dashboard-protection-pill.is-off .dashboard-dot {
  background: var(--danger, #ff453a);
  box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.14);
}

.dashboard-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dashboard-refresh-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dashboard-refresh-btn.is-loading {
  opacity: 0.8;
}

.dashboard-refresh-btn.is-loading .dashboard-refresh-icon svg {
  animation: dashboard-spin 0.9s linear infinite;
}

.dashboard-refresh-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted, #8a8a8e);
  font-size: 12.5px;
  white-space: nowrap;
}

/* --- chart --------------------------------------------------------------- */

.dashboard-chart-card {
  margin-bottom: 0;
}

.dashboard-chart-body {
  width: 100%;
  min-height: 210px;
  min-width: 0;
}

.dashboard-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.dashboard-axis-label {
  fill: var(--dashboard-muted);
  font-family: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.dashboard-grid-line {
  stroke: var(--dashboard-line);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  opacity: 0.72;
}

.dashboard-axis-line {
  stroke: var(--dashboard-line);
  stroke-width: 1;
}

.dashboard-bar-rect {
  transition: opacity 0.15s ease;
}

.dashboard-bar-allow {
  fill: var(--dashboard-blue);
}

.dashboard-bar-blocked {
  fill: var(--dashboard-red);
}

.dashboard-bar-other {
  fill: var(--dashboard-muted);
  opacity: 0.5;
}

.dashboard-chart-bar:hover .dashboard-bar-rect {
  opacity: 0.78;
}

.dashboard-chart-empty {
  display: grid;
  place-items: center;
  min-height: 230px;
}

.dashboard-chart-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 10px;
  min-height: 18px;
}

.dashboard-updated {
  color: var(--dashboard-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dashboard-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--dashboard-muted);
  font-size: 12px;
}

.dashboard-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dashboard-legend-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.dashboard-legend-allow {
  background: var(--dashboard-blue);
}

.dashboard-legend-blocked {
  background: var(--dashboard-red);
}

.dashboard-legend-other {
  background: var(--dashboard-muted);
  opacity: 0.5;
}

/* --- top lists and response codes --------------------------------------- */

.dashboard-lists-host {
  min-width: 0;
}

.dashboard-lists-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-list-card,
.dashboard-rcode-card,
.dashboard-status-card,
.dashboard-summary-card {
  margin-bottom: 0;
  min-width: 0;
}

.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.dashboard-list-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.dashboard-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.dashboard-list-key {
  min-width: 0;
  overflow: hidden;
  color: var(--dashboard-text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-list-count {
  flex: none;
  color: var(--dashboard-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dashboard-progress {
  width: 100%;
  min-width: 0;
}

.dashboard-progress > * {
  width: 100%;
}

.dashboard-rcode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

/* --- runtime status ------------------------------------------------------ */

.dashboard-side-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.dashboard-status {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dashboard-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 22px;
}

.dashboard-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.dashboard-field-label {
  color: var(--dashboard-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.dashboard-field-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--dashboard-text);
  font-size: 13px;
}

.dashboard-protection-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.dashboard-protection-note {
  color: var(--dashboard-muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.dashboard-mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.dashboard-muted {
  color: var(--dashboard-muted);
}

.dashboard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.dashboard-chip {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid var(--dashboard-line);
  border-radius: 999px;
  background: var(--dashboard-surface);
  color: var(--dashboard-text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.dashboard-reset-btn {
  flex: none;
}

/* --- loading skeleton ---------------------------------------------------- */

.dashboard-skeleton {
  border: 1px solid var(--dashboard-line);
  border-radius: 12px;
  background: var(--dashboard-surface);
  animation: dashboard-pulse 1.6s ease-in-out infinite;
}

.dashboard-skeleton-stat {
  height: 108px;
}

.dashboard-skeleton-mini {
  height: 54px;
  border-radius: 12px;
}

.dashboard-skeleton-chart {
  height: 250px;
}

.dashboard-skeleton-card {
  height: 226px;
}

.dashboard-skeleton-status {
  height: 312px;
}

.dashboard-skeleton-rcode {
  height: 312px;
}

@keyframes dashboard-pulse {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.78; }
}

@keyframes dashboard-spin {
  to { transform: rotate(360deg); }
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 1024px) {
  .dashboard-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-side-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .dashboard-lists-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-skeleton-rcode {
    height: 240px;
  }
}

@media (max-width: 720px) {
  .dashboard-refresh-btn,
  .dashboard-reset-btn,
  .dashboard-retry-btn {
    min-height: 44px;
  }
}

@media (max-width: 620px) {
  .dashboard-stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-mini-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-protection-pill {
    padding: 5px 10px;
  }
}

@media (max-width: 420px) {
  .dashboard-mini-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-mini {
    padding: 9px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-skeleton {
    animation: none;
    opacity: 0.65;
  }

  .dashboard-refresh-btn.is-loading .dashboard-refresh-icon svg {
    animation: none;
  }

  .dashboard-protection-pill,
  .dashboard-bar-rect {
    transition: none;
  }
}
