/*
 * Default Theme for monitorat
 * Clean, modern system UI look
 */

:root {
  --theme-bg-body-light: #f3f4f6;
  --theme-bg-surface-light: #ffffff;
  --theme-bg-card-light: #f9fafb;
  --theme-bg-notes-light: #fafbfc;
  --theme-border-muted-light: #d1d5db;
  --theme-shadow-strong-light: 0 10px 40px rgba(31, 36, 43, 0.12);
  --theme-text-primary-light: #111827;
  --theme-text-muted-light: #4b5563;
  --theme-text-label-light: #6b7280;
  --theme-text-heading-light: #1f2937;
  --theme-accent-light: #0ea5e9;
  --theme-accent-hover-light: #0284c7;
  --theme-accent-disabled-light: #7dd3fc;
  --theme-toggle-bg-light: #ffffff;
  --theme-toggle-border-light: #d1d5db;
  --theme-toggle-hover-light: #f3f4f6;

  --theme-bg-body-dark: #0f1115;
  --theme-bg-surface-dark: #1a1d25;
  --theme-bg-card-dark: #222733;
  --theme-bg-notes-dark: #232836;
  --theme-border-muted-dark: #2a303c;
  --theme-shadow-strong-dark: none;
  --theme-text-primary-dark: #eef1f5;
  --theme-text-muted-dark: #9ba4b3;
  --theme-text-label-dark: #9ba4b3;
  --theme-text-heading-dark: #d2d9e4;
  --theme-accent-dark: #40bcf4;
  --theme-accent-hover-dark: #70cdf7;
  --theme-accent-disabled-dark: #2d6c8c;
  --theme-toggle-bg-dark: #1a1d25;
  --theme-toggle-border-dark: #2a303c;
  --theme-toggle-hover-dark: #222733;

  --theme-icon-privacy-on-light: var(--theme-accent-light);
  --theme-icon-privacy-off-light: var(--theme-text-muted-light);
  --theme-icon-privacy-on-dark: var(--theme-accent-dark);
  --theme-icon-privacy-off-dark: var(--theme-text-muted-dark);
  --theme-icon-sun-light: #f59e0b;
  --theme-icon-moon-light: #2563eb;
  --theme-icon-sun-dark: #fbbf24;
  --theme-icon-moon-dark: #93c5fd;

  --status-ok-rgb: 16, 185, 129;
  --status-warn-rgb: 245, 158, 11;
  --status-critical-rgb: 239, 68, 68;
  --status-unknown-rgb: 156, 163, 175;
  --status-ok: rgb(var(--status-ok-rgb));
  --status-warn: rgb(var(--status-warn-rgb));
  --status-critical: rgb(var(--status-critical-rgb));
  --status-unknown: rgb(var(--status-unknown-rgb));
  --status-degraded: var(--status-warn);
  --status-offline: var(--status-critical);

  --chart-series-1: #2563eb;
  --chart-series-2: #16a34a;
  --chart-series-3: #d97706;
  --chart-series-4: #dc2626;
  --chart-series-5: #7c3aed;
  --chart-series-6: #0891b2;

  --chart-legend-bg-rgb: var(--color-ghost-rgb);

  --color-ghost-rgb: 148, 163, 184;
  --color-ghost: rgba(var(--color-ghost-rgb), 0.35);
  --color-ghost-light: rgba(var(--color-ghost-rgb), 0.08);

  --bg-body: var(--theme-bg-body-light);
  --bg-surface: var(--theme-bg-surface-light);
  --bg-card: var(--theme-bg-card-light);
  --bg-notes: var(--theme-bg-notes-light);
  --border-muted: var(--theme-border-muted-light);
  --shadow-strong: var(--theme-shadow-strong-light);
  --text-primary: var(--theme-text-primary-light);
  --text-muted: var(--theme-text-muted-light);
  --text-label: var(--theme-text-label-light);
  --text-heading: var(--theme-text-heading-light);
  --accent: var(--theme-accent-light);
  --accent-hover: var(--theme-accent-hover-light);
  --accent-disabled: var(--theme-accent-disabled-light);
  --toggle-bg: var(--theme-toggle-bg-light);
  --toggle-border: var(--theme-toggle-border-light);
  --toggle-hover: var(--theme-toggle-hover-light);
  --icon-privacy-on: var(--theme-icon-privacy-on-light);
  --icon-privacy-off: var(--theme-icon-privacy-off-light);
  --icon-theme-sun: var(--theme-icon-sun-light);
  --icon-theme-moon: var(--theme-icon-moon-light);
  --text-secondary: var(--text-muted);
  --bg-tertiary: rgba(128, 128, 128, 0.15);
  --button-text: #ffffff;
}

