/* ==========================================================================
   thewave Container Manager – skin for the Portainer CE UI (Portainer 2.39.x)
   --------------------------------------------------------------------------
   Modification notice: written by Ensur in 2026 to restyle the Portainer
   Community Edition web UI (Copyright (c) 2018 Portainer.io, zlib License).
   Portainer's image, code and files are unchanged; its license and notices
   are in third-party-licenses/portainer/, and every change is listed in
   third-party-licenses/portainer/MODIFICATIONS.md.
   --------------------------------------------------------------------------
   One stylesheet, linked last in <head> by the index.html that
   portainer/skin/apply-skin.sh writes (mounted over /public/index.html),
   together with container-manager.js. Portainer's accent colors are
   hard-coded in its Tailwind and Bootstrap rules, not variables: the script
   recolors those rules (blue → the portal's green), so this file only does
   what a palette cannot.

   What it changes
     - Primary buttons: Portainer's graphite (light) and mist (dark) become
       the portal's green
     - Fonts: Inter becomes the portal's system stack
     - Sidebar: white like the portal's in the light theme (Portainer's
       graphite stays in the dark one), the selected item green-tinted, a
       "thewave Container Manager" wordmark instead of the PORTAINER.IO logo,
       the wave tile when collapsed
     - Sign-in and loading pages: the "thewave / CONTAINER MANAGER" lockup of
       the Authentik, Gitea and Object Store sign-in pages, on their
       green-tinted gradient, in a card; "Login with OAuth" (Authentik, Caddy
       mode) is the green primary and "Use internal authentication" the
       secondary
     - Docker, Docker Compose and Kubernetes logos: green instead of blue
       (inline SVG here, <img> in container-manager.js)
     - Hidden: the "Upgrade to Business Edition" banner and the "New version
       available" box in the sidebar (Portainer's version is pinned and
       upgraded by the platform), and the "Latest News From Portainer"
       panel on the home page
   Portainer's high-contrast theme keeps its own colors (green in place of
   its accent would cost contrast); the wordmark, lockup and fonts apply in
   every theme. Left as they are: the "© Portainer Community Edition
   <version>" line and the "About Portainer" dialog in the sidebar footer,
   the "Get Help" link, Business Edition feature hints in forms, and the
   status colors (green running, red stopped, …).

   Selectors
     The theme is the theme attribute Portainer sets on <html> (dark,
     highcontrast; light is the attribute "light" or none). Components are
     matched by their CSS-module class names (app-react-sidebar-…-module__…,
     derived from the source path, stable across builds), Portainer's own
     classes (simple-box, motd-body, btn-primary, …) and data-cy test ids.
     Re-check them after a Portainer bump.

   Specificity
     Portainer's theme rules are `.x:is([theme=dark] *)` (two classes).
     Every rule here starts with a :root theme scope, which puts it above
     them without !important.
   ========================================================================== */


/* --------------------------------------------------------------------------
   0. Brand constants
   -------------------------------------------------------------------------- */
:root {
  --edp-brand-name: "thewave";
  --edp-product-name: "Container Manager";
  --edp-product-tag: "CONTAINER MANAGER";

  --edp-font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";

  /* Greens and grays of the portal (Nuxt UI / Tailwind v4) */
  --edp-green-50: #f0fdf4;
  --edp-green-100: #dcfce7;
  --edp-green-200: #b9f8cf;
  --edp-green-300: #7bf1a8;
  --edp-green-400: #05df72;
  --edp-green-500: #00c950;
  --edp-green-600: #00a63e;
  --edp-green-700: #008236;
  --edp-green-800: #016630;
  --edp-green-900: #0d542b;
  --edp-green-950: #032e15;

  --edp-gray-50: #f9fafb;
  --edp-gray-100: #f3f4f6;
  --edp-gray-200: #e5e7eb;
  --edp-gray-300: #d1d5dc;
  --edp-gray-400: #99a1af;
  --edp-gray-500: #6a7282;
  --edp-gray-600: #4a5565;
  --edp-gray-700: #364153;
  --edp-gray-800: #1e2939;
  --edp-gray-900: #101828;
  --edp-gray-950: #030712;
}


