

/* Config page forms, domain blocks, danger zone, toggles, warning banners. Extracted from style.css. */

/* Simple Configuration Tabs - Clean Design */
.config-actions {
  display: flex;
  gap: 12px;
  padding: 20px 20px 20px 0;
  background: transparent;
  margin-top: 0;
  flex-wrap: wrap;
}

.config-actions .action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
}

.config-actions .action-btn svg {
  width: 16px;
  height: 16px;
}

.config-actions .action-btn.primary {
  background: var(--primary-color);
  color: var(--text-primary);
  border: 1px solid var(--primary-color);
}

.config-actions .action-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
}

.config-actions .action-btn.secondary {
  background: rgba(var(--text-rgb), 0.1);
  border: 1px solid rgba(var(--text-rgb), 0.2);
  color: var(--text-primary);
}

.config-actions .action-btn.secondary:hover {
  background: rgba(var(--text-rgb), 0.2);
  transform: translateY(-1px);
}

.config-actions .action-btn:not(.primary):not(.secondary) {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary, #fff);
}

.config-actions .action-btn:not(.primary):not(.secondary):hover {
  background: var(--hover-bg);
  transform: translateY(-1px);
}

.config-title {
  padding: 20px;
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
}

.config-title h3 {
  margin: 0 0 8px 0;
  color: var(--text-primary, #fff);
  font-size: 18px;
  font-weight: 600;
}

.config-title p {
  margin: 0;
  color: var(--text-secondary, #ccc);
  font-size: 13px;
}

/* Page-level header used on /config and /backup so both surfaces start
   with the same prominent H1 + description above their content. */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid rgba(var(--text-rgb), 0.08);
  margin-bottom: 22px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.page-header-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: var(--accent);
}

.page-header-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.page-header-title h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-header-title p {
  margin: 0;
  color: var(--text-secondary, rgba(var(--text-rgb), 0.6));
  font-size: 0.9rem;
}

.page-header-title p:empty {
  display: none;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: center;
}

.config-container {
  border-radius: 12px;
  padding: 0;
  margin-bottom: 20px;
  overflow: hidden;
}

/* "Unsaved config changes" bar — sits in flow between an app's config content
   and its action buttons, shown by JS while any field differs from its saved
   value. */
.config-dirty-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
  padding: 12px 16px;
  background: var(--card-bg, #1c1c24);
  border: 1px solid var(--border-color, #333);
  border-left: 3px solid var(--status-warning);
  border-radius: 10px;
  animation: configDirtyIn 0.2s ease;
}

.config-dirty-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--status-warning);
}

.config-dirty-msg svg { flex-shrink: 0; }

.config-dirty-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.advanced-warning-banner .warning-content h4 {
  margin: 0 0 4px 0;
  color: var(--status-warning);
  font-size: 14px;
  font-weight: 600;
}

.advanced-warning-banner .warning-content p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

/* Traefik / domains "not installed" notice — glass card tinted with
   the theme warning colour. Matches the .system-card recipe. */
.traefik-warning-banner {
  background: rgba(var(--status-warning-rgb), 0.10);
  border: 1px solid rgba(var(--status-warning-rgb), 0.30);
  border-left: 4px solid var(--status-warning);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(var(--text-rgb), 0.06);
}

.traefik-warning-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.traefik-warning-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1.4;
  color: var(--status-warning);
}

.traefik-warning-text {
  flex: 1;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.traefik-warning-text strong {
  color: var(--status-warning);
  font-weight: 600;
  margin-right: 2px;
}

/* Configuration Form */
.config-form {
  padding: 0;
  margin: 0;
}

.config-form h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
}

.config-group {
}

.config-group h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid;
}

.config-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
  grid-auto-flow: dense;
  grid-auto-rows: minmax(min-content, max-content);
}

/* Responsive column counts — colocated here (and not in style.css)
   because the base 3-column rule above loads later than style.css,
   so the unscoped base would otherwise win the cascade against the
   style.css media queries that try to step down to 2 / 1 columns. */
@media (max-width: 1280px) {
  .config-fields {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 800px) {
  .config-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: fit-content;
}

.master-toggle,

.master-toggle .field-group,
.git-master-toggle .field-group {
  margin: 0;
  width: 100%;
}

.master-toggle input[type="checkbox"],
.git-master-toggle input[type="checkbox"] {
  display: none;
}

.config-field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.config-field input,
.config-field select {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.config-field input:focus,
.config-field select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Enhanced Config Form Styles */
.config-group {
}

.config-group h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  margin: 0 0 8px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-color, var(--accent));
}

.config-actions {
  display: flex;
  gap: 12px;
  padding-top: 0;
  margin-top: 0px;
}

/* Thin horizontal rule that separates the config form's sections — one sits
   above the advanced/danger-zone container, one above the Save/Reset buttons,
   and one at the top of #advanced-sections so a line appears between the "Show
   Advanced Options" toggle and the advanced fields only when they're revealed. */
