/* Application layer on top of AdminLTE 4 (vendored, see app/templates/base.html).

   Why this file exists: most templates were written before the theme, with bare <table>, <input>, <button> and a handful of
   helper classes (.stats, .filters, .actions, button.link, ...). Rather than rewriting all of them at once, this maps those to
   AdminLTE's look using Bootstrap's own CSS variables, so light and dark modes both work. New templates should prefer the
   Bootstrap/AdminLTE classes (card, table, form-control, btn, badge, alert, callout) directly. */

/* ---- Aïon Solutions brand (colours of https://www.aion-solutions.lu/) ----
   Yellow and orange are the logo's gradient, slate the site's dark background. Buttons are yellow with dark text, as on the
   site. Link text uses a darker orange than the site's #f28507, which is too light to read as text on white (contrast < 3). */
:root {
  --aion-yellow: #ffcd1c; --aion-yellow-rgb: 255, 205, 28;
  --aion-orange: #f99d33; --aion-orange-dark: #f28507;
  --aion-slate: #3b4348; --aion-slate-dark: #2f363a;
  --aion-gradient: linear-gradient(90deg, var(--aion-yellow), var(--aion-orange));
}
:root, [data-bs-theme=light] {
  --bs-primary: var(--aion-yellow); --bs-primary-rgb: var(--aion-yellow-rgb);
  --bs-success: #23b053; --bs-success-rgb: 35, 176, 83;
  --bs-link-color: #b35c00; --bs-link-color-rgb: 179, 92, 0;
  --bs-link-hover-color: #8a4700; --bs-link-hover-color-rgb: 138, 71, 0;
}
[data-bs-theme=dark] {
  --bs-primary: var(--aion-yellow); --bs-primary-rgb: var(--aion-yellow-rgb);
  --bs-link-color: var(--aion-yellow); --bs-link-color-rgb: var(--aion-yellow-rgb);
  --bs-link-hover-color: var(--aion-orange); --bs-link-hover-color-rgb: 249, 157, 51;
}
.btn-primary {
  --bs-btn-color: #212529; --bs-btn-bg: var(--aion-yellow); --bs-btn-border-color: var(--aion-yellow);
  --bs-btn-hover-color: #212529; --bs-btn-hover-bg: var(--aion-orange); --bs-btn-hover-border-color: var(--aion-orange);
  --bs-btn-active-color: #212529; --bs-btn-active-bg: var(--aion-orange-dark); --bs-btn-active-border-color: var(--aion-orange-dark);
  --bs-btn-disabled-color: #212529; --bs-btn-disabled-bg: var(--aion-yellow); --bs-btn-disabled-border-color: var(--aion-yellow);
  --bs-btn-focus-shadow-rgb: var(--aion-yellow-rgb);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--aion-orange); box-shadow: 0 0 0 .25rem rgba(var(--aion-yellow-rgb), .35); }