/* --------------------------------------------------------------------------
   1. Theme tokens
   Light: Portainer's own light theme (no theme attribute, or "light").
   Filled buttons keep a white label, so their green is green-700 (4.9:1);
   on the dark surfaces the fill is green-500 with a near-black label
   (9.5:1), as in the Code Repository's dark theme.
   -------------------------------------------------------------------------- */
:root:not([theme="dark"], [theme="highcontrast"]) {
  --edp-primary: var(--edp-green-700);
  --edp-primary-hover: var(--edp-green-800);
  --edp-primary-active: var(--edp-green-900);
  --edp-primary-ink: #ffffff;
  --edp-focus: rgb(0 166 62 / 35%);

  --edp-side-bg: #ffffff;
  --edp-side-edge: var(--edp-gray-200);
  --edp-side-ink: var(--edp-gray-900);
  --edp-side-text: var(--edp-gray-700);
  --edp-side-label: var(--edp-gray-500);
  --edp-side-muted: var(--edp-gray-400);
  --edp-side-hover-bg: var(--edp-gray-100);
  --edp-side-box-bg: var(--edp-gray-50);
  --edp-side-box-edge: var(--edp-gray-200);
  --edp-side-selected-bg: var(--edp-green-50);
  --edp-side-selected-ink: var(--edp-green-700);
  --edp-side-thumb: var(--edp-gray-300);

  --edp-page-from: #ffffff;
  --edp-page-to: var(--edp-gray-50);
  --edp-glow-1: rgb(0 166 62 / 10%);
  --edp-glow-2: rgb(5 223 114 / 8%);
  --edp-card-bg: #ffffff;
  --edp-card-border: var(--edp-gray-200);
  --edp-card-shadow-1: rgb(16 24 40 / 6%);
  --edp-card-shadow-2: rgb(16 24 40 / 8%);
  --edp-lockup-ink: var(--edp-gray-900);
  --edp-lockup-tag: var(--edp-green-700);

  /* Portainer's sidebar tokens (module CSS reads them) */
  --bg-sidebar-color: var(--edp-side-bg);
  --bg-sidebar-nav-color: var(--edp-side-box-bg);
  --graphite-500: var(--edp-gray-200);
}

:root[theme="dark"] {
  --edp-primary: var(--edp-green-500);
  --edp-primary-hover: var(--edp-green-400);
  --edp-primary-active: var(--edp-green-300);
  --edp-primary-ink: var(--edp-gray-950);
  --edp-focus: rgb(5 223 114 / 35%);

  --edp-side-ink: #ffffff;
  --edp-side-text: #f2f4f7;
  --edp-side-label: #98a2b3;
  --edp-side-muted: #98a2b3;
  --edp-side-selected-bg: rgb(5 223 114 / 12%);
  --edp-side-selected-ink: var(--edp-green-400);

  --edp-page-from: #121212;
  --edp-page-to: #181818;
  --edp-glow-1: rgb(0 166 62 / 16%);
  --edp-glow-2: rgb(5 223 114 / 7%);
  --edp-card-bg: #212121;
  --edp-card-border: #383838;
  --edp-card-shadow-1: rgb(0 0 0 / 30%);
  --edp-card-shadow-2: rgb(0 0 0 / 35%);
  --edp-lockup-ink: #ffffff;
  --edp-lockup-tag: var(--edp-green-400);
}

:root[theme="highcontrast"] {
  --edp-lockup-ink: #ffffff;
  --edp-lockup-tag: #ffffff;
}


/* --------------------------------------------------------------------------
   2. Typography
   Portainer sets Inter on body and on select (WebKit); Bootstrap's inputs
   and buttons inherit.
   -------------------------------------------------------------------------- */
:root body,
:root select {
  font-family: var(--edp-font-sans);
}

::selection {
  background: rgb(0 166 62 / 25%);
}


/* --------------------------------------------------------------------------
   3. Links in the dark themes
   Portainer's links are its blue-8 in every theme; recolored they are
   green-700, too dark on the dark surfaces. Here green-400, the portal's
   dark-mode primary. :where() keeps the specificity of Portainer's own
   `a, a.hyperlink` rule, so Tailwind's text-* utilities still win.
   -------------------------------------------------------------------------- */
