/*
 * App-level overrides, loaded after every theme stylesheet (plan/04-conventions.md: never edit the
 * theme files; scope overrides by component and use the theme tokens).
 */

/* The React sidebar scrolls natively instead of through SimpleBar (which rewrites the DOM React owns).
   Same look as the theme: scrollable, scrollbar hidden. */
#sidebar .sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
#sidebar .sidebar-scroll::-webkit-scrollbar {
  display: none;
}

/* ── Date / time / range picker (react-datepicker) in the theme's tokens ─────────────────────────
   Skin and light/dark switch through the --sk-* variables on <body>, so nothing here is mode-specific. */
body .react-datepicker-wrapper {
  display: block;
  width: 100%;
}
body .react-datepicker__input-container {
  position: relative;
}
/* Input: a plain Bootstrap .form-control (the theme's own padding, height and radius) with the
   calendar / clock icon overlaid on the left. */
body .jrp-dp-field {
  position: relative;
}
body .jrp-dp-field .react-datepicker__input-container input.form-control {
  padding-left: 2.75rem;
}
body .jrp-dp-icon {
  position: absolute;
  top: 50%;
  left: 0.875rem;
  z-index: 2;
  display: inline-flex;
  transform: translateY(-50%);
  color: var(--sk-muted-foreground, #6c757d);
  pointer-events: none;
}
body .jrp-dp-field:focus-within .jrp-dp-icon {
  color: var(--sk-primary, #0067ff);
}
body .react-datepicker__close-icon {
  right: 0.25rem;
}
body .react-datepicker__close-icon::after {
  background: transparent;
  color: var(--sk-muted-foreground, #6c757d);
  font-size: 1.125rem;
}

/* Popup */
body .react-datepicker-popper {
  z-index: 1080;
  padding-top: 0.375rem;
}
body .react-datepicker {
  /* month | time list */
  display: grid;
  grid-template-columns: auto auto;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--sk-body-text, #495057);
  background: var(--sk-surface, #fff);
  border: 1px solid var(--sk-border, #e5e7eb);
  border-radius: 0.875rem;
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.04),
    0 12px 32px rgb(0 0 0 / 0.14);
  overflow: hidden;
}
body .react-datepicker__month-container {
  float: none;
  grid-column: 1;
  grid-row: 1;
  padding: 0.75rem 0.75rem 0.5rem;
}
body .react-datepicker__header {
  padding: 0;
  background: transparent;
  border: 0;
}
body .react-datepicker__day-names {
  display: flex;
  justify-content: space-between;
  margin: 0.5rem 0 0.125rem;
}
body .react-datepicker__day-name {
  width: 2.25rem;
  margin: 0;
  line-height: 2rem;
  color: var(--sk-muted-foreground, #6c757d);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
body .react-datepicker__month {
  margin: 0;
}
body .react-datepicker__week {
  display: flex;
  justify-content: space-between;
}

/* Header: ‹  Month  Year  › */
body .jrp-dp-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
body .jrp-dp-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--sk-muted-foreground, #6c757d);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
body .jrp-dp-nav:hover:not(:disabled) {
  color: var(--sk-primary, #0067ff);
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.1);
}
body .jrp-dp-nav:disabled {
  opacity: 0.35;
  cursor: default;
}
body .jrp-dp-select {
  flex: 1 1 auto;
  min-width: 0;
  height: 2rem;
  padding: 0 1.5rem 0 0.625rem;
  color: var(--sk-foreground, #212529);
  font: inherit;
  font-weight: 600;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  border: 0;
  border-radius: var(--sk-radius-inset, 0.5rem);
  cursor: pointer;
  appearance: none;
}
body .jrp-dp-select:last-of-type {
  flex-basis: 5.5rem;
}
body .jrp-dp-select:hover,
body .jrp-dp-select:focus-visible {
  background-color: rgb(var(--sk-primary-rgb, 0 103 255) / 0.08);
  outline: 0;
}
body .jrp-dp-select option {
  color: #212529;
  background: #fff;
}

/* Days: round cells */
body .react-datepicker__day {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0.125rem 0;
  line-height: 2.25rem;
  color: var(--sk-body-text, #495057);
  border-radius: 50%;
  transition:
    background-color 0.12s ease,
    color 0.12s ease;
}
body .react-datepicker__day:hover,
body .react-datepicker__month-text:hover,
body .react-datepicker__year-text:hover {
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.12);
  border-radius: 50%;
}
body .react-datepicker__day--today {
  font-weight: 700;
  color: var(--sk-primary, #0067ff);
  box-shadow: inset 0 0 0 1.5px rgb(var(--sk-primary-rgb, 0 103 255) / 0.45);
}
body .react-datepicker__day--selected,
body .react-datepicker__day--range-start,
body .react-datepicker__day--range-end,
body .react-datepicker__day--selecting-range-start,
body .react-datepicker__day--selecting-range-end,
body .react-datepicker__day--keyboard-selected {
  background: var(--sk-primary, #0067ff);
  color: var(--sk-primary-foreground, #fff);
  font-weight: 600;
  box-shadow: none;
}
body .react-datepicker__day--keyboard-selected:not(.react-datepicker__day--selected):not(.react-datepicker__day--range-start):not(.react-datepicker__day--range-end) {
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.16);
  color: var(--sk-body-text, #495057);
}
/* Range: a continuous band between the two round ends */
body .react-datepicker__day--in-range:not(.react-datepicker__day--range-start):not(.react-datepicker__day--range-end),
body .react-datepicker__day--in-selecting-range:not(.react-datepicker__day--selecting-range-start) {
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.14);
  color: var(--sk-body-text, #495057);
  border-radius: 0;
}
body .react-datepicker__day--range-start:not(.react-datepicker__day--range-end) {
  border-radius: 50% 0 0 50%;
}
body .react-datepicker__day--range-end:not(.react-datepicker__day--range-start) {
  border-radius: 0 50% 50% 0;
}
body .react-datepicker__day--selected:hover,
body .react-datepicker__day--range-start:hover,
body .react-datepicker__day--range-end:hover {
  background: var(--sk-primary-hover, var(--sk-primary, #0067ff));
}
body .react-datepicker__day--disabled,
body .react-datepicker__day--outside-month {
  color: var(--sk-muted-foreground, #6c757d);
  opacity: 0.5;
}
body .react-datepicker__day--disabled:hover {
  background: transparent;
}

/* Time list */
body .react-datepicker__time-container {
  float: none;
  grid-column: 2;
  grid-row: 1;
  width: 6.5rem;
  border-left: 1px solid var(--sk-border, #e5e7eb);
}
body .react-datepicker__header--time {
  padding: 0.75rem 0.5rem 0.5rem;
  background: transparent;
  border-bottom: 0;
}
body .react-datepicker-time__header {
  color: var(--sk-foreground, #212529);
  font-weight: 600;
  font-size: 0.875rem;
}
body .react-datepicker__time-container .react-datepicker__time {
  background: transparent;
}
/* The list scrolls inside the popup instead of stretching it (one calendar tall) */
body .react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list {
  height: 15rem !important;
  overflow-y: auto;
}
body .react-datepicker__time-container .react-datepicker__time-box {
  width: 100%;
}
body .react-datepicker__time-container .react-datepicker__time-list {
  padding: 0 0.375rem 0.375rem;
}
body .react-datepicker__time-container .react-datepicker__time-list-item {
  height: auto;
  margin: 0.125rem 0;
  padding: 0.4rem 0.5rem;
  color: var(--sk-body-text, #495057);
  border-radius: var(--sk-radius-inset, 0.5rem);
}
body .react-datepicker__time-container .react-datepicker__time-list-item:hover {
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.12);
}
body .react-datepicker__time-container .react-datepicker__time-list-item--selected {
  background: var(--sk-primary, #0067ff);
  color: var(--sk-primary-foreground, #fff);
  font-weight: 600;
}
/* Time-only picker: the list is the whole popup */
body .react-datepicker--time-only {
  grid-template-columns: auto;
}
body .react-datepicker--time-only .react-datepicker__time-container {
  grid-column: 1;
  grid-row: 1;
  width: 8rem;
  border-left: 0;
}
body .react-datepicker__input-container input:focus {
  border-color: var(--sk-primary, #0067ff);
  box-shadow: 0 0 0 0.2rem rgb(var(--sk-ring-rgb, 0 103 255) / 0.2);
}

/* ── Select (react-select, rendered unstyled; classes are `jrp-select__*`) ───────────────────── */
/* Same box as the theme's .form-control: height, border, radius, font and text colour.
   `body` outranks react-select's own base min-height (38px), which is injected later. */
body .jrp-select__control {
  display: flex;
  align-items: center;
  min-height: 41.6px; /* = the theme's .form-control (10px padding + 1.4 line + 2px border) */
  padding: 0 0.375rem 0 0.5rem;
  color: var(--sk-foreground, #212529);
  font-size: 0.875rem;
  background: var(--sk-surface, #fff);
  border: 1px solid var(--sk-border, #ced4da);
  border-radius: var(--sk-radius-card, 6px);
  cursor: pointer;
}
.jrp-select__control:hover {
  border-color: var(--sk-primary, #0067ff);
}
.jrp-select__control--is-focused {
  border-color: var(--sk-primary, #0067ff);
  box-shadow: 0 0 0 0.2rem rgb(var(--sk-ring-rgb, 0 103 255) / 0.2);
}
.jrp-select__value-container {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem 0.25rem;
}
.jrp-select__single-value {
  color: var(--sk-foreground, #212529);
}
.jrp-select__placeholder {
  color: var(--sk-muted-foreground, #6c757d);
}
.jrp-select__input-container {
  color: var(--sk-foreground, #212529);
}
.jrp-select__indicators {
  display: flex;
  align-items: center;
}
.jrp-select__indicator {
  padding: 0.25rem 0.4rem;
  color: var(--sk-muted-foreground, #6c757d);
}
.jrp-select__indicator:hover {
  color: var(--sk-primary, #0067ff);
}
.jrp-select__indicator-separator {
  display: none;
}
.jrp-select__menu {
  z-index: 1080;
  margin-top: 0.25rem;
  overflow: hidden;
  background: var(--sk-surface, #fff);
  border: 1px solid var(--sk-border, #e5e7eb);
  border-radius: var(--sk-radius-card, 0.625rem);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.14);
}
.jrp-select__menu-list {
  max-height: 16rem;
  padding: 0.25rem;
  overflow-y: auto;
}
.jrp-select__group-heading {
  padding: 0.5rem 0.75rem 0.25rem;
  color: var(--sk-muted-foreground, #6c757d);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.jrp-select__option {
  padding: 0.4rem 0.75rem;
  color: var(--sk-body-text, #495057);
  border-radius: var(--sk-radius-inset, 0.375rem);
  cursor: pointer;
}
.jrp-select__option--is-focused {
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.12);
}
.jrp-select__option--is-selected {
  background: var(--sk-primary, #0067ff);
  color: var(--sk-primary-foreground, #fff);
}
.jrp-select__no-options-message {
  padding: 0.75rem;
  color: var(--sk-muted-foreground, #6c757d);
  text-align: center;
}
.jrp-select__multi-value {
  display: flex;
  align-items: center;
  background: rgb(var(--sk-primary-rgb, 0 103 255) / 0.12);
  color: var(--sk-primary, #0067ff);
  border-radius: var(--sk-radius-inset, 0.375rem);
}
.jrp-select__multi-value__label {
  padding: 0.125rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
}
.jrp-select__multi-value__remove {
  padding: 0 0.35rem;
  align-self: stretch;
  display: flex;
  align-items: center;
  border-radius: 0 var(--sk-radius-inset, 0.375rem) var(--sk-radius-inset, 0.375rem) 0;
  cursor: pointer;
}
.jrp-select__multi-value__remove:hover {
  background: var(--sk-primary, #0067ff);
  color: var(--sk-primary-foreground, #fff);
}

/* ── Dark mode: carry the sidebar brand's divider across the header ───────────────────────────────
   The brand has a 1px rgba(255 255 255 / 0.1) line under it; the header, in the same colour, had none,
   so the line stopped at the sidebar edge. An inset shadow draws it in the same row (y = 55) without
   changing the header's height. The theme sets this shadow with !important (admin.css, `body[data-skin]
   .navbar.navbar-bg`), so this rule is more specific and !important too. */
body[data-skin][data-theme="dark"] nav.navbar.navbar-bg {
  box-shadow:
    inset 0 -1px 0 rgb(255 255 255 / 0.1),
    0 4px 40px rgba(39, 32, 120, 0.1) !important;
}

/* ── Dark mode: vertical divider where the sidebar ends ───────────────────────────────────────────
   The brand row has the header's colour, so below the header the sidebar edge shows only as a colour
   change and, next to the brand, not at all. A 1px inset line on the sidebar's right edge (same
   rgba(255 255 255 / 0.1) as the brand's bottom line) closes the brand cell. The inset shadow does not
   change the width; the theme's own outer glow is kept. */
body[data-skin][data-theme="dark"] #sidebar {
  box-shadow:
    inset -1px 0 0 rgb(255 255 255 / 0.1),
    0 0 21px 0 rgba(89, 102, 122, 0.1) !important;
}

/* Dark mode: the brand cell is separated from the header by the same 1px line (right edge, y 0–56),
   so the brand's bottom divider and this one frame it. Inset shadow = no layout change. */
body[data-skin][data-theme="dark"] #sidebar .sidebar-brand-new {
  box-shadow: inset -1px 0 0 rgb(255 255 255 / 0.1);
}

/* ── Text size (header A− / A+) ──────────────────────────────────────────────────────────────────
   --jrp-text-scale is set on <html> by lib/theme/preferences.ts (and before paint by head-boot.js).
   rem-based text follows the root font-size; the theme's px font sizes are multiplied by the same
   variable in theme-text-scale.css (generated, scripts/gen-text-scale.mjs). */
html {
  font-size: calc(100% * var(--jrp-text-scale, 1));
}

/* Header text-size dropdown. The toggle uses fixed px on purpose: it must not grow with the text it controls. */
body .text-size-toggle {
  min-width: 32px;
  height: 32px;
  padding: 0 4px !important;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  line-height: 32px;
  font-weight: 700;
}
body .text-size-glyph-small {
  font-size: 17px;
}
body .text-size-glyph-large {
  font-size: 12px;
}
body .text-size-panel {
  min-width: 200px;
}
body .text-size-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