.form-check-input:checked { background-color: var(--aion-orange); border-color: var(--aion-orange); }
.app-header { border-top: 3px solid var(--aion-yellow); border-image: var(--aion-gradient) 1; }
.app-sidebar {
  background-color: var(--aion-slate) !important;
  --lte-sidebar-color: #d5d9dc; --lte-sidebar-hover-color: #fff; --lte-sidebar-hover-bg: rgba(255, 255, 255, .08);
  --lte-sidebar-header-color: var(--aion-yellow);
}
.app-sidebar .sidebar-brand { border-bottom-color: rgba(255, 255, 255, .1); }
.app-sidebar .sidebar-menu .nav-link.active { background: var(--aion-gradient); color: #212529; font-weight: 600; }
.app-sidebar .sidebar-menu .nav-header { color: var(--aion-yellow); opacity: .85; font-size: .75rem; letter-spacing: .06em; }
.login-page { background: var(--aion-slate) !important; }
.login-page .login-logo { color: #fff; }
.login-page .login-logo img { width: 4.5rem; height: 4.5rem; display: block; margin: 0 auto .5rem; }

/* ---- Layout: header, sidebar brand, theme switch ---- */
.app-content { padding-top: 1.25rem; padding-bottom: 1.25rem; }
/* Wide legacy tables scroll inside the content area instead of widening the whole page (and pushing the header off-screen). */
.app-main { min-width: 0; }
.app-content > .container-fluid { overflow-x: auto; }
.sidebar-brand .brand-logo { width: 2rem; height: 2rem; margin-right: .6rem; }
.sidebar-brand .brand-link { display: inline-flex; align-items: center; white-space: nowrap; }
.app-header .nav-link .ti { font-size: 1.2rem; vertical-align: middle; }
.app-sidebar .nav-icon.ti { font-size: 1.15rem; }
.user-initial { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--bs-secondary-bg); font-weight: 600; font-size: .85rem; }
/* Selected entry of a dropdown (language menu, ...) in the brand colours rather than Bootstrap's blue. */
.dropdown-menu { --bs-dropdown-link-active-bg: var(--aion-yellow); --bs-dropdown-link-active-color: #212529; }
.dropdown-item.active, .dropdown-item:active { color: #212529; background-color: var(--aion-yellow); }
/* Language menu of the header (app/i18n.py). */
.language-menu .dropdown-menu form { margin: 0; }
.language-menu .language-code { display: inline-block; width: 1.75rem; font-size: .75rem; font-weight: 600;
  color: var(--bs-secondary-color); }
.language-menu .dropdown-item.active .language-code { color: inherit; }
/* Show only the button that switches to the other mode. */
html[data-bs-theme=dark] .theme-light-only, html:not([data-bs-theme=dark]) .theme-dark-only { display: none; }

/* Label bubble of the folded sidebar's icons (js/sidebar-tooltips.js), on the icon's right with a small arrow. */
.sidebar-tip { position: fixed; z-index: 1080; transform: translateY(-50%); padding: .3rem .65rem; font-size: .85rem;
  font-weight: 500; white-space: nowrap; color: #fff; background: var(--aion-slate-dark); border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow-sm); pointer-events: none; opacity: 0; transition: opacity .12s; }
.sidebar-tip::before { content: ""; position: absolute; top: 50%; left: -5px; margin-top: -5px;
  border: 5px solid transparent; border-left: 0; border-right-color: var(--aion-slate-dark); }
.sidebar-tip.show { opacity: 1; }

/* ---- Typography of legacy pages ---- */
.app-content h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1rem; }
.app-content h2 { font-size: 1.15rem; font-weight: 600; margin: 1.75rem 0 .75rem; }
.app-content h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
.error { color: var(--bs-danger); }
.hint { color: var(--bs-secondary-color); font-size: .8rem; margin-right: .5rem; }
pre, code { font-size: .85em; }
.code-block { background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius);
  padding: .75rem 1rem; overflow-x: auto; }

/* ---- Tables: Bootstrap's .table look for every bare table ---- */
.app-content table { width: 100%; border-collapse: collapse; margin: .75rem 0 1.25rem; background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); }
.app-content th, .app-content td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--bs-border-color); vertical-align: top; }
.app-content th { background: var(--bs-secondary-bg); font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--bs-secondary-color); }
.app-content tbody tr:hover { background: var(--bs-tertiary-bg); }
.app-content tr:last-child td { border-bottom: 0; }
tr.inherited { color: var(--bs-secondary-color); }

/* ---- Form controls: Bootstrap's .form-control look for every bare control ---- */
.app-content :is(input:not([type=checkbox], [type=radio], [type=hidden], [type=submit], [type=button], [type=file]), select, textarea),
.login-card-body
  :is(input:not([type=checkbox], [type=radio], [type=hidden], [type=submit], [type=button]), select, textarea) {
  padding: .375rem .75rem; font-size: .875rem; line-height: 1.5; color: var(--bs-body-color); background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); max-width: 100%; }
.app-content :is(input, select, textarea):focus, .login-card-body :is(input, select, textarea):focus {
  outline: 0; border-color: var(--bs-primary); box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .25); }
