/* Colors and base layout as in HAProxy Manager — Bootstrap stays the base,
   only its variables and individual components are adjusted here. */
:root,
[data-bs-theme="dark"] {
  --bs-body-bg: #0f1218;
  --bs-tertiary-bg: #151a22;
  --bs-secondary-bg: #1b212b;
  --bs-border-color: #262e3b;
  --bs-primary: #3d8bfd;
  --bs-primary-rgb: 61, 139, 253;
  --pd-card-bg: #151a22;
  --pd-muted: #8a94a6;
}

body {
  min-height: 100vh;
}

/* ---------- Navigation ---------- */
.brand-logo {
  border-radius: 8px;
}

.pd-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2b3445;
  font-size: .8rem;
  font-weight: 600;
}

/* ---------- Page header, cards, tables ---------- */
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.page-title h1 {
  font-size: 1.5rem;
  margin: 0;
}

.page-title .subtitle {
  color: var(--pd-muted);
  font-size: .9rem;
}

.card {
  background-color: var(--pd-card-bg);
  border-color: var(--bs-border-color);
}

.card-header {
  background-color: rgba(255, 255, 255, .02);
  border-color: var(--bs-border-color);
  font-weight: 600;
}

.card-footer {
  background-color: rgba(255, 255, 255, .02);
  border-color: var(--bs-border-color);
}

