/*
 * Bambuddy look for the Zammad portal.
 *
 * Linked into every page by the edge nginx (sub_filter in helpdesk.bambuddy.cool.conf),
 *   so the Zammad containers stay stock and an update stays a version bump. Zammad
 *   draws its colours from CSS variables, with a second set under [data-theme='dark'];
 *   most of this file only redefines those. The few rules that target markup are the
 *   ones a Zammad update can break, and if it does, the page falls back to the stock
 *   look rather than breaking. Check the portal in both themes after every update.
 *
 * Styles only: Zammad's content security policy allows a stylesheet from its own host
 *   but no script without its per-request nonce.
 */

/* Green marks what you act on and what is selected; the surfaces stay neutral:
   white and light grey in light mode, near-black in dark mode. */
:root {
  /* The app's green (frontend tailwind `bambu.green`), and a darker step for white
     text on it: #00ae42 under white text is below 3:1. */
  --bb-green: #00ae42;
  --bb-green-strong: #008a35;
  --bb-green-stronger: #00722c;
  --bb-green-text: #007a30;
  --bb-green-tint: #e3f5ea;
  --bb-green-ring: #9ad9b1;

  --button-primary-background: var(--bb-green-strong);
  --button-primary-background-active: var(--bb-green-stronger);
  --text-link: var(--bb-green-text);
  --text-nav: var(--bb-green-text);
  --highlight: var(--bb-green);
  --border-highlight: var(--bb-green);
  --background-highlight: var(--bb-green-tint);
  --shadow-highlight: var(--bb-green-ring);
  --text-muted-highlight: var(--bb-green-tint);
  /* The selected overview was black in light mode, next to a blue sidebar entry. */
  --background-active: var(--bb-green-strong);
  --backdrop-clue-start: hsla(143, 100%, 34%, 0.1);
  --backdrop-clue-end: hsla(143, 100%, 34%, 0.9);

  --background-primary: hsl(0, 0%, 98%);
  --background-primary-alt: hsl(0, 0%, 94%);
  --background-article-customer: hsl(0, 0%, 95%);
  --background-article-customer-meta: hsl(0, 0%, 97%);
  --border-article-customer: hsl(0, 0%, 88%);
  --border-article-customer-selected: hsl(0, 0%, 80%);

  /* The login page sat on the dark sidebar colour in light mode too. */
  --fullscreen-background: hsl(0, 0%, 95%);
  --fullscreen-text-link: var(--header-primary);
}

/* Light mode: Zammad keeps its sidebar dark in both themes. Redefined on the sidebar
   only, because the same variables colour other parts of the page. */
:root:not([data-theme='dark']) .navigation {
  --menu-background-primary: white;
  --menu-background-secondary: hsl(0, 0%, 96%);
  --menu-background-primary-hover: hsla(0, 0%, 0%, 0.04);
  --menu-background-active: var(--bb-green-tint);
  --menu-text: hsl(0, 0%, 30%);
  --menu-text-active: hsl(0, 0%, 8%);
  --menu-icon: hsl(0, 0%, 45%);
  --menu-icon-secondary: hsl(0, 0%, 50%);
  --menu-icon-secondary-hover-background: hsl(0, 0%, 20%);
  --menu-close-tab-background: hsl(0, 0%, 82%);
  --nav-icon: hsl(0, 0%, 45%);
}
:root:not([data-theme='dark']) .navigation { border-right: 1px solid hsl(0, 0%, 89%); }
:root:not([data-theme='dark']) .navigation .search { border-bottom-color: hsl(0, 0%, 91%); }

