/* ========================================
   Admin Accessibility Normalization
   Structural rules are scoped under class="admin-normalized" on the page's
   content wrapper and apply to everyone.
   High-contrast visual rules are additionally gated behind the a11y-mode
   class on <html>, toggled by the header accessibility button and applied
   early by includes/admin-a11y-mode.ftl.
   ======================================== */

/* ----------------------------------------
   Always-on. Focus visibility, keyboard support and structural fixes.
   ---------------------------------------- */

.admin-normalized .btn,
.admin-normalized button,
.admin-normalized .btn span,
.admin-normalized button span {
  text-shadow: none;
}

.admin-normalized .btn:focus-visible,
.admin-normalized button:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
}

.admin-normalized input:focus-visible,
.admin-normalized select:focus-visible,
.admin-normalized textarea:focus-visible,
.admin-normalized a:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
}

.admin-normalized .btn-primary-minimalist {
  color: var(--color-tertiary-text);
}

.admin-normalized .btn-primary-minimalist:not([disabled]):focus-visible {
  background-color: var(--color-tertiary);
  color: #fff;
  border-color: var(--color-background);
}

.admin-normalized .btn-secondary-minimalist:not([disabled]):focus-visible {
  background-color: #c9c9c9;
  font-weight: bold;
  border: none;
}

.admin-normalized .lock-state {
  width: 2.8em;
  height: 2.8em;
  line-height: normal;
  font-size: var(--font-size-medium);
}

/* Larger lock id while accessibility mode is on */
html.a11y-mode .admin-normalized .lock-state {
  font-size: var(--font-size-large);
}

.admin-normalized .free,
.admin-normalized .occupied,
.admin-normalized .tdHeight {
  font-size: var(--font-size-small);
}

/* WCAG AA green in both modes (the original 2.88:1 fails even large text) */
.admin-normalized .free {
  color: #15803D;
}

.admin-normalized .sidebarLeft a:focus-visible {
  outline: none;
}

.admin-normalized .sidebarLeft a:focus-visible .lockerSidebarLink {
  background-color: #fff3e0;
  color: var(--color-tertiary);
}

#open-spotlight,
#openAdminHelp {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

#open-spotlight:focus-visible,
#openAdminHelp:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Matches the 24px svg icons of the neighboring header buttons */
#a11yModeToggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 1;
  color: var(--color-medium-dark);
}

/* Pressed state mirrors the accessibility palette it enables */
#a11yModeToggle[aria-pressed="true"] {
  color: #C54500;
}

/* Corner dot badge, a shape cue so the active state does not rely on
   the hue change alone (WCAG 1.4.1) */
#a11yModeToggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #C54500;
  border: 2px solid var(--color-topbarBackground, #fff);
}

#a11yModeToggle:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Tooltip bubble under the accessibility button. Always uses the darker
   orange so the white text stays readable in both modes. */
.a11y-toggle-item {
  position: relative;
}

.a11y-tooltip {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: max-content;
  max-width: 296px;
  padding: 12px;
  border-radius: var(--border-radius-primary);
  background: var(--color-tertiary-accessible);
  color: var(--color-white);
  font-size: var(--font-size-small);
  line-height: normal;
  text-align: left;
  filter: drop-shadow(0 3px 3.5px rgba(30, 41, 59, 0.2));
}

/* Arrow pointing up at the icon */
.a11y-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: solid transparent;
  border-width: 0 10px 12px;
  border-bottom-color: var(--color-tertiary-accessible);
}

.a11y-tooltip-title {
  display: block;
  padding-right: 24px;
}

.a11y-tooltip-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-white);
  cursor: pointer;
}

.a11y-tooltip-close:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 1px;
}

.a11y-tooltip-text {
  margin: 0;
}

.admin-normalized [role="button"][tabindex]:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: 4px;
}

.admin-normalized .ace_editor:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
}

.admin-normalized .modal-header .close,
.admin-normalized .modal-header button[data-bs-dismiss="modal"]:not(.btn-close):not(.btn) {
  color: var(--color-dark);
  text-shadow: none;
  opacity: 1;
  font-size: 1.5rem;
  background: transparent;
  border: 0;
}

.page-title-with-back {
  display: flex;
  align-items: center;
  gap: var(--Spacing-space-100, 1rem);
  margin-bottom: 24px;
}

.page-title-with-back h3 {
  margin: 0;
}

