/* ==========================================================================
   POSMAX BRAND LAYER
   --------------------------------------------------------------------------
   The look of this installation. Loaded AFTER pos-ui.css on every page.

   pos-ui.css is the platform's design system. It owns layout, components,
   states and the dark theme. This file only re-points that system's tokens
   at the POSMAX palette and adds the few things that are POSMAX's own: the
   navy rail and the navy brand band. It is a separate file so that fixes to
   pos-ui.css from the upstream platform merge without conflicts. Brand
   decisions go here, not there.

   Every colour pair below gives its WCAG contrast ratio, measured, not
   estimated. Body text needs 4.5:1, large text and icons 3:1.

   Sections
     01  Palette
     02  Tokens: POSMAX as the default theme
     03  Tokens: dark mode
     04  The "Ocean" preset, kept selectable
     05  Brand band (top of the sidebar)
     06  Navy rail (sidebar skin, the default)
     07  Accent details
     08  Footer credit
     09  Sign-in shell
   ========================================================================== */


/* ==========================================================================
   01  PALETTE
   --------------------------------------------------------------------------
   Two inks, sampled from the logo artwork (tools/brand-assets.php):
   navy #101D43 and green #72BF44. The ramps around them are for UI states.

   White text on #72BF44 is only 2.27:1, so the logo green is NEVER a fill
   behind white text. It works as an accent: rail markers, active tiles, and
   fills with navy text (7.23:1). Where green has to carry white text or be
   read as text, the darker steps below are used instead.
   ========================================================================== */

:root {
  --pmx-navy-950: #0A1330;
  --pmx-navy-900: #101D43;   /* logo navy */
  --pmx-navy-800: #172656;
  --pmx-navy-700: #1D2F6F;   /* interactive navy: white on it 12.44:1 */
  --pmx-navy-100: #DDE3F2;
  --pmx-navy-50:  #EDF0F8;   /* navy-700 on it 10.91:1 */

  --pmx-green-500: #72BF44;  /* logo green: accent only, see above */
  --pmx-green-600: #5EA932;
  --pmx-green-800: #357A1A;  /* white on it 5.32:1 - success fills */
  --pmx-green-850: #2F6F17;  /* on white 6.16:1 - money */
  --pmx-green-50:  #F0F8EA;

  /* Rail ink, measured on navy-900. */
  --pmx-rail-label: #8E9AC0; /* 5.89:1 */
  --pmx-rail-link:  #C5CDE6; /* 10.36:1 */
  --pmx-rail-icon:  #AEB8D6; /* 7.03:1 on its .06 tile */
}


/* ==========================================================================
   02  TOKENS: POSMAX AS THE DEFAULT THEME
   --------------------------------------------------------------------------
   Plain :root, so it takes over from pos-ui.css's own :root defaults. The
   other presets (Emerald, Indigo, Slate) use :root[data-pos-theme=...] and
   are more specific, so they still win when someone picks them in
   Appearance. That is the behaviour wanted.
   ========================================================================== */

:root {
  --pos-primary: var(--pmx-navy-700);
  --pos-primary-hover: var(--pmx-navy-900);  /* hover deepens to the logo navy */
  --pos-primary-soft: var(--pmx-navy-50);
  --pos-primary-rgb: 29, 47, 111;

  --pos-success: var(--pmx-green-800);
  --pos-success-soft: var(--pmx-green-50);

  /* Money in the brand's green, a step darker than success so a price never
     reads as a status: 6.16:1 on white, 5.89:1 on the alt surface. */
  --pos-price: var(--pmx-green-850);

  --pos-text-primary: #0F1A33;               /* navy-leaning ink, 17.4:1 */
  --pos-page-bg: #F4F6FA;

  /* Bootstrap bridge: the rgb triplets cannot be derived from a hex var. */
  --bs-primary-rgb: 29, 47, 111;
  --bs-success: var(--pmx-green-800);
  --bs-success-rgb: 53, 122, 26;
  --bs-body-color-rgb: 15, 26, 51;
}

::selection { background: rgba(114, 191, 68, .28); }


/* ==========================================================================
   03  TOKENS: DARK MODE
   --------------------------------------------------------------------------
   pos-ui.css's dark block sets a blue primary with the same specificity as
   this rule. This file loads later, so these values win.
   #4A6AD6 carries white button text at 4.86:1. Navy itself would be
   invisible on the dark surfaces.
   ========================================================================== */