:root[data-theme="dark"] {
  --bg-body: var(--theme-bg-body-dark);
  --bg-surface: var(--theme-bg-surface-dark);
  --bg-card: var(--theme-bg-card-dark);
  --bg-notes: var(--theme-bg-notes-dark);
  --border-muted: var(--theme-border-muted-dark);
  --shadow-strong: var(--theme-shadow-strong-dark);
  --text-primary: var(--theme-text-primary-dark);
  --text-muted: var(--theme-text-muted-dark);
  --text-label: var(--theme-text-label-dark);
  --text-heading: var(--theme-text-heading-dark);
  --accent: var(--theme-accent-dark);
  --accent-hover: var(--theme-accent-hover-dark);
  --accent-disabled: var(--theme-accent-disabled-dark);
  --toggle-bg: var(--theme-toggle-bg-dark);
  --toggle-border: var(--theme-toggle-border-dark);
  --toggle-hover: var(--theme-toggle-hover-dark);
  --icon-privacy-on: var(--theme-icon-privacy-on-dark);
  --icon-privacy-off: var(--theme-icon-privacy-off-dark);
  --icon-theme-sun: var(--theme-icon-sun-dark);
  --icon-theme-moon: var(--theme-icon-moon-dark);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: var(--theme-bg-body-dark);
    --bg-surface: var(--theme-bg-surface-dark);
    --bg-card: var(--theme-bg-card-dark);
    --bg-notes: var(--theme-bg-notes-dark);
    --border-muted: var(--theme-border-muted-dark);
    --shadow-strong: var(--theme-shadow-strong-dark);
    --text-primary: var(--theme-text-primary-dark);
    --text-muted: var(--theme-text-muted-dark);
    --text-label: var(--theme-text-label-dark);
    --text-heading: var(--theme-text-heading-dark);
    --accent: var(--theme-accent-dark);
    --accent-hover: var(--theme-accent-hover-dark);
    --accent-disabled: var(--theme-accent-disabled-dark);
    --toggle-bg: var(--theme-toggle-bg-dark);
    --toggle-border: var(--theme-toggle-border-dark);
    --toggle-hover: var(--theme-toggle-hover-dark);
    --icon-privacy-on: var(--theme-icon-privacy-on-dark);
    --icon-privacy-off: var(--theme-icon-privacy-off-dark);
    --icon-theme-sun: var(--theme-icon-sun-dark);
    --icon-theme-moon: var(--theme-icon-moon-dark);
  }
}

:root[data-theme="dark"] .markdown-body {
  color-scheme: dark;
  --focus-outlineColor: #1f6feb;
  --fgColor-default: #e6edf3;
  --fgColor-muted: #8d96a0;
  --fgColor-accent: #4493f8;
  --fgColor-success: #3fb950;
  --fgColor-attention: #d29922;
  --fgColor-danger: #f85149;
  --fgColor-done: #ab7df8;
  --bgColor-default: #0d1117;
  --bgColor-muted: #161b22;
  --bgColor-neutral-muted: #6e768166;
  --bgColor-attention-muted: #bb800926;
  --borderColor-default: #30363d;
  --borderColor-muted: #30363db3;
  --borderColor-neutral-muted: #6e768166;
  --borderColor-accent-emphasis: #1f6feb;
  --borderColor-success-emphasis: #238636;
  --borderColor-attention-emphasis: #9e6a03;
  --borderColor-danger-emphasis: #da3633;
  --borderColor-done-emphasis: #8957e5;
}

