/* =========================================================
   Admin area page styles
   ========================================================= */

/* Align action buttons consistently in tables */
td.actions {
  white-space: nowrap;
}
td.actions .btn {
  margin-left: .4rem;
}

/* =========================================================
   Access Method modal: requirements right-side panel
   ========================================================= */

.method-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.method-main {
  flex: 1 1 auto;
  min-width: 480px;
}

.method-requirements {
  flex: 0 0 520px;
  max-width: 520px;
}

#requirements-panel {
  background: transparent;
}

/* Edit Access Method modal: allow right-side requirements panel */
#edit-method-modal.modal-overlay > * {
  width: min(820px, 100%);
}

#edit-method-modal.modal-overlay.requirements-open > * {
  width: min(1180px, calc(100vw - 48px));
}

#edit-method-modal .method-layout {
  flex-wrap: wrap;
}

#edit-method-modal .method-main {
  flex: 1 1 520px;
  min-width: 520px;
}

#edit-method-modal .method-requirements {
  flex: 0 1 520px;
  max-width: 520px;
}

/* Theme the injected requirement form */
#edit-method-modal .requirements-form-slot > * {
  background: var(--surface-2) !important;
  border: 1px solid var(--border-1) !important;
  border-radius: var(--radius-2);
  padding: .75rem;
  color: var(--text-1);
}

#edit-method-modal .requirements-form-slot label {
  color: var(--text-2);
}

#edit-method-modal .requirements-form-slot .text-muted {
  color: var(--text-3) !important;
}

/* =========================================================
   User typeahead selector (Feature B)
   ========================================================= */

.user-typeahead {
  position: relative;
}

.user-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 4000;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-2);
}

.user-search-results:empty {
  display: none;
}

.user-search-result {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  cursor: pointer;
}

.user-search-result:hover {
  background: var(--surface-3);
}

.user-search-name {
  font-weight: 500;
}

.user-search-email {
  font-size: .8rem;
  color: var(--text-3);
}

/* =========================================================
   Configuration editor (Feature A)
   ========================================================= */

.config-page-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.config-tag-list {
  width: 100%;
}

.config-tag-selected {
  background: var(--surface-3);
}

.config-mode-toggle {
  display: flex;
  gap: .25rem;
}

.config-raw-textarea {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: .85rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
}

.config-editor-actions {
  display: flex;
  gap: .5rem;
}

.config-section {
  border-left: 2px solid var(--border-1);
  padding-left: .75rem;
}

.config-section-label {
  font-weight: 500;
  font-size: .9rem;
  cursor: pointer;
  color: var(--text-1);
}

.config-section-body {
  padding-top: .25rem;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.config-field-label {
  font-size: .85rem;
  color: var(--text-2);
  font-weight: 500;
}

.config-required {
  color: var(--state-danger-text);
  margin-left: .2rem;
}

.config-help-text,
.config-help-inline {
  font-size: .78rem;
  color: var(--text-3);
}

.config-input {
  max-width: 400px;
}

.config-checkbox {
  width: auto;
  margin: .25rem 0;
}

/* Config diff confirmation */
.config-diff-table td {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: .8rem;
  word-break: break-all;
}

.config-diff-old {
  color: var(--state-danger-text);
  background: var(--state-danger-bg);
}

.config-diff-new {
  color: var(--state-success-text);
  background: var(--state-success-bg);
}

.config-json-diff-panel {
  display: flex;
  gap: 1rem;
}

.config-json-diff-col {
  flex: 1;
  min-width: 0;
}

.config-json-pre {
  font-size: .78rem;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-1);
  padding: .5rem;
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-all;
}


/* =========================================================
   Access Method modal polish
   ========================================================= */

/* Give the two columns slightly better visual balance */
#edit-method-modal .method-layout {
  gap: 22px;
  align-items: flex-start;
}

/* Slightly more breathing room in the form column */
#edit-method-modal .method-main {
  padding-right: 4px;
}

/* Make the requirements panel feel like a panel */
#edit-method-modal #requirements-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  padding: .65rem .75rem .75rem;
}

/* Clean header alignment */
#edit-method-modal #requirements-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .55rem;
}

