/*
 * Custom application styles. PulseDAQ color palette and Tailwind are in
 * app/assets/tailwind/application.css (built as "tailwind" stylesheet).
 */

@import url("https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/css/tom-select.bootstrap5.min.css");

:root {
  --pd-main: var(--pulsedaq-main, #5b2cff);
  --pd-secondary: var(--pulsedaq-secondary, #7b61ff);
  --pd-main-light: var(--pulsedaq-main-light, #efe9ff);
}

/*
 * Tom Select’s bootstrap5 skin uses Bootstrap 5 variables (--bs-body-bg, etc.). Tabler
 * does not define them, so those backgrounds were invalid and the open dropdown looked
 * translucent over the rest of the form. Scope the missing variables to Tom Select only.
 */
.ts-wrapper {
  --bs-body-bg: #ffffff;
  --bs-body-color: #1f2937;
  --bs-border-color: #dee2e6;
  --bs-border-color-translucent: rgba(0, 0, 0, 0.175);
  --bs-border-radius: 0.375rem;
  --bs-border-radius-lg: 0.5rem;
  --bs-border-radius-sm: 0.25rem;
  --bs-border-width: 1px;
  --bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
  --bs-secondary-bg: #e9ecef;
  --bs-tertiary-bg: #f3f4f6;
  --bs-form-valid-color: #198754;
  --bs-form-invalid-color: #dc3545;
}

.ts-wrapper .ts-dropdown {
  z-index: 1050;
}

/* Onboarding sector Tom Select: match body text scale (1rem); form-select-lg was too large. */
.onboarding-category-path-select.ts-wrapper,
.onboarding-category-path-select.ts-wrapper .ts-control,
.onboarding-category-path-select.ts-wrapper .ts-control input,
.onboarding-category-path-select.ts-wrapper .ts-dropdown {
  font-size: 1rem;
}

.onboarding-category-path-select.ts-wrapper .ts-dropdown .optgroup-header {
  font-size: 1.125rem;
  font-weight: 600;
}

.pd-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.pd-main-offset {
  margin-top: 4rem;
}

.pd-auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--pd-main-light), #ffffff, var(--pd-main-light));
}

.pd-auth-card-wrap {
  max-width: 28rem;
}

.pd-navbar {
  background: #fff;
  min-height: 4rem;
  border-bottom: 1px solid #e6e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.pd-logo {
  height: 2.5rem;
  width: auto;
}

.pd-footer {
  background: #fff;
  border-top: 1px solid #e6e7eb;
}

.pd-footer-logo {
  height: 6rem;
  width: auto;
}

.pd-footer-form-wrap {
  border: 1px solid #e8ddff;
  background: #fbf9ff;
}

.pd-btn-primary {
  color: #fff;
  border: 0;
  background: linear-gradient(to right, var(--pd-main), var(--pd-secondary));
}

.pd-btn-primary:hover,
.pd-btn-primary:focus {
  color: #fff;
  opacity: 0.95;
}

.pd-link {
  color: var(--pd-main);
}

.pd-link:hover,
.pd-link:focus {
  color: var(--pd-secondary);
}

.pd-bg-main {
  background: var(--pd-main);
}

.pd-text-main {
  color: var(--pd-main);
}

.pd-btn-accent {
  color: #fff;
  border: 0;
  background: var(--pd-main);
}

.pd-btn-accent:hover,
.pd-btn-accent:focus {
  color: #fff;
  background: var(--pd-secondary);
}

.pd-lock-icon {
  width: 4rem;
  height: auto;
}

.pd-report-card-interactive {
  transition: all 0.2s ease;
}

.pd-report-card-interactive:hover,
.pd-report-card-interactive:focus-within {
  background: #faf7ff;
  box-shadow: 0 1rem 2.5rem rgba(17, 24, 39, 0.2);
  border-color: #c9b0ff;
}

.pd-link-underline-hover:hover,
.pd-link-underline-hover:focus {
  text-decoration: underline;
}

.pd-report-link-hover {
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.pd-report-link-hover:hover,
.pd-report-link-hover:focus {
  color: var(--pd-main) !important;
  text-decoration: underline !important;
  text-underline-offset: 2px;
}

.pd-report-card-menu {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
}

.pd-report-card-menu-trigger {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  cursor: pointer;
  color: #4b5563;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.pd-report-card-menu-panel {
  position: absolute;
  right: 0;
  margin-top: 0.25rem;
  width: 14rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  background: #fff;
  padding: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.14);
}

.pd-hover-bg-light:hover,
.pd-hover-bg-light:focus {
  background: #f3f4f6 !important;
}

.pd-report-card-image,
.pd-report-card .report-card-placeholder {
  height: 180px;
  width: 100%;
  object-fit: cover;
  object-position: top;
}

.pd-report-card .report-card-placeholder {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
  background: #f8f9fa;
}

.pd-report-card.pd-missing-image .pd-report-card-image {
  display: none !important;
}

.pd-report-card.pd-missing-image .report-card-placeholder {
  display: flex !important;
}

.pd-insight-icon {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
}

.cursor-pointer {
  cursor: pointer;
}

/* Report TOC (off-canvas + contents): native <details> for expand/collapse. */
.report-toc-details > summary,
.report-toc-email-group > summary {
  list-style: none;
}

.report-toc-details > summary::-webkit-details-marker,
.report-toc-email-group > summary::-webkit-details-marker {
  display: none;
}

.report-toc-details > summary,
.report-toc-email-group > summary {
  position: relative;
  padding-right: 2rem;
  cursor: pointer;
}

.report-toc-details > summary::after,
.report-toc-email-group > summary::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.55;
}