:root[data-theme="dark"] {
  --pos-primary: #4A6AD6;
  --pos-primary-hover: #6E8BEB;              /* 5.54:1 on the dark card */
  --pos-primary-soft: rgba(74, 106, 214, .18);
  --pos-primary-rgb: 74, 106, 214;

  --pos-success: #8FD06A;                    /* 9.63:1 on the dark card */
  --pos-success-soft: rgba(114, 191, 68, .16);
  --pos-price: #8FD06A;

  --bs-primary-rgb: 74, 106, 214;
  --bs-success: #8FD06A;
  --bs-success-rgb: 143, 208, 106;
}


/* ==========================================================================
   04  THE "OCEAN" PRESET, KEPT SELECTABLE
   --------------------------------------------------------------------------
   Ocean was the platform default and had no rule of its own: it was just
   pos-ui.css's :root. Section 02 replaces that :root, so Ocean gets its own
   rule here, or picking it in Appearance would quietly show POSMAX instead.
   ========================================================================== */

:root[data-pos-theme="ocean"] {
  --pos-primary: #2563EB;
  --pos-primary-hover: #1D4ED8;
  --pos-primary-soft: #EFF6FF;
  --pos-primary-rgb: 37, 99, 235;
  --bs-primary-rgb: 37, 99, 235;
}


/* ==========================================================================
   05  BRAND BAND (top of the sidebar)
   --------------------------------------------------------------------------
   pos-ui.css section 34 paints the band white, because the platform's logo
   was drawn for light backgrounds. POSMAX has a reversed lockup (white +
   green), so the band is navy on every skin and in dark mode. It lines up
   with the 62px top header and reads as the product's signature.
   ========================================================================== */

.sidebar-header,
:root[data-theme="dark"] .sidebar-header {
  background: var(--pmx-navy-900) !important;
  border-bottom: 1px solid rgba(255, 255, 255, .08) !important;
  padding: 12px 14px 12px 18px !important;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-logo { justify-content: flex-start !important; }
.sidebar-brand-img--full { max-height: 30px; }
body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 12px 6px !important; }
body.sidebar-collapsed .sidebar-brand-img--mark { max-height: 30px; }

/* A ghost button on the navy band. pos-ui.css draws it white with a light
   border, which reads as a hole punched in the band. */
.sidebar-collapse-btn {
  background: transparent !important;
  border-color: rgba(255, 255, 255, .16) !important;
  color: var(--pmx-rail-icon) !important;
}
.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus-visible {
  background: rgba(255, 255, 255, .08) !important;
  color: #FFFFFF !important;
}


/* ==========================================================================
   06  NAVY RAIL (sidebar skin, the default)
   --------------------------------------------------------------------------
   Chosen in Appearance -> Sidebar -> Navy, and the default in pos-ui.js.
   Every selector is scoped to the skin, so White, Soft and Tint look
   exactly as pos-ui.css draws them.

   States, all measured on navy-900:
     label     #8E9AC0          5.89:1
     link      #C5CDE6         10.36:1
     hover     white on .06    13.90:1
     active    white on .08    13.13:1, with the icon tile in logo green
               holding a navy glyph (7.23:1) and a green rail marker
     sub open  green on .12     5.96:1
   ========================================================================== */

:root[data-pos-sidebar="navy"] {
  --pos-sidebar-bg: var(--pmx-navy-900);
  --pos-sidebar-border: var(--pmx-navy-900);
  --pos-sidebar-link: var(--pmx-rail-link);
}
:root[data-theme="dark"][data-pos-sidebar="navy"] {
  --pos-sidebar-bg: #0C1633;                 /* a step under the band, link 11.25:1 */
  --pos-sidebar-border: rgba(255, 255, 255, .06);
}

:root[data-pos-sidebar="navy"] .sidebar {
  background: linear-gradient(180deg, var(--pos-sidebar-bg) 0%, var(--pmx-navy-950) 100%) !important;
}

:root[data-pos-sidebar="navy"] .nav-label { color: var(--pmx-rail-label) !important; }

/* The template separates menu groups with a near-white rule (#F3F5F9). On
   navy that is the brightest line on the screen, so it is dimmed to a hairline. */
:root[data-pos-sidebar="navy"] .nav-group { border-color: rgba(255, 255, 255, .08) !important; }

:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link i.icon,
:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link .icon {
  background: rgba(255, 255, 255, .06);
  color: var(--pmx-rail-icon) !important;
}

:root[data-pos-sidebar="navy"] .sidebar .nav-sidebar .nav-link:hover,
:root[data-pos-sidebar="navy"] .sidebar .nav-sidebar .nav-link:focus {
  background: rgba(255, 255, 255, .06) !important;
  color: #FFFFFF !important;
}
:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link:hover i.icon {
  background: rgba(114, 191, 68, .18);
  color: var(--pmx-green-500) !important;
}

:root[data-pos-sidebar="navy"] .sidebar .nav-sidebar .nav-link.active {
  background: rgba(255, 255, 255, .08) !important;
  color: #FFFFFF !important;
}
:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link.active i.icon {
  background: var(--pmx-green-500);
  color: var(--pmx-navy-900) !important;
}
:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link.active::before {
  background: var(--pmx-green-500);
}

:root[data-pos-sidebar="navy"] .nav-sidebar .nav-link.has-sub::after { color: var(--pmx-rail-label); }

:root[data-pos-sidebar="navy"] .nav-sub::before { background: rgba(255, 255, 255, .10); }
:root[data-pos-sidebar="navy"] .nav-sub-link,
:root[data-pos-sidebar="navy"] .nav-sub .nav-sub-link.dropdown-item {
  color: var(--pmx-rail-icon) !important;
}
:root[data-pos-sidebar="navy"] .nav-sub-link:hover,
:root[data-pos-sidebar="navy"] .nav-sub .nav-sub-link.dropdown-item:hover {
  background: rgba(255, 255, 255, .06) !important;
  color: #FFFFFF !important;
}
:root[data-pos-sidebar="navy"] .nav-sub-link.active,
:root[data-pos-sidebar="navy"] .nav-sub .nav-sub-link.dropdown-item.active {
  background: rgba(114, 191, 68, .12) !important;
  color: var(--pmx-green-500) !important;
}

:root[data-pos-sidebar="navy"] .sidebar-footer {
  background: transparent !important;
  border-top-color: rgba(255, 255, 255, .08);
}
:root[data-pos-sidebar="navy"] .sidebar-footer-body h6 a,
:root[data-pos-sidebar="navy"] .sidebar-footer-body .h6 a { color: #FFFFFF !important; }

/* Scrollbar on the dark rail: the light thumb from pos-ui.css vanishes. */
:root[data-pos-sidebar="navy"] .sidebar * { scrollbar-color: rgba(255, 255, 255, .18) transparent; }
:root[data-pos-sidebar="navy"] .sidebar ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .18);
  background-clip: content-box;
}

/* Keyboard focus has to show on navy too: a green ring, not the navy one. */
:root[data-pos-sidebar="navy"] .sidebar a:focus-visible,
:root[data-pos-sidebar="navy"] .sidebar button:focus-visible {
  outline: 2px solid var(--pmx-green-500);
  outline-offset: -2px;
}


/* ==========================================================================
   07  ACCENT DETAILS
   --------------------------------------------------------------------------
   A small amount of the logo green, kept to places where it marks "this one":
   the theme swatch, the active segmented control. The green stays scarce on
   purpose. Used everywhere, it would stop meaning anything.
   ========================================================================== */

/* A green call-to-action, for the rare button that must outrank primary.
   Navy text on the logo green, 7.23:1. */
.btn-pmx-accent {
  background: var(--pmx-green-500) !important;
  border-color: var(--pmx-green-500) !important;
  color: var(--pmx-navy-900) !important;
  font-weight: 700 !important;
}
.btn-pmx-accent:hover,
.btn-pmx-accent:focus-visible {
  background: var(--pmx-green-600) !important;
  border-color: var(--pmx-green-600) !important;
  color: var(--pmx-navy-950) !important;
}

/* The template decorates a text logo with a coloured dot after it. The
   POSMAX logo is artwork with its own mark, so the dot is removed. */
.header-logo::after { content: none !important; }

/* File inputs ("Choose File" on every logo and image upload). The template
   sets the button's text to cream #F2DABD on #F3F5F9, about 1.2:1, so the
   button reads as blank. Navy-700 on navy-50 is 10.91:1. */
.form-control::file-selector-button {
  background: var(--pos-primary-soft) !important;
  color: var(--pos-primary) !important;
  font-weight: 600;
}
.form-control:hover:not(:disabled):not([readonly])::file-selector-button {
  background: rgba(var(--pos-primary-rgb), .14) !important;
  color: var(--pos-primary-hover) !important;
}