:where(:root[theme="dark"], :root[theme="highcontrast"]) a,
:where(:root[theme="dark"], :root[theme="highcontrast"]) a.hyperlink {
  color: var(--edp-green-400);
}

:where(:root[theme="dark"], :root[theme="highcontrast"]) a:hover,
:where(:root[theme="dark"], :root[theme="highcontrast"]) a.hyperlink:hover {
  color: var(--edp-green-300);
}


/* --------------------------------------------------------------------------
   4. Primary buttons
   Portainer 2.39's primary is graphite on mist (light) and mist on graphite
   (dark). Its focus border is recolored by container-manager.js.
   -------------------------------------------------------------------------- */
:root:not([theme="highcontrast"]) .btn.btn-primary,
:root:not([theme="highcontrast"]) .btn.btn-primary:focus {
  border-color: var(--edp-primary);
  background-color: var(--edp-primary);
  color: var(--edp-primary-ink);
}

:root:not([theme="highcontrast"]) .btn.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--edp-focus);
}

:root:not([theme="highcontrast"]) .btn.btn-primary:hover {
  border-color: var(--edp-primary-hover);
  background-color: var(--edp-primary-hover);
  color: var(--edp-primary-ink);
}

:root:not([theme="highcontrast"]) .btn.btn-primary:active,
:root:not([theme="highcontrast"]) .btn.btn-primary.active,
:root:not([theme="highcontrast"]) .open > .dropdown-toggle.btn-primary {
  border-color: var(--edp-primary-active);
  background-color: var(--edp-primary-active);
  color: var(--edp-primary-ink);
}

/* Disabled: Bootstrap fades the button; keep the green, not the hover */
:root:not([theme="highcontrast"]) .btn.btn-primary:is([disabled], .disabled):hover {
  border-color: var(--edp-primary);
  background-color: var(--edp-primary);
}


/* --------------------------------------------------------------------------
   5. Sidebar – surfaces and items
   Portainer's sidebar is graphite in every theme; in the light theme it is
   white with a gray-200 rule, as the portal's. Items carry Tailwind classes
   for a dark sidebar (text-gray-3, text-white, hover:bg-graphite-500); the
   selected item is the one with a plain bg-graphite-500.
   -------------------------------------------------------------------------- */
:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__nav {
  border-right: 1px solid var(--edp-side-edge);
}

:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root :is(.text-gray-3, .text-white) {
  color: var(--edp-side-text);
}

:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root .hover\:bg-graphite-500:hover {
  background-color: var(--edp-side-hover-bg);
  color: var(--edp-side-ink);
}