input[readonly], tr.inherited input[readonly] { background: var(--bs-secondary-bg) !important; }
textarea { min-height: 6rem; font-family: var(--bs-font-monospace); font-size: .8rem !important; }
.app-content label { margin-right: 1rem; }
.app-content .filters label, .app-content .field { display: flex; flex-direction: column; font-size: .85rem; color: var(--bs-secondary-color); }
.filters { display: flex; gap: 1rem; align-items: end; margin: 1rem 0; flex-wrap: wrap; }
.filters input, .filters select { margin-top: .25rem; }
.field-wide { width: 100%; max-width: 40rem; }
.actions { margin: 1rem 0; }
form.inline { display: inline; }

/* ---- Forms: one layout everywhere ----
   Label above the field (.form-label), fields on Bootstrap's 12-column grid (.row.g-3 > .col-md-N, full width on phones), help
   under the field (.form-hint), buttons together on one actions row (.form-actions: primary yellow, others outlined). An add/edit
   form sits in a titled card (.form-card), a page's own form is kept narrow (.form-narrow). Filter bars use .form-filters. */
.form-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius);
  padding: 1rem 1.25rem; margin: 1rem 0; }
/* Inside a tab panel (same colour as a card), a form gets a faint tint so it stands out from the surrounding text; its fields
   keep the panel colour, so they still read as fields. On the page background a plain card already stands out. */
:root, [data-bs-theme=light] { --form-card-tint: rgba(0, 0, 0, .03); }
[data-bs-theme=dark] { --form-card-tint: rgba(255, 255, 255, .055); }
.page-tab-content .form-card, .admin-card .form-card { background: var(--form-card-tint); }
.page-tab-content .form-card :is(.form-control, .form-select), .page-tab-content .form-card textarea { background-color: var(--bs-body-bg); }
.app-content .form-card-title { font-size: 1rem; font-weight: 600; margin: 0 0 .75rem; }
/* Buttons of a form as tall as its fields (the fields use the compact .875rem size of app.css). */
.app-content .form-card .btn:not(.btn-sm) { padding: .375rem .9rem; font-size: .875rem; line-height: 1.5; }
.form-narrow { max-width: 40rem; }
.app-content .form-label { display: block; margin: 0 0 .25rem; font-size: .8rem; font-weight: 500; color: var(--bs-secondary-color); }
.app-content .form-control, .app-content .form-select { width: 100%; }
.form-hint { margin-top: .25rem; font-size: .8rem; color: var(--bs-secondary-color); }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.form-actions .ms-auto { margin-left: auto; }
.form-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: .75rem 1rem; }
.form-filters > div { min-width: 9rem; }
.form-filters .form-actions { margin-top: 0; }
.form-switches { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: center; }
.form-switches .form-check { margin: 0; }
.logs-more-filters > summary { cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--bs-link-color); width: max-content; }
/* Page title with its main action on the right (e.g. "Clients" ... "+ New client"). */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.page-head h1 { margin: 0 !important; }

/* ---- Buttons ---- */
.app-content button:not(.btn):not(.btn-close):not(.nav-link),
.login-card-body button:not(.btn):not(.btn-close):not(.nav-link),
a.button {
  display: inline-block; padding: .375rem .9rem; font-size: .875rem; line-height: 1.5; border-radius: var(--bs-border-radius);
  border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); cursor: pointer; text-decoration: none; }