.kpi-label {
  color: var(--pd-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.table > :not(caption) > * > * {
  background-color: transparent;
}

.table thead th {
  color: var(--pd-muted);
  font-weight: 500;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.table-sm td {
  vertical-align: middle;
}

.list-group-item {
  background-color: transparent;
}

.text-muted-2 {
  color: var(--pd-muted) !important;
}

.pd-footer {
  border-top: 1px solid var(--bs-border-color);
  color: var(--pd-muted);
}

.toast-container {
  z-index: 1090;
}

.toast-body {
  font-family: monospace;
  white-space: pre-wrap;
  font-size: .8rem;
}

.node-card {
  transition: transform .15s ease;
}

.node-card:hover {
  transform: translateY(-3px);
}

.border-leader {
  border-left: 5px solid var(--bs-success) !important;
}

.border-replica {
  border-left: 5px solid var(--bs-primary) !important;
}

.border-down {
  border-left: 5px solid var(--bs-danger) !important;
}

.lag-chart {
  position: relative;
  height: 240px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.scroll-panel {
  max-height: 300px;
  overflow-y: auto;
}

.step-detail {
  font-size: .72rem;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
}

.cred {
  font-family: monospace;
  font-size: .85rem;
}

.cred-block {
  font-family: monospace;
  font-size: .75rem;
  white-space: pre-wrap;
}

#logs {
  height: calc(100vh - 230px);
  background: #0b0e13;
  border-color: var(--bs-border-color) !important;
  color: #c9d1d9;
  overflow: auto;
  white-space: pre;
  font: .82rem/1.45 monospace;
}

footer code {
  font-size: inherit;
}

/* ---------- Setup wizard ---------- */
.setup-wrap {
  max-width: 980px;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: .5rem;
}

.setup-step {
  display: block;
  padding: .6rem .8rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  background: var(--pd-card-bg);
  color: var(--pd-muted);
  font-size: .8rem;
  line-height: 1.25;
  text-decoration: none;
  hyphens: auto;
  overflow-wrap: anywhere;
}

a.setup-step:hover {
  border-color: var(--bs-primary);
}

.setup-step.done {
  border-color: #2fb34466;
  color: #8fd19e;
}

.setup-step.current {
  border-color: var(--bs-primary);
  color: #fff;
  box-shadow: 0 0 0 1px var(--bs-primary) inset;
}

.choice-card {
  display: block;
  height: 100%;
  padding: 1.25rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  background: var(--pd-card-bg);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}

.choice-card:hover {
  border-color: var(--bs-primary);
  transform: translateY(-2px);
}

.btn-check:checked + .choice-card {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 1px var(--bs-primary) inset;
}

.btn-check:focus-visible + .choice-card {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.choice-card .choice-icon {
  font-size: 2rem;
  line-height: 1;
}

/* Test result in settings cards: only visible when there is one */
.test-result:empty {
  display: none;
}

/* ---------- Login ---------- */
.login-wrap,
.login-alert {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.login-wrap {
  margin-top: 8vh;
}

/* Number directly below an event ("Benachrichtigungen" page) */
.pd-inline-input {
  max-width: 260px;
}

/* Setup step skipped by the current choice (e.g. Nodes for a new cluster) */
.setup-step.skipped {
  opacity: .45;
  text-decoration: line-through;
}

/* ---------- Patroni setup ---------- */
.setup-code {
  background: #0b0e13;
  border: 1px solid var(--bs-border-color);
  border-radius: .375rem;
  padding: .5rem .75rem;
  margin: .25rem 0 .5rem;
  max-height: 340px;
  overflow: auto;
  font-size: .78rem;
  color: #c9d1d9;
  white-space: pre;
}

.setup-code.output {
  white-space: pre-wrap;
  word-break: break-all;
}

.run-step {
  cursor: pointer;
}

.run-step.active {
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 1px var(--bs-primary) inset;
}

.run-status {
  width: 1.25rem;
  text-align: center;
  flex: 0 0 1.25rem;
}

/* ==========================================================================
   Design: shadcn-style sidebar (as in HAProxy Manager since 1.0.40)
   Colors stay: background #0f1218, cards #151a22, lines #262e3b, blue #3d8bfd
   ========================================================================== */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
:root, [data-bs-theme="dark"] {
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: .9rem;
  --bs-body-color: #e6e9ef;
  --bs-border-radius: .5rem; --bs-border-radius-sm: .375rem; --bs-border-radius-lg: .75rem;
  --pd-sidebar-w: 248px;
}
body { font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
.min-w-0 { min-width: 0; }

/* Scaffold: fixed sidebar on the left, content next to it. Pages only include _site_header.html,
   so the offset is derived from the sidebar itself (:has). */
@media (min-width: 992px) {
  body:has(> .pd-sidebar) { padding-left: var(--pd-sidebar-w); }
}
body:has(> .pd-sidebar) > :is(main, .container-fluid) { max-width: 1600px; width: 100%; }

.pd-sidebar { background: #151a22; border-right: 1px solid var(--bs-border-color); }
@media (min-width: 992px) {
  .pd-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--pd-sidebar-w); z-index: 1030; }
}
@media (max-width: 991.98px) { .pd-sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; --bs-offcanvas-bg: #151a22; } }
.pd-sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: .85rem .75rem .75rem; overflow-y: auto; }
.pd-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: #fff; text-decoration: none; padding: .25rem .5rem; white-space: nowrap; }
.pd-brand img { border-radius: .5rem; }
.pd-brand:hover { color: #fff; }

/* Menu: flat, without collapsible groups */
.pd-nav { display: flex; flex-direction: column; gap: 1px; margin-top: .75rem; }
.pd-nav-title { color: var(--pd-muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: .7rem .75rem .2rem; }
.pd-nav-link { display: flex; align-items: center; gap: .65rem; padding: .4rem .75rem; border-radius: .5rem;
  color: #aab3c2; text-decoration: none; font-size: .875rem; }
.pd-nav-link .bi { font-size: 1rem; width: 1.1rem; text-align: center; opacity: .85; }
.pd-nav-link:hover { background: #1b212b; color: #fff; }
.pd-nav-link.active { background: #1b212b; color: #fff; box-shadow: inset 2px 0 0 var(--bs-primary); }
.pd-nav-link.active .bi { color: var(--bs-primary); opacity: 1; }
.pd-sidebar-foot { margin-top: auto; padding-top: .6rem; border-top: 1px solid var(--bs-border-color); }
.pd-user { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; padding: .35rem .5rem;
  border-radius: .5rem; min-width: 0; }
/* Role "User": controls for changes are hidden (the server refuses them anyway) */
html[data-role="user"] .admin-only { display: none !important; }

/* Header bar: menu button + logo on small screens, status badges on Cluster/Databases */
.pd-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem;
  background: rgba(21, 26, 34, .95); border-bottom: 1px solid var(--bs-border-color); backdrop-filter: blur(6px); }
@media (min-width: 992px) { .pd-topbar { padding: .6rem 1.5rem; } }
.pd-topbar-status { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-left: auto; }

/* Cards: rounded, thin borders, calm headers */
.card { border-radius: .75rem; --bs-card-inner-border-radius: calc(.75rem - 1px); }
.card-header { background-color: transparent; font-weight: 600; font-size: .875rem; padding: .85rem 1.25rem; }
.card-body { padding: 1.1rem 1.25rem; }
.card-footer { background-color: transparent; }

.page-title h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }

/* KPIs: label small and muted, value large */
.kpi-label { text-transform: none; letter-spacing: 0; font-size: .78rem; }
.kpi-value { font-weight: 600; letter-spacing: -.01em; }

/* Badges: subtly tinted */
.badge { font-weight: 500; border-radius: 999px; padding: .3em .65em; }
.badge.text-bg-success { background-color: rgba(47, 179, 68, .15) !important; color: #4cc764 !important; }
.badge.text-bg-warning { background-color: rgba(255, 193, 7, .15) !important; color: #ffc107 !important; }
.badge.text-bg-danger { background-color: rgba(214, 57, 57, .18) !important; color: #f06a6a !important; }
.badge.text-bg-info { background-color: rgba(61, 139, 253, .15) !important; color: #6ea8fe !important; }
.badge.text-bg-primary { background-color: rgba(61, 139, 253, .18) !important; color: #8bb9fe !important; }
.badge.text-bg-secondary { background-color: rgba(138, 148, 166, .16) !important; color: #b3bccb !important; }

/* Tables: muted header, no uppercase */
.table { --bs-table-bg: transparent; }
.table > thead th { color: var(--pd-muted); font-weight: 500; font-size: .78rem; text-transform: none; letter-spacing: 0;
  border-bottom-color: var(--bs-border-color); }
.table > :not(caption) > * > * { border-bottom-color: var(--bs-border-color); }
:is(.card, .card > .collapse) > .table-responsive > .table > :not(caption) > * > :first-child,
:is(.card, .card > .collapse) > .table > :not(caption) > * > :first-child { padding-left: 1rem; }
:is(.card, .card > .collapse) > .table-responsive > .table > :not(caption) > * > :last-child,
:is(.card, .card > .collapse) > .table > :not(caption) > * > :last-child { padding-right: 1rem; }

/* Buttons, inputs, alerts */
.btn { font-weight: 500; }
.form-control, .form-select { background-color: #0f1218; border-color: var(--bs-border-color); }
.form-control:focus, .form-select:focus { border-color: rgba(61, 139, 253, .6); box-shadow: 0 0 0 .2rem rgba(61, 139, 253, .15); }
.alert { border-radius: .75rem; }
.dropdown-menu { border-radius: .6rem; border-color: var(--bs-border-color); background-color: #151a22; }
.modal-content { border-radius: .75rem; border-color: var(--bs-border-color); background-color: #151a22; }
.choice-card { border-radius: .75rem; }

/* Setup wizard steps in the sidebar */
.pd-steps { list-style: none; margin: .25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pd-step > a, .pd-step > span { display: flex; align-items: center; gap: .65rem; padding: .4rem .75rem; border-radius: .5rem;
  color: #aab3c2; text-decoration: none; font-size: .875rem; }
.pd-step > a:hover { background: #1b212b; color: #fff; }
.pd-step-num { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; flex: none;
  font-size: .72rem; font-weight: 600; border: 1px solid var(--bs-border-color); color: var(--pd-muted); }
.pd-step.done .pd-step-num { background: rgba(47, 179, 68, .15); border-color: transparent; color: #4cc764; }
.pd-step.current > span { background: #1b212b; color: #fff; box-shadow: inset 2px 0 0 var(--bs-primary); }
.pd-step.current .pd-step-num { background: var(--bs-primary); border-color: transparent; color: #fff; }
.pd-step.todo > span { opacity: .65; }
.pd-step.skipped > span { opacity: .45; text-decoration: line-through; }
body:has(> .pd-sidebar) .setup-wrap { max-width: 920px; margin: 0; }

/* Patroni setup steps (in the content, horizontal): same numbered circles */
.setup-steps { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: .4rem; }
.setup-step { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: .6rem;
  border-color: var(--bs-border-color); color: #aab3c2; font-size: .82rem; }
a.setup-step:hover { border-color: var(--bs-border-color); background: #1b212b; color: #fff; }
.setup-step.done { border-color: var(--bs-border-color); color: #aab3c2; }
.setup-step.done .pd-step-num { background: rgba(47, 179, 68, .15); border-color: transparent; color: #4cc764; }
.setup-step.current { border-color: var(--bs-border-color); background: #1b212b; color: #fff; box-shadow: inset 2px 0 0 var(--bs-primary); }
.setup-step.current .pd-step-num { background: var(--bs-primary); border-color: transparent; color: #fff; }

/* Pages without a sidebar (login, logout, setup token): content centered */
.pd-plain main { display: flex; flex-direction: column; justify-content: center; }
.pd-plain-wrap { width: 100%; max-width: 580px; margin: 0 auto; }
.pd-plain .login-wrap { margin-top: 0; }

/* Collapsible cards (static/cards.js): header toggles, chevron rotates */
.card-collapse-header { cursor: pointer; user-select: none; display: flex; align-items: center; gap: .4rem; }
.card-collapse-end { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.card-collapse-header.justify-content-between { justify-content: flex-start !important; }
.collapse-chevron { color: var(--pd-muted); font-size: .8rem; transition: transform .2s; }
.card-collapse-header[aria-expanded="true"] .collapse-chevron { transform: rotate(180deg); }
.card-collapse-header:hover .collapse-chevron { color: #fff; }
.card-collapse-header[aria-expanded="false"] { border-bottom-color: transparent; }
/* collapsed card in a row (h-100): do not stretch it empty to full height */
.card.h-100:has(> .collapse:not(.show, .collapsing)) { height: auto !important; }

/* ---------- Configurations: file explorer ---------- */
.config-tree { max-height: 70vh; overflow-y: auto; }
.config-folder > summary { cursor: pointer; list-style: none; }
.config-folder > summary::-webkit-details-marker { display: none; }
.config-file { color: inherit; text-decoration: none; border-left: 2px solid transparent; }
.config-file:hover { background: var(--bs-tertiary-bg); }
.config-file.active { background: var(--bs-tertiary-bg); border-left-color: var(--bs-primary); }
.config-content { max-height: 70vh; overflow: auto; white-space: pre; }

/* ---------- Notifications: delivery type selection in the popup ---------- */
.channel-choice {
  padding: .75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  background: var(--pd-card-bg);
  color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.channel-choice:hover { border-color: var(--bs-primary); transform: translateY(-2px); }
.channel-choice.active { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary) inset; }
.channel-choice:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

/* QR code of the two-factor setup */
#twofa svg { width: 100%; height: auto; display: block; }

/* Passwords in configuration files: blurred until clicked (configs.html) */
.secret-blur { filter: blur(5px); cursor: pointer; border-radius: .2rem; transition: filter .15s ease;
               background: rgba(255, 193, 7, .12); }
.secret-blur:focus-visible { outline: 1px solid var(--bs-warning); }
.secret-blur.revealed { filter: none; }

/* Mein Konto: tiles to add a second factor */
.mfa-choice { display: flex; flex-direction: column; gap: .25rem; width: 100%; height: 100%; text-align: left;
  padding: .9rem 1rem; border: 1px solid var(--bs-border-color); border-radius: .6rem; background: transparent; color: inherit; }
.mfa-choice .bi { font-size: 1.4rem; color: var(--bs-primary); }
.mfa-choice:hover:not(:disabled), .mfa-choice.active { border-color: var(--bs-primary); background: #1b212b; }
.mfa-choice:disabled { opacity: .5; cursor: not-allowed; }