/* Match typography with form labels */
#edit-method-modal #requirements-panel strong {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
}

/* Tighten table appearance slightly */
#edit-method-modal .requirements-scroll .table th {
  font-size: .75rem;
}

/* Slightly lighter table rows for modal context */
#edit-method-modal .requirements-scroll .table td {
  font-size: .85rem;
}

/* Align action buttons consistently */
#edit-method-modal .requirements-scroll .btn-xs {
  font-size: .78rem;
}

/* Ensure textarea and panel align visually */
#edit-method-modal textarea.form-control {
  min-height: 110px;
}



/* =========================================================
   Edit Access Method requirements panel tidy
   ========================================================= */

#edit-method-modal .method-layout {
  align-items: flex-start;
}

#edit-method-modal .method-requirements {
  margin-top: 22px;
}

#edit-method-modal #requirements-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  padding: .6rem .8rem .7rem;
}

#edit-method-modal .requirements-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .55rem;
}

#edit-method-modal .requirements-panel-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.2;
}

#edit-method-modal .requirements-panel-header .btn {
  align-self: center;
}

#edit-method-modal .requirements-scroll .table th {
  font-size: .75rem;
  letter-spacing: .05em;
}

#edit-method-modal .requirements-scroll .table td {
  font-size: .84rem;
  line-height: 1.3;
}

#edit-method-modal .requirements-scroll .btn-xs {
  font-size: .78rem;
}

#edit-method-modal textarea.form-control {
  min-height: 110px;
}


.config-field-bool {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.config-bool-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.config-bool-label {
  margin: 0;
}

.config-checkbox {
  width: auto !important;
  max-width: none;
  flex: 0 0 auto;
  margin: 0;
  align-self: flex-start;
}

/* ── Status page ─────────────────────────────────────────────────────────── */

.status-overall {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.status-overall-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.status-overall-value {
  font-size: 1.15rem;
}

.status-healthy {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #16a34a;
}

.status-degraded {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #ca8a04;
}

.status-unhealthy {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.status-alert-badge {
  margin-left: auto;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  text-decoration: none;
}

.status-alert-badge:hover {
  text-decoration: underline;
}

.status-section-title {
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.status-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.status-card {
  flex: 1 1 140px;
  max-width: 220px;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
}

.status-card-warn {
  border-color: rgba(234, 179, 8, 0.4);
  background: rgba(234, 179, 8, 0.06);
}

.status-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-bottom: 0.25rem;
}

.status-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.status-card-denominator {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-3);
}

.status-card-detail {
  font-size: 0.76rem;
  color: var(--text-3);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.status-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-1);
}

/* Dark mode overrides for status */
[data-theme="dark"] .status-healthy {
  background: rgba(34, 197, 94, 0.08);
  color: #4ade80;
}

[data-theme="dark"] .status-degraded {
  background: rgba(234, 179, 8, 0.08);
  color: #facc15;
}

[data-theme="dark"] .status-unhealthy {
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
}

[data-theme="dark"] .status-alert-badge {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

[data-theme="dark"] .status-card-warn {
  border-color: rgba(234, 179, 8, 0.3);
  background: rgba(234, 179, 8, 0.08);
}

/* ── Help page ───────────────────────────────────────────────────────────── */

.help-section {
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  overflow: hidden;
}

.help-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 1rem;
  margin: 0;
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  text-align: left;
  font-family: inherit;
  line-height: 1.3;
}

.help-section-toggle:hover {
  background: var(--surface-3);
}

.help-section-toggle::after {
  content: "▸";
  font-size: 0.85rem;
  color: var(--text-3);
  transition: transform 150ms ease;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.help-section.open .help-section-toggle::after {
  transform: rotate(90deg);
}

.help-section-body {
  display: none;
  padding: 1rem 1.25rem;
}

.help-section.open .help-section-body {
  display: block;
}

.help-section-body h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  color: var(--text-1);
}

.help-section-body h3:first-child {
  margin-top: 0;
}

.help-section-body p {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-2);
}

.help-section-body a {
  color: var(--accent);
}

.help-section-body a:hover {
  text-decoration: underline;
}