.app-content button:not(.btn):not(.nav-link):hover { border-color: var(--aion-orange); }
.app-content button[type=submit]:not(.danger):not(.btn), .login-card-body button[type=submit]:not(.danger):not(.btn),
a.button, button.link {
  background: var(--bs-primary); border-color: var(--bs-primary); color: #212529; }
.app-content button[type=submit]:not(.danger):not(.btn):hover, a.button:hover, button.link:hover {
  background: var(--aion-orange); border-color: var(--aion-orange); }
/* Destructive actions (Remove, Revoke, ...): same specificity as the generic bare-button rule above, so it must come after it. */
.app-content button.danger:not(.btn):not(.btn-close):not(.nav-link) {
  background: var(--bs-danger); border-color: var(--bs-danger); color: #fff; padding: .2rem .6rem; font-size: .8rem; }

/* ---- Back links ("← Projects") and icon actions (pencil = edit) ---- */
.back-link { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .8rem .25rem .55rem; font-size: .85rem;
  font-weight: 500; color: var(--bs-secondary-color); background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
  border-radius: 2rem; text-decoration: none; }
.back-link .ti { font-size: 1rem; }
.back-link:hover { color: #212529; background: var(--aion-yellow); border-color: var(--aion-yellow); }
.icon-action { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem;
  border-radius: var(--bs-border-radius); color: #212529; background: var(--aion-yellow); text-decoration: none; }
.icon-action .ti { font-size: 1.35rem; }
.icon-action:hover { color: #212529; background: var(--aion-orange); }
h1 .icon-action .ti { font-size: 1.3rem; }
/* In a table cell, the 2rem hit area must not push the row taller than its text. */
td .icon-action { margin: -.35rem 0; vertical-align: middle; }

/* ---- Page tabs (project, domains): tabs sit on a card-like panel so each section reads as one block (js/tabs.js) ---- */
.page-tabs { margin-top: 1.25rem; border-bottom: 0; gap: .15rem; }
.page-tabs .nav-link { padding: .5rem .75rem; white-space: nowrap; }
.page-tabs .nav-link { color: var(--bs-secondary-color); font-weight: 500; background: transparent;
  border: 1px solid transparent; margin-bottom: -1px; }
.page-tabs .nav-link:hover { color: var(--bs-body-color); background: var(--bs-secondary-bg); border-color: transparent; }
.page-tabs .nav-link.active { color: var(--bs-body-color); background: var(--bs-body-bg);
  border-color: var(--bs-border-color) var(--bs-border-color) var(--bs-body-bg); box-shadow: inset 0 3px 0 var(--aion-yellow); }
.page-tabs .nav-link .badge { font-weight: 500; }
.page-tab-content { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
  border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) var(--bs-border-radius); padding: 1rem 1.25rem; }
.page-tab-content .tab-pane { overflow-x: auto; }
.page-tab-content table { margin-bottom: 0; }
.page-tab-content table + form, .page-tab-content table + .actions { margin-top: 1rem; }
/* Short values stay on one line; the long ArgoCD path is the column that wraps (anywhere, it has no spaces). */
#environments td { white-space: nowrap; }
#environments td:nth-child(3), #environments td:nth-child(3) code { white-space: normal; overflow-wrap: anywhere; }
.page-tab-content > :first-child { margin-top: 0; }
.tab-intro { color: var(--bs-secondary-color); font-size: .875rem; margin-bottom: .75rem; }
.tab-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }

/* ---- Dashboard tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.stat { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow-sm); padding: 1rem 1.25rem; text-decoration: none; font-size: .85rem; color: var(--bs-secondary-color); }
a.stat:hover { border-color: var(--aion-orange); }
.stat strong { display: block; font-size: 1.6rem; color: var(--bs-body-color); }
/* A large, faint icon in the bottom-right corner of each tile, behind the text: identifies the tile at a glance. */
.stat { position: relative; overflow: hidden; }
.stat-icon { position: absolute; right: -.35rem; bottom: -.7rem; font-size: 4.25rem; line-height: 1; opacity: .09;
  color: var(--bs-body-color); pointer-events: none; transition: opacity .15s, transform .15s; }
a.stat:hover .stat-icon { opacity: .18; color: var(--aion-orange); transform: rotate(-6deg); }

/* ---- Callouts: AdminLTE's .callout / .callout-<variant>, spaced like the other blocks ---- */
.callout { margin-bottom: 1rem; border-radius: var(--bs-border-radius); }

/* ---- Anonymous pages (login): labels span the card so inputs fill it ---- */
.login-card-body label { display: block; width: 100%; }
.login-card-body label input { width: 100%; }