.back-arrow-link {
  color: var(--color-tertiary);
  font-size: var(--font-size-extralarge);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

/* a.back-arrow-link outranks the global a:hover rule that turns links dark */
a.back-arrow-link:hover,
a.back-arrow-link:active {
  color: var(--color-tertiary);
}

.back-arrow-link:hover {
  background-color: rgba(255, 88, 0, 0.08);
}

.back-arrow-link:hover .dsIcon {
  transform: translateX(-2px);
}

/* Pressed state so the arrow reads as a button when clicked */
.back-arrow-link:active {
  background-color: rgba(255, 88, 0, 0.12);
  box-shadow: 0 2px 6px rgba(255, 88, 0, 0.25), inset 0 1px 2px rgba(30, 41, 59, 0.08);
  transform: scale(0.94);
}

.back-arrow-link .dsIcon {
  width: 28px;
  height: 28px;
  transition: transform 0.2s ease;
}

.breadcrumb .dsIconHome {
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
}

.back-arrow-link:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Subtle input borders in normal mode. Accessibility mode strengthens
   them with the gated rules below. input:not([type]) covers inputs with no
   type attribute, which default to text but don't match input[type="text"].
   Token fields draw their border on the .controls.form-control wrapper, not the input. */
.admin-normalized .controls.form-control,
.admin-normalized input:not([type]),
.admin-normalized input[type="text"],
.admin-normalized input[type="email"],
.admin-normalized input[type="number"],
.admin-normalized input[type="password"],
.admin-normalized input[type="search"],
.admin-normalized input[type="tel"],
.admin-normalized input[type="url"],
.admin-normalized input[type="date"],
.admin-normalized input[type="datetime-local"],
.admin-normalized input[type="time"],
.admin-normalized select,
.admin-normalized textarea {
  border: 1px solid var(--color-medium-light);
}

.admin-normalized .btn-primary-minimalist,
.admin-normalized .btn-secondary-minimalist {
  border: 1px solid var(--color-medium-light);
}

.admin-normalized .btn-secondary-minimalist:not([disabled]):hover {
  border: 1px solid var(--color-medium-light);
}

/* ----------------------------------------
   Gated. High-contrast visuals applied only while accessibility mode is on.
   ---------------------------------------- */

/* Header controls (user block, language selector) keep their
   normal-mode typography */
html.a11y-mode .admin-normalized .btn,
html.a11y-mode .admin-normalized button:not(#logoutButton):not(#customLanguageCurrent) {
  font-weight: 700;
}

html.a11y-mode .admin-normalized .btn span,
html.a11y-mode .admin-normalized button:not(#logoutButton):not(#customLanguageCurrent) span {
  font-weight: inherit;
}

/* Keeps anchor nav-links consistent with the bolded button nav-links */
html.a11y-mode .admin-normalized .nav-link {
  font-weight: 700;
}

html.a11y-mode .admin-normalized .btn-primary {
  background-color: #C54500;
  border-color: #C54500;
}

/* The brightness filter from the base hover rule cascades, dimming this to
   roughly #b53f00. White text on it is 5.71:1, comfortably AA. */
html.a11y-mode .admin-normalized .btn-primary:hover,
html.a11y-mode .admin-normalized .btn-primary:focus,
html.a11y-mode .admin-normalized .btn-primary:focus-visible {
  color: var(--color-white);
  background-color: #C54500;
  border-color: #C54500;
  box-shadow: none;
}

html.a11y-mode .admin-normalized .btn-secondary:hover,
html.a11y-mode .admin-normalized .btn-secondary:focus,
html.a11y-mode .admin-normalized .btn-secondary:focus-visible {
  color: var(--color-tertiary);
  background-color: #fff3ec;
  background-image: none;
  border-color: var(--color-tertiary);
  box-shadow: none;
  transform: none;
}

/* Input border contrast. WCAG 1.4.11 Non-text Contrast, 3:1 against white. */
html.a11y-mode .admin-normalized .controls.form-control,
html.a11y-mode .admin-normalized input:not([type]),
html.a11y-mode .admin-normalized input[type="text"],
html.a11y-mode .admin-normalized input[type="email"],
html.a11y-mode .admin-normalized input[type="number"],
html.a11y-mode .admin-normalized input[type="password"],
html.a11y-mode .admin-normalized input[type="search"],
html.a11y-mode .admin-normalized input[type="tel"],
html.a11y-mode .admin-normalized input[type="url"],
html.a11y-mode .admin-normalized input[type="date"],
html.a11y-mode .admin-normalized input[type="datetime-local"],
html.a11y-mode .admin-normalized input[type="time"],
html.a11y-mode .admin-normalized select,
html.a11y-mode .admin-normalized textarea {
  border: 1px solid var(--color-medium-dark);
}

html.a11y-mode .admin-normalized .btn-secondary-minimalist,
html.a11y-mode .admin-normalized .btn-primary-minimalist {
  border: 1px solid var(--color-medium-dark);
}

html.a11y-mode .admin-normalized .btn-secondary-minimalist:not([disabled]):hover {
  border: 1px solid var(--color-medium-dark);
}

/* WCAG AA contrast variants of brand colors */
/* Darker than the brand variants so they also pass on the grey page background */
html.a11y-mode .breadcrumb > .active {
  color: #9A3600;
}

html.a11y-mode .admin-normalized .free {
  color: #166534;
}

html.a11y-mode .admin-normalized .occupied {
  color: #991B1B;
}

html.a11y-mode .admin-normalized .stat-sublabel {
  color: var(--color-dark);
}

html.a11y-mode .admin-normalized .form-label,
html.a11y-mode .admin-normalized label {
  color: #334155;
}

html.a11y-mode .admin-normalized .view-pill.active,
html.a11y-mode .admin-normalized .view-pill:hover {
  color: #C54500;
}

html.a11y-mode .admin-normalized .locker-page .lock-door-open .openDoorBtn {
  background-color: #0E8C63;
  border-color: #0E8C63;
}

html.a11y-mode .back-arrow-link:hover {
  color: #C54500;
}

/* The help modal renders outside the admin-normalized wrapper, so it is targeted directly */
html.a11y-mode #adminHelpModal .admin-help-phone,
html.a11y-mode #adminHelpModal .admin-help-phone:hover {
  color: #C54500;
}

html.a11y-mode #adminHelpModal .admin-help-label {
  color: #334155;
  opacity: 1;
}
