/*
 * Site Configs Explorer
 * Styles for the site configuration browser page
 */

html {
  overflow: auto;
}

#moreMenu[open] {
  z-index: 10;
}

.row-count {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Raw / Resolved toggle ──────────────────────────────────── */

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-opt {
  all: unset;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--card-bg);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.view-opt:not(:last-child) {
  border-right: 1px solid var(--border);
}

.view-opt[aria-pressed="true"] {
  background: var(--host-delivery);
  color: #fff;
}

/* ── Main layout ────────────────────────────────────────────── */

.configs-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 24px 24px;
}

/* ── Stats section ──────────────────────────────────────────── */

.stats-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.stats-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 260px;
}

.stat-chip {
  all: unset;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 120px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.stat-chip:hover {
  border-color: var(--host-delivery);
}

.stat-chip.active {
  background: color-mix(in srgb, var(--host-delivery) 10%, transparent);
  border-color: var(--host-delivery);
}

.stat-chip.active .stat-value,
.stat-chip.active .stat-label {
  color: var(--host-delivery);
}

.stat-chip .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-chip .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-chip .stat-pct {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ── CDN type breakdown table ───────────────────────────────── */

.type-breakdown {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 200px;
}

.type-breakdown h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.type-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.type-table tbody tr {
  cursor: pointer;
  border-radius: 4px;
}

.type-table tbody tr:hover td {
  background: var(--bg);
}

.type-table tbody tr.active td {
  background: color-mix(in srgb, var(--host-delivery) 10%, transparent);
}

.type-table tbody tr.active td:first-child {
  color: var(--host-delivery);
  font-weight: 600;
}

.type-table td {
  padding: 3px 0;
  vertical-align: middle;
}

.type-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  padding-left: 16px;
}

.type-bar-cell {
  width: 80px;
  padding-left: 8px !important;
}

.type-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.type-bar-fill {
  height: 100%;
  background: var(--host-delivery);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── Site configs table section ─────────────────────────────── */

.table-section {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-container {
  overflow-x: auto;
}

.configs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.configs-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.configs-table th {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}

.configs-table th.sortable button {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

.configs-table th.sortable:hover,
.configs-table th.sortable button:hover {
  color: var(--text);
}

.configs-table th.sort-asc::after {
  content: ' \25B2 ';
  font-size: 10px;
}

.configs-table th.sort-desc::after {
  content: ' \25BC ';
  font-size: 10px;
}

.configs-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.configs-table tbody tr:hover {
  background: var(--bg);
  cursor: pointer;
}

.configs-table tbody tr.hidden {
  display: none;
}

.org-cell {
  font-weight: 600;
  color: var(--host-delivery);
}

.site-cell {
  color: var(--text);
}

.cdn-host-cell {
  color: var(--host-customer);
  font-size: 12px;
}

.cdn-type-cell,
.source-type-cell {
  color: var(--text-secondary);
  font-size: 12px;
}

.profile-cell {
  color: var(--host-authoring);
  font-size: 12px;
}

.date-cell {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

/* Empty and loading states inside table-section */
.table-section .loading {
  padding: 60px 20px;
}

.table-section .error-message {
  margin: 20px;
}

/* ── Pagination ─────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.page-btn {
  all: unset;
  cursor: pointer;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}

.page-btn:hover:not(:disabled) {
  background: var(--card-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 140px;
  text-align: center;
}

/* ── Config detail dialog ───────────────────────────────────── */

.config-detail-dialog {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: min(640px, 95vw);
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.config-detail-dialog[open] {
  display: flex;
  flex-direction: column;
}

.config-detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

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

.detail-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.detail-header .detail-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-config-link {
  color: var(--host-delivery);
  text-decoration: none;
  font-size: 12px;
}

.detail-config-link:hover {
  text-decoration: underline;
}

.detail-close {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

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

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

.detail-group {
  margin-bottom: 16px;
}

.detail-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.detail-rows {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 12px;
  font-size: 13px;
}

.detail-label {
  color: var(--text-secondary);
  padding: 3px 0;
  align-self: start;
}

.detail-value {
  color: var(--text);
  padding: 3px 0;
  word-break: break-all;
  align-self: start;
}

.detail-value.empty {
  color: var(--text-secondary);
  font-style: italic;
}

.profile-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  background: color-mix(in srgb, var(--host-authoring) 12%, transparent);
  color: var(--host-authoring);
  vertical-align: middle;
  white-space: nowrap;
}

.detail-json {
  margin: 0;
  font-size: 12px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 600px) {
  .configs-main {
    margin: 0 12px 16px;
  }

  .stats-section {
    flex-direction: column;
  }

  .type-breakdown {
    width: 100%;
  }
}