:root[data-theme="light"] .markdown-body,
:root:not([data-theme]) .markdown-body {
  color-scheme: light;
  --focus-outlineColor: #0969da;
  --fgColor-default: #1f2328;
  --fgColor-muted: #636c76;
  --fgColor-accent: #0969da;
  --fgColor-success: #1a7f37;
  --fgColor-attention: #9a6700;
  --fgColor-danger: #d1242f;
  --fgColor-done: #8250df;
  --bgColor-default: #ffffff;
  --bgColor-muted: #f6f8fa;
  --bgColor-neutral-muted: #afb8c133;
  --bgColor-attention-muted: #fff8c5;
  --borderColor-default: #d0d7de;
  --borderColor-muted: #d0d7deb3;
  --borderColor-neutral-muted: #afb8c133;
  --borderColor-accent-emphasis: #0969da;
  --borderColor-success-emphasis: #1a7f37;
  --borderColor-attention-emphasis: #bf8700;
  --borderColor-danger-emphasis: #cf222e;
  --borderColor-done-emphasis: #8250df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  position: relative;
  overflow-x: hidden;
}

a {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

h1 {
  margin: 0;
  font-size: 1.9rem;
  color: var(--text-heading);
}

h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-heading);
}

h3 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--text-heading);
}

h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-heading);
}

h5 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-heading);
}

h6 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-heading);
}

button {
  appearance: none;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--button-text);
  transition: background 0.2s ease;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  background: var(--accent-disabled);
  cursor: not-allowed;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card {
  background: var(--bg-card);
  border-radius: 8px;
}

/* Status card base styling */
.status-card {
  background: var(--status-bg, var(--bg-card));
  border-left: 4px solid var(--status-border, transparent);
}

.status-ok {
  --status-bg: rgba(var(--status-ok-rgb), 0.12);
  --status-border: rgb(var(--status-ok-rgb));
}

.status-warning,
.status-warn,
.status-caution {
  --status-bg: rgba(var(--status-warn-rgb), 0.12);
  --status-border: rgb(var(--status-warn-rgb));
}

.status-critical,
.status-down,
.status-expired {
  --status-bg: rgba(var(--status-critical-rgb), 0.12);
  --status-border: rgb(var(--status-critical-rgb));
}

.status-unknown,
.status-never {
  --status-bg: rgba(var(--status-unknown-rgb), 0.15);
  --status-border: rgb(var(--status-unknown-rgb));
}

.alerts-toggle {
  font-size: 0.85rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-weight: 400;
}

.alerts-toggle:hover {
  text-decoration: underline;
}

button.alerts-toggle {
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--accent);
  text-decoration: none;
}

button.alerts-toggle:hover {
  text-decoration: none;
  background: var(--toggle-hover);
}
.alerts-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: none;
}

.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--status-border, rgb(var(--status-unknown-rgb)));
  background: var(--status-bg, rgba(var(--status-unknown-rgb), 0.12));
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.1;
  text-transform: none;
  letter-spacing: normal;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
}

.icon-label-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.icon-label:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-label:hover:not(:disabled) {
  background: color-mix(
    in srgb,
    var(--status-bg, var(--bg-card)) 82%,
    var(--bg-surface) 18%
  );
  border-color: color-mix(
    in srgb,
    var(--status-border, var(--border-muted)) 70%,
    var(--text-primary) 30%
  );
}

.icon-label.status-ok {
  --status-bg: rgba(var(--status-ok-rgb), 0.18);
  --status-border: rgb(var(--status-ok-rgb));
  color: var(--text-primary);
}

.info-button {
  pointer-events: auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.info-button:hover {
  opacity: 1;
  color: var(--accent);
  background: transparent;
  transform: scale(1.06);
}

.info-button:focus-visible {
  outline: 2px solid var(--border-muted);
  outline-offset: 2px;
}

.info-button svg {
  width: 100%;
  height: 100%;
}

.modal-status {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.85rem;
}

.modal-status-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 4px 0;
}

.modal-status-item:not(:last-child) {
  border-bottom: 1px solid var(--border-muted);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.modal-status-name {
  flex: 1;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  display: block;
  white-space: nowrap;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-muted) transparent;
  scrollbar-gutter: stable;
}

.modal-status-label {
  font-weight: 500;
  white-space: normal;
  text-align: right;
  flex: 0 0 auto;
  max-width: 50%;
  min-width: 0;
}

.modal-status-label.status-ok {
  color: rgb(var(--status-ok-rgb));
}
.modal-status-label.status-warning,
.modal-status-label.status-warn,
.modal-status-label.status-caution {
  color: rgb(var(--status-warn-rgb));
}
.modal-status-label.status-down,
.modal-status-label.status-expired,
.modal-status-label.status-critical {
  color: rgb(var(--status-critical-rgb));
}
.modal-status-label.status-unknown {
  color: rgb(var(--status-unknown-rgb));
}