.report-toc-details[open] > summary::after,
.report-toc-email-group[open] > summary::after {
  transform: translateY(-50%) rotate(-135deg);
}

.report-toc-contents-root {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pd-report-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 4rem);
}

.pd-report-sidebar {
  flex: 0 0 20rem;
  width: 20rem;
  margin-left: calc(50% - 50vw);
  background: #fff;
  border-right: 1px solid #e6e7eb;
}

.pd-report-sidebar-inner {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 4rem);
  overflow: auto;
}

.pd-report-main {
  flex: 1 1 auto;
  min-width: 0;
}

.pd-report-content {
  flex: 1 1 auto;
  min-width: 0;
}

.report-toc-section-body {
  margin-top: 0.25rem;
}

@media (max-width: 991.98px) {
  .pd-report-shell {
    display: block;
    min-height: auto;
  }

  .pd-report-sidebar {
    width: 100%;
    flex: 0 0 auto;
    margin-left: 0;
    border-right: 0;
    border-bottom: 1px solid #e6e7eb;
  }

  .pd-report-sidebar-inner {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Tabler-style page-loader overlay (used on onboarding processing page). */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  transition: opacity 250ms ease, transform 250ms ease;
}

.page-loader-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

/* Top colour gradient bar (reports; keep in sync with report_pdf.css) */
.pd-top-colour-bar {
  /* Match ColourGradientBar::EDGE_PCT / 100 */
  --pd-tcb-edge-fr: 0.08;
  /* Same white as Bootstrap/Tailwind .bg-white (Tabler --tblr-white); used in ColourGradientBar edge stops */
  --pd-tcb-edge-bg: var(--tblr-white, #ffffff);
  --pd-tcb-track-h: 2.3rem;
  --pd-tcb-marker: 0.625rem;
  max-width: 14rem;
  width: 100%;
}

.pd-top-colour-bar-compare .pd-top-colour-bar {
  max-width: none;
}

.pd-top-colour-bar__label {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
}

/* Track + markers: thick bar, modest radius; dots straddle bottom edge, evenly placed by gradient index */
.pd-top-colour-bar__stack {
  width: 100%;
  padding-bottom: calc(var(--pd-tcb-marker) / 2 + 0.25rem);
}

.pd-top-colour-bar__track {
  position: relative;
  overflow: visible;
  height: var(--pd-tcb-track-h);
  border-radius: 0.375rem;
  border: none;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.1);
}

.pd-top-colour-bar__markers {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.pd-top-colour-bar__marker {
  position: absolute;
  bottom: 0;
  width: var(--pd-tcb-marker);
  height: var(--pd-tcb-marker);
  border-radius: 50%;
  border: 1px solid #fff;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  box-sizing: content-box;
  transform: translate(-50%, 50%);
}

/* Centres align with palette stops inside ColourGradientBar edge band (same math as Ruby) */
.pd-top-colour-bar__marker:not(.pd-top-colour-bar__marker--solo) {
  left: calc(
    (var(--pd-tcb-edge-fr) + (1 - 2 * var(--pd-tcb-edge-fr)) * var(--pd-tcb-i) / var(--pd-tcb-denom)) * 100%
  );
}

.pd-top-colour-bar__marker--solo {
  left: 50%;
}

.pd-top-colour-bar__empty {
  color: #6b7280;
}

.pd-top-colour-bar-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.pd-top-colour-bar-compare__col {
  min-width: 0;
}