.config-divider {
  height: 0;
  border: none;
  border-top: 1px solid var(--border-color, rgba(var(--text-rgb), 0.12));
  margin: 24px 0;
}

.git-master-toggle .master-toggle {
  display: flex;
  align-items: center;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: none;
}

.git-master-toggle .master-toggle:hover {
  background: rgba(var(--text-rgb), 0.05);
  transform: none;
}

/* System Config Sections - Override domain-specific CSS for non-domain configs */
.config-category:not(.app-config) .domains-header {
  display: block;
  margin-bottom: 16px;
}

.config-category:not(.app-config) .domains-header h3 {
  display: block;
  width: auto;
  justify-content: flex-start;
}

/* Each subcategory on the global config page renders as its own glass
   card, matching the .app-card recipe used on the App Center grid.
   The outer .config-section becomes a transparent layout wrapper so
   the categories aren't double-nested in two card chromes. */
.config-category:not(.app-config) {
  background: var(--card-bg);
  border: 1px solid var(--card-border, var(--border-color));
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

.config-category:not(.app-config) .spacer-lg {
  display: none;
}

/* Advanced subcategory badge — applied to subcategories rendered
   inside #advanced-sections. The old "🛠️ Advanced Configuration"
   divider above the group is gone; each subcategory's own h3 now
   carries an inline red "ADVANCED" tag so it self-identifies. */
.is-advanced .domains-header h3,
.is-advanced .config-category h3 {
  display: block;
  width: 100%;
  margin: 0;
}

.is-advanced .domains-header h3::after,
.is-advanced .config-category h3::after {
  content: 'Advanced';
  display: inline-block;
  vertical-align: middle;
  margin-left: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  background: rgba(var(--status-danger-rgb), 0.18);
  border: 1px solid rgba(var(--status-danger-rgb), 0.55);
  color: var(--status-danger);
  line-height: 1;
  position: relative;
  top: -1px;
}

/* App Config Sections - Complete separation from domain/system styling */
.app-config {
  /* App config container styling */
}

.app-config .panel-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.domain-input {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.domain-input:focus {
  border-color: var(--primary-color, var(--accent));
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
  outline: none;
}

.domain-building-blocks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: start;
  grid-auto-flow: dense;
  grid-auto-rows: minmax(min-content, max-content);
}

.domain-building-block {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: fit-content;
  gap: 12px;
}

.domain-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.domain-actions {
  padding: 10px 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.domain-input.flash {
  animation: flash 0.5s ease-in-out 2;
}

/* Wrapper around the whole config-page content — matches the visual
   "card" the App Center uses for its grid, so the two pages feel
   consistent (subtle glass surface + soft border + rounded corners
   floating on the cosmic gradient). */
.config-section {
  margin: 22px;
  padding: 22px;
  background: rgba(var(--text-rgb), 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}

/* Inside an app-detail tab-pane the .config-section's card chrome is
   redundant — the tab-pane is itself a card and the sibling tabs
   (Services / Tools / Backups / …) drop their content directly into
   the pane without an extra wrapper. Strip the inner card so the
   Config tab matches the rest. */
.tab-pane .config-section {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

/* ===== Mobile (≤768px) — global Config page ===== */
@media (max-width: 768px) {
  .config-section {
    margin: 10px;
    padding: 12px;
    /* flex-shrink: 0 keeps the section at its content's natural height
       inside .main's flex column — without it, the section's overflow
       (combined with .main's flex-shrink) collapsed the section down to
       the .main viewport height and the vertical scrollbar never
       appeared. overflow-x: hidden still clips wide grandchildren. */
    overflow-x: hidden;
    flex-shrink: 0;
  }

  .config-category:not(.app-config) {
    padding: 22px;
  }

  .config-section,
  .config-form,
  .config-category,
  .config-group,
  .config-fields,
  .config-field,
  .field-group,
  .domains-wrapper,
  .domains-header,
  .password-input-group {
    min-width: 0;
    max-width: 100%;
  }

  .field-group,
  .config-field {
    width: 100%;
  }

  .config-field input,
  .config-field select,
  .config-field textarea,
  .field-group input,
  .field-group select,
  .field-group textarea,
  .form-input,
  .form-select,
  .form-textarea,
  .form-control {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .config-form {
    margin: 0;
    padding: 0;
  }

  .config-title {
    padding: 14px;
  }

  .config-title h3 {
    font-size: 16px;
  }

  .config-container {
    margin-bottom: 12px;
  }

  .config-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .config-actions {
    padding: 14px 0;
    gap: 8px;
  }

  .config-actions .action-btn {
    flex: 1 1 100%;
    justify-content: center;
    padding: 12px 16px;
  }

  .config-dirty-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}