.modal-status-name::-webkit-scrollbar {
  height: 6px;
}

.modal-status-name::-webkit-scrollbar-track {
  background: transparent;
}

.modal-status-name::-webkit-scrollbar-thumb {
  background: var(--border-muted);
  border-radius: 6px;
}

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

select.alerts-toggle {
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  appearance: auto;
}

select.alerts-toggle:hover {
  text-decoration: none;
  background: var(--toggle-hover);
}
select.alerts-toggle:disabled {
  cursor: not-allowed;
  color: var(--text-muted);
  background: var(--toggle-bg);
}

.widget-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-separator {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.section-header-collapsible {
  cursor: pointer;
  user-select: none;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.section-header-collapsible.collapsed {
  border-bottom-color: var(--border-muted);
  margin-bottom: 0;
}

.section-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.section-header-collapsible:not(.collapsed) .section-chevron {
  transform: rotate(180deg);
}

.section-title {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text-heading);
}

.section-header .alerts-toggle {
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-weight: 400;
}

.header-anchor {
  margin-left: 0.5em;
  color: var(--accent);
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

h1:hover .header-anchor,
h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor,
h5:hover .header-anchor,
h6:hover .header-anchor {
  opacity: 1;
}

.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}
.alerts-toggle:hover {
  background: none !important;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--bg-tertiary, rgba(128, 128, 128, 0.2));
  color: var(--text-secondary);
}

.source-badge img {
  width: 12px;
  height: 12px;
}

.feature-header {
  margin: 16px 0 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.feature-header:first-child {
  margin-top: 0;
}

.feature-header:empty {
  display: none;
}

.feature-header .source-badge {
  margin-left: 8px;
  text-transform: none;
  font-weight: 500;
}

.metrics > :is(.metrics-history, .metrics-events),
.network .network-container > :is(.uptime-overview, .alerts) {
  margin-top: 12px;
}

.metrics
  :is(
    .feature-header[data-metrics-section-header="snapshot"],
    .feature-header[data-metrics-section-header="history"],
    .feature-header[data-metrics-section-header="events"]
  ),
.network
  :is(
    .feature-header[data-network-section-header="metrics"],
    .feature-header[data-network-section-header="uptime"],
    .feature-header[data-network-section-header="alerts"]
  ) {
  margin: 0 0 8px 0;
}

.layout-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.layout-group {
  --layout-group-columns: 1;
  --layout-group-min: 320px;
  display: grid;
  grid-template-columns: repeat(
      var(--layout-group-columns),
      minmax(min(100%, var(--layout-group-min)), 1fr)
    );
  gap: var(--layout-group-gap, 24px);
}

.layout-group > [id$="-widget"] {
  min-width: 0;
  overflow: hidden;
}

[id$="-widget"] {
  --widget-min-width: 320px;
}

.layout-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 700px) {
  .layout-columns {
    grid-template-columns: 1fr;
  }
}

/* Modal System */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease,
    visibility 0.15s ease;
}

.modal-backdrop.modal-visible {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.15s ease;
}

.modal-visible .modal-container {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-muted);
}

.modal-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-muted);
}

.modal-action {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid var(--border-muted);
  background: var(--bg-card);
  color: var(--text-primary);
}

.modal-action:hover {
  background: var(--bg-surface);
}

.modal-action-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-text);
}

.modal-action-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Info Modal Specific */
.info-modal-section {
  margin-bottom: 20px;
}

.info-modal-section:last-child {
  margin-bottom: 0;
}

.info-modal-section h4 {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.info-modal-themes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-modal-theme {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-muted);
  border-radius: 6px;
  cursor: pointer;
  transition:
    border-color 0.1s ease,
    background 0.1s ease;
}

.info-modal-theme:hover {
  background: var(--bg-card);
}

.info-modal-theme.selected {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb, 37, 99, 235), 0.08);
}

.info-modal-theme input[type="radio"] {
  margin: 0;
  accent-color: var(--accent);
}

.info-modal-theme-name {
  font-weight: 500;
  color: var(--text-primary);
}

.info-modal-footer-links {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border-muted);
  margin-top: 8px;
}

.info-modal-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.info-modal-link:hover {
  color: var(--accent);
}

.info-modal-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Utilities */
.hover-expand {
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.15s ease;
}

.hover-expand:hover,
.hover-expand-parent:hover .hover-expand {
  transform: scale(1.12);
}