/* Appearance panel: the selected swatch rings in green so it is clear which
   one is on, whatever the swatch colour is. */
.pos-theme-swatches .pos-swatch.active {
  box-shadow: 0 0 0 2px var(--pos-surface), 0 0 0 4px var(--pmx-green-500) !important;
}


/* ==========================================================================
   08  FOOTER CREDIT
   --------------------------------------------------------------------------
   The credit line is a requirement, not decoration. pos-ui.css sets the
   footer in the muted tone, which is 2.39:1 on the page and too faint to
   read, so it is raised to the secondary text colour (7.2:1).
   ========================================================================== */

.main-footer,
.main-footer span { color: var(--pos-text-secondary); }

/* Mark and words on one line. An upstream footer rule makes every span in
   the footer display:block, which stacked the mark above the text. */
.main-footer .pmx-credit {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}
.main-footer .pmx-credit > span { display: inline !important; }
.pmx-credit img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}


/* ==========================================================================
   09  SIGN-IN SHELL
   --------------------------------------------------------------------------
   The brand panel used to be a blue gradient with the logo on a white plate.
   With the reversed POSMAX lockup it no longer needs a plate. The panel is
   the logo navy with one soft green glow and the "X" chevron as a large
   watermark, so the screen is recognisably POSMAX before anyone reads it.
   Shared by login.php (its own markup) and sign.css pages (the company
   chooser and the password screens).
   ========================================================================== */

.sign-brand {
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(114, 191, 68, .16), transparent 62%),
    radial-gradient(700px 480px at 0% 100%, rgba(255, 255, 255, .05), transparent 60%),
    linear-gradient(160deg, var(--pmx-navy-800) 0%, var(--pmx-navy-900) 55%, var(--pmx-navy-950) 100%) !important;
}
/* The mark as a watermark, bottom right, replacing the plain circle. */
.sign-brand::after {
  right: -60px !important;
  bottom: -40px !important;
  width: 420px !important;
  height: 420px !important;
  border-radius: 0 !important;
  background: url("../img/brand/posmax-mark-reverse.png") center / contain no-repeat !important;
  opacity: .07;
  pointer-events: none;
}

.sign-brand__logo {
  display: block;
  height: 46px;
  width: auto;
  max-width: min(300px, 40vw);
}
/* Short panels (1366x768 and most POS screens): the shells tighten their copy
   at this height, so the logo steps down with it. */
@media (max-height: 760px) { .sign-brand__logo { height: 38px; } }
.sign-brand__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(114, 191, 68, .14);
  border: 1px solid rgba(114, 191, 68, .35);
  color: var(--pmx-green-500);                /* 7.23:1 on navy */
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sign-brand__body p { color: #C9D1EA !important; }       /* 10.78:1 */
.sign-points i {
  background: rgba(114, 191, 68, .16) !important;
  color: var(--pmx-green-500);
}
.sign-brand__foot { color: var(--pmx-rail-label) !important; }  /* 5.89:1 */
.sign-brand__foot strong { color: #FFFFFF; font-weight: 600; }

/* Form side: the client's name above the form, so the screen says whose
   till this is. */
.sign-client {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  padding: 10px 12px;
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-md);
  background: var(--pos-surface-alt);
}
.sign-client__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--pmx-navy-900);
  color: var(--pmx-green-500);
  font-size: 18px;
}
.sign-client__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--pos-text-primary);
  line-height: 1.2;
}
.sign-client__sub {
  font-size: 12px;
  color: var(--pos-text-secondary);
}

/* The foot carries the credit line, so it is set in the secondary colour
   (7.2:1 on white), not the muted one (2.56:1). */
.sign-foot { color: var(--pos-text-secondary) !important; text-align: center; }
.sign-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--pos-text-secondary);
}
.sign-credit img { width: 16px; height: 16px; object-fit: contain; }

/* The form-top logo only repeats the brand panel's, so it shows only where
   the panel is hidden. The two shells hide the panel at different widths:
   login.php's own styles at 900px, sign.css at 991px. These match each one. */
@media (min-width: 901px) { body:not(.sign-body) .sign-form__logo { display: none; } }
@media (min-width: 992px) { body.sign-body .sign-form__logo { display: none; } }