[data-theme='dark'] {
  --bb-green-text: #3fd47a;
  --bb-green-tint: hsl(145, 35%, 20%);
  --bb-green-ring: hsl(145, 45%, 30%);

  --text-link: var(--bb-green-text);
  /* Text buttons ("Stay on tab") are drawn in the button colour, too dark here. */
  --text-button-primary: var(--bb-green-text);
  --text-button-primary-active: #6ee39c;
  --text-nav: hsl(0, 0%, 86%);
  --background-active: var(--bb-green-strong);
  --menu-background-active: hsla(0, 0%, 100%, 0.1);

  --background-primary: hsl(0, 0%, 9%);
  --background-primary-alt: hsl(0, 0%, 11%);
  --background-secondary: hsl(0, 0%, 13%);
  --background-secondary-hover: hsl(0, 0%, 10%);
  --background-tertiary: hsl(0, 0%, 6%);
  --background-quaternary: hsl(0, 0%, 3%);
  --background-quaternary-alt: hsl(0, 0%, 22%);
  --background-popover: hsl(0, 0%, 18%);
  --background-article-meta: hsl(0, 0%, 14%);
  --background-article-customer: hsl(0, 0%, 17%);
  --background-article-customer-meta: hsl(0, 0%, 15%);
  --border-article-customer: hsl(0, 0%, 22%);
  --border-article-customer-selected: hsl(0, 0%, 30%);
  --border: hsl(0, 0%, 16%);
  --border-alt: hsl(0, 0%, 17%);
  --fullscreen-background: hsl(0, 0%, 4%);
  --fullscreen-text-link: white;
}

/* ---- Logo: the app's mark in the sidebar, the full logo on the login page ---- */

.navigation .search .logo > svg { visibility: hidden; }
.navigation .search .logo {
  background: url("/bambuddy-theme/bambuddy-mark.png") center / 30px 30px no-repeat;
}

.login .company-logo {
  content: url("/bambuddy-theme/bambuddy-logo.png");
  max-width: 280px;
  max-height: none;
  width: 100%;
  margin: 8px auto 34px;
}

/* ---- "New case": the one action a customer comes for, not a bare + ----
 *
 * A customer's bar holds two items (avatar, +), which leaves room for a label. An
 * agent's also has reports and admin, and there the + stays a green square: the
 * label would be cut off. "Exactly two items" is written as first-child plus
 * nth-last-child(2), which needs no :has(). */

.user-menu li.add .list-button::before,
.user-menu li.add:hover .list-button::before,
.user-menu li.add.is-active .list-button::before {
  content: '';
  position: absolute;
  inset: 10px 6px;
  border-radius: 8px;
  background: var(--bb-green-strong);
}
.user-menu li.add:hover .list-button::before,
.user-menu li.add.is-active .list-button::before {
  background: var(--bb-green-stronger);
}
.user-menu li.add .list-button { color: white; }
.user-menu li.add .list-button svg { fill: white; color: white; }

.user-menu > li:first-child:nth-last-child(2) ~ li.add { flex: 2; }
.user-menu > li:first-child:nth-last-child(2) ~ li.add .list-button { gap: 6px; }
.user-menu > li:first-child:nth-last-child(2) ~ li.add .list-button::before {
  inset: 10px 12px 10px 4px;
}
.user-menu > li:first-child:nth-last-child(2) ~ li.add .list-button::after {
  content: 'New case';
  position: relative;
  font-weight: 600;
  white-space: nowrap;
}

/* A collapsed sidebar, and phones, stack the bar into a narrow column: no label. */
#app.navigation-collapsed .user-menu li.add .list-button::after { content: none; }
#app.navigation-collapsed .user-menu li.add .list-button::before { inset: 10px 6px; }
@media screen and (max-width: 767px) {
  .user-menu li.add .list-button::after { content: none !important; }
  .user-menu li.add .list-button::before { inset: 10px 6px !important; }
}

/* ---- Lists: calmer rows, titles read as text rather than a column of links ---- */

.table-overview .table > tbody > tr > td { padding-top: 11px; padding-bottom: 11px; }
.table-overview .table > tbody > tr > td a { color: var(--header-primary); }
.table-overview .table > tbody > tr:hover > td a { color: var(--text-link); }
.table-overview .table > thead > tr > th { letter-spacing: 0.04em; }

.btn--primary, .btn.btn--primary { font-weight: 600; }

/* Zammad's own green for "Create", brought in line with the rest. */
.btn--positive, .btn--create, .btn--success {
  background: var(--bb-green-strong);
  font-weight: 600;
}
.btn--positive:active, .btn--create:active, .btn--success:active {
  background: var(--bb-green-stronger);
}
.btn--positive.btn--secondary, .btn--create.btn--secondary, .btn--success.btn--secondary {
  background: var(--background-secondary);
  color: var(--bb-green-text);
}

.form-control:focus, .form-control.focus {
  border-color: var(--bb-green);
  box-shadow: 0 0 0 3px var(--shadow-highlight);
}