/* Section labels ("Administration", "Environment: …") */
:root:not([theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root li.ml-3 {
  color: var(--edp-side-label);
  font-weight: 500;
}

:root:not([theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root li.ml-3 .text-gray-6 {
  color: var(--edp-side-muted);
}

/* The selected environment's name */
:root:not([theme="highcontrast"]) .app-react-sidebar-EnvironmentSidebar-module__root li.ml-3 span.text-white {
  color: var(--edp-side-ink);
  font-weight: 600;
}

/* Selected item: the link, or the row of a group (Settings, Logs, …) whose
   page is open */
:root:not([theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root .bg-graphite-500,
:root:not([theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root .bg-graphite-500:hover {
  background-color: var(--edp-side-selected-bg);
  color: var(--edp-side-selected-ink);
  font-weight: 600;
}

/* The box of the selected environment */
:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-EnvironmentSidebar-module__root {
  border: 1px solid var(--edp-side-box-edge);
}

:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-EnvironmentSidebar-module__closeBtn {
  color: var(--edp-side-label);
}

/* Collapse / expand toggle */
:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root button.bg-graphite-900 {
  background-color: var(--edp-gray-100);
  color: var(--edp-gray-500);
}

:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__root button.bg-graphite-900:hover {
  background-color: var(--edp-gray-200);
  color: var(--edp-gray-900);
}

:root:not([theme="dark"], [theme="highcontrast"]) .app-react-sidebar-Sidebar-module__nav-list-container::-webkit-scrollbar-thumb {
  background-color: var(--edp-side-thumb) !important;
}

/* Footer: "© Portainer Community Edition <version>" stays, in gray */
:root:not([theme="highcontrast"]) .app-react-sidebar-Footer-Footer-module__root .text-gray-5 {
  color: var(--edp-side-muted);
}

/* Business Edition banner (first child of the sidebar) and the "New
   version available" box: Portainer's version is pinned by the platform. */
:root .app-react-sidebar-Sidebar-module__root > button:first-child:not(:only-child),
:root .app-react-sidebar-Footer-UpdateNotifications-module__root {
  display: none;
}


/* --------------------------------------------------------------------------
   6. Sidebar – wordmark
   The portal's top-bar "thewave Data Portal" style: "thewave" in italics,
   then the product name, semibold. Portainer's logo is an <img> (a data:
   SVG) in the home link; it goes, the text takes its place.
   -------------------------------------------------------------------------- */
:root a[data-cy="portainerSidebar-homeImage"] {
  display: flex;
  align-items: baseline;
  gap: 0.28em;
  min-height: 34px;
  padding-top: 2px;
  font-family: var(--edp-font-sans);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--edp-side-ink, #ffffff);
}

:root a[data-cy="portainerSidebar-homeImage"]:is(:hover, :focus) {
  color: var(--edp-side-selected-ink, #ffffff);
}

:root a[data-cy="portainerSidebar-homeImage"] > img {
  display: none;
}

:root a[data-cy="portainerSidebar-homeImage"]::before {
  content: var(--edp-brand-name);
  font-style: italic;
  font-weight: 700;
}

:root a[data-cy="portainerSidebar-homeImage"]::after {
  content: var(--edp-product-name);
}

/* Collapsed sidebar: only the wave tile */
:root #page-wrapper:not(.open) a[data-cy="portainerSidebar-homeImage"] {
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border-radius: 7px;
  background: url("favicon.svg") center / contain no-repeat;
  font-size: 0;
}

:root #page-wrapper:not(.open) a[data-cy="portainerSidebar-homeImage"]::before,
:root #page-wrapper:not(.open) a[data-cy="portainerSidebar-homeImage"]::after {
  content: none;
}


/* --------------------------------------------------------------------------
   7. Sign-in page and loading screen
   Both are a .simple-box: a logo row (Portainer's light and dark logo
   <img>s) and, on the sign-in page, a panel with the form. The logo row
   becomes the lockup of the other sign-in pages; the page gets their
   green-tinted gradient and the panel their card.
   -------------------------------------------------------------------------- */
:root:not([theme="highcontrast"]) body:has(.simple-box) {
  background:
    radial-gradient(80rem 42rem at 16% -14%, var(--edp-glow-1), transparent 62%),
    radial-gradient(62rem 38rem at 104% 6%, var(--edp-glow-2), transparent 58%),
    linear-gradient(168deg, var(--edp-page-from) 0%, var(--edp-page-to) 100%)
    fixed;
}

:root:not([theme="highcontrast"]) body:has(.simple-box) :is(#page-wrapper, #content-wrapper, .page-content, .page-wrapper) {
  background: transparent;
}

:root .simple-box .row:has(img.simple-box-logo) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.5rem;
}

:root .simple-box .row:has(img.simple-box-logo) img.simple-box-logo,
:root .simple-box .row:has(img.simple-box-logo) > div {
  display: none !important;
}

:root .simple-box .row:has(img.simple-box-logo)::before {
  content: var(--edp-brand-name);
  display: block;
  font-family: var(--edp-font-sans);
  font-size: 2.6rem;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--edp-lockup-ink, #2e2f33);
}

:root .simple-box .row:has(img.simple-box-logo)::after {
  content: var(--edp-product-tag);
  display: block;
  padding-left: 0.32em;
  font-family: var(--edp-font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--edp-lockup-tag, #2e2f33);
}

/* "Log in to your account / Welcome back! …" */
:root .simple-box .row.p-5.text-center {
  padding-top: 1rem !important;
  padding-bottom: 1.25rem !important;
}

:root .simple-box .row.p-5.text-center .text-xl {
  margin-bottom: 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
}

/* The form's first group holds the OAuth button; without OAuth it is an
   empty box above the username */
:root .simple-box .simple-box-form > .form-group:first-child:not(:has(*)) {
  display: none;
}

/* The card */
:root:not([theme="highcontrast"]) .simple-box .panel {
  border: 1px solid var(--edp-card-border);
  border-radius: 14px;
  background: var(--edp-card-bg);
  box-shadow:
    0 1px 2px var(--edp-card-shadow-1),
    0 12px 32px -8px var(--edp-card-shadow-2);
}

:root:not([theme="highcontrast"]) .simple-box .panel > .panel-body {
  padding: 1.75rem 1.75rem 1.25rem;
  border-radius: 14px;
  background: transparent;
}

:root .simple-box .simple-box-form .pb-2 {
  font-weight: 500;
}

:root .simple-box .simple-box-form .form-control {
  border-radius: 8px;
}

:root .simple-box .simple-box-form .btn-lg {
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
}

/* With OAuth (Authentik, Caddy mode): "Login with OAuth" becomes a
   full-width "Sign in with SSO", the label of the Object Store's button;
   "Use internal authentication" (the local admin, break-glass) turns into
   an outlined secondary under the "or" rule. */
:root .simple-box .simple-box-form a[ng-href] {
  flex: 1;
  text-decoration: none;
}

:root .simple-box .simple-box-form a[ng-href] > .btn[ng-if$="'OAuth'"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0;
}

:root .simple-box .simple-box-form a[ng-href] > .btn[ng-if$="'OAuth'"] svg {
  width: 1.1rem;
  height: 1.1rem;
}

:root .simple-box .simple-box-form a[ng-href] > .btn[ng-if$="'OAuth'"]::after {
  content: "Sign in with SSO";
  font-size: 1rem;
}

:root:not([theme="highcontrast"]) .simple-box .btn.btn-primary[ng-click="ctrl.toggleStandardLogin()"] {
  border-color: var(--edp-card-border);
  background: transparent;
  color: inherit;
  font-weight: 500;
}

:root:not([theme="highcontrast"]) .simple-box .btn.btn-primary[ng-click="ctrl.toggleStandardLogin()"]:hover {
  border-color: var(--edp-gray-400);
  background: rgb(127 127 127 / 8%);
  color: inherit;
}

/* Loading screen (index.html): the lockup above "Loading Container
   Manager…" */
:root .page-wrapper > .simple-box.container {
  padding-top: clamp(2rem, 14vh, 8rem);
}


/* --------------------------------------------------------------------------
   8. Dashboard tiles
   The counts next to a tile ("8 running", "9 stopped", "82.7 GB") inherit
   the tile link's color; in green "9 stopped" would read as good news.
   They become neutral; their icons keep Portainer's status colors.
   -------------------------------------------------------------------------- */
:root:not([theme="dark"], [theme="highcontrast"]) a[data-cy$="-link"] > div > .flex > .ml-auto {
  color: var(--edp-gray-600);
}

:root:is([theme="dark"], [theme="highcontrast"]) a[data-cy$="-link"] > div > .flex > .ml-auto {
  color: var(--edp-gray-300);
}


/* --------------------------------------------------------------------------
   9. Home page
   "Latest News From Portainer" (Portainer's message of the day, fetched
   from portainer.io) is product marketing of Portainer, out of place in the
   platform.
   -------------------------------------------------------------------------- */
:root .row:has(> .col-sm-12 > .widget > .motd-body) {
  display: none;
}


/* --------------------------------------------------------------------------
   10. Platform logos
   The Docker, Docker Compose and Kubernetes logos Portainer renders as
   inline <svg> (environment lists, stack and environment forms) carry
   their blue as a fill attribute, which any rule overrides; the same logos
   as <img> are recolored by container-manager.js (same colors, every
   theme). Other vendors' logos keep their colors.
   -------------------------------------------------------------------------- */
:root svg [fill="#0091E2" i],
:root svg [fill="#326CE4" i],
:root svg [fill="#326DE6" i] {
  fill: var(--edp-green-600);
}

:root svg [fill="#72CCFA" i] {
  fill: var(--edp-green-300);
}

:root svg [fill="#29B4FA" i] {
  fill: var(--edp-green-500);
}

:root svg [fill="#0F5983" i] {
  fill: var(--edp-green-800);
}

:root svg [fill="#05446D" i] {
  fill: var(--edp-green-900);
}
