/* --- Form-overlay (left-side drawer) -------------------------------- */
/* Anchored to the LEFT edge of the viewport; animates by width so the
 * panel slides in from the left. Two width states:
 *   • split  (~50vw) — PDF row scoots to the right half so both
 *                      surfaces are visible at once
 *   • full   (100vw) — form fully covers the screen
 * Z-index sits at 1030, deliberately BELOW the Assistant panel (1040)
 * so the Assistant always wins overlap when both are open. */
.ds-form-wrapper {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 1030;
  overflow: hidden;
  transition: width 0.30s ease, box-shadow 0.30s ease;
  box-shadow: none;
  pointer-events: none;
}
.ds-form-wrapper-open-split {
  width: 50vw;
  pointer-events: auto;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
}
.ds-form-wrapper-open-full {
  width: 100vw;
  pointer-events: auto;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
}
.ds-form-wrapper-closed {
  width: 0;
  pointer-events: none;
}
/* When the form is in split mode, scoot the PDF row to the right half
 * so both the form and the PDF are usable at once. Body-class toggle
 * driven by the toggle-form-panel callback below. */
body.ds-form-split .ds-pdf-row {
  width: 50vw;
  left: 75%;
  margin-left: -25vw;
  margin-right: -25vw;
  transition: width 0.30s ease, left 0.30s ease, margin 0.30s ease;
}
.ds-form-panel {
  height: 100%;
  margin: 0;
  border-radius: 0 14px 14px 0;
  /* Match the Assistant's glass aesthetic — translucent white tinted
   * with the parchment palette, strong backdrop blur + saturation,
   * hairline-bright right border catching the highlight. */
  background: rgba(255, 255, 255, 0.24);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-left: none;
  box-shadow:
    12px 0 36px rgba(15, 23, 42, 0.18),
    -1px 0 0 rgba(255, 255, 255, 0.55) inset;
  display: flex;
  flex-direction: column;
}
.ds-form-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.36);
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.0) 100%);
}
.ds-form-panel-ctl {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(180deg, #fcf9f1 0%, #efe6d2 100%);
  color: var(--ds-mahogany-deep);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 1px 0 #fff;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease,
    box-shadow 0.15s ease;
}
.ds-form-panel-ctl:hover {
  background: linear-gradient(180deg, #fffdf6 0%, #f0e6cf 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
}
.ds-form-panel-ctl:active {
  transform: translateY(1px);
}
.ds-form-panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 22px 22px;
}

/* Wheel layout for the page-tab rail — applies unconditionally on
 * the doc page (no body-class gating), so the rolling/scaling
 * behaviour is identical whether the form drawer is open or closed.
 * Force a single vertical column on whatever container dbc.Tabs is
 * actually rendering — covers .ds-page-nav itself AND any inner
 * .nav-tabs descendant. */
.ds-page-nav,
.ds-page-nav .nav-tabs {
  position: relative;       /* offsetParent for the items, so JS can read offsetTop */
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  flex-wrap: nowrap !important;
  gap: 0 !important;
  padding: 0;
  margin: 0;
  border: none;
  transition: transform 0.55s cubic-bezier(0.22, 1.0, 0.36, 1);
  transform-origin: center center;
  will-change: transform;
}
.ds-page-nav .nav-tabs .nav-item {
  display: block;
  width: 100%;
  margin: 0;
  transform-origin: left center;    /* shrink toward the left edge */
  transition: transform 0.5s cubic-bezier(0.22, 1.0, 0.36, 1),
              opacity 0.45s ease;
  will-change: transform, opacity;
}
.ds-page-nav .nav-tabs .nav-link {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  font-size: 1rem;
  padding: 0.55rem 0.95rem;
  margin: 0 !important;
  text-align: left !important;
  direction: ltr !important;        /* override the existing rtl-truncate rule */
  border-radius: 0 !important;      /* flat edges so tabs butt seamlessly */
  transition: background 0.25s ease, color 0.25s ease;
}
/* Only the active tab gets a fill — sits over the PDF as a
 * highlighted plate so its label is unambiguous. */
.ds-page-nav .nav-tabs .nav-link.active {
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--ds-parchment, #f8f5ee);
  color: var(--ds-mahogany-deep, #2a1f0e);
  box-shadow:
    0 14px 30px rgba(15, 23, 42, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

/* Form FABs: two velvet+brass orbs in the lower-left.
 *   • .ds-form-fab-full  — opens the form full-screen
 *   • .ds-form-fab-split — opens the form on the left half, PDF on the right
 * Both share the same orb styling; only their icon, title, and order differ.
 * When either mode is active, the matching FAB gets .ds-form-fab-active for
 * a brighter rim so the user can tell which mode they're in.
 * When the form is in full mode the FABs ride 18px in from the left edge
 * of the panel (which now covers 100vw); in split mode they slide along
 * with the panel boundary so they remain visible. */
.ds-form-fab {
  position: fixed;
  bottom: 22px;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  z-index: 1042;             /* Above the form panel (1030). */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 220, 160, 0.32) 0%, transparent 55%),
    linear-gradient(155deg,
      var(--ds-velvet-light) 0%,
      var(--ds-velvet) 55%,
      var(--ds-mahogany-deep) 100%);
  border: 1px solid rgba(218, 165, 32, 0.6);
  color: #f4e7c8;
  font-size: 1.25rem;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(218, 165, 32, 0.18),
    inset 0 1px 0 rgba(255, 220, 160, 0.35);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.15s ease,
    filter 0.15s ease, bottom 0.3s ease, left 0.3s ease,
    border-color 0.15s ease;
}
.ds-form-fab-full  { left: 22px; }
.ds-form-fab-split { left: 90px; }
.ds-form-fab:hover,
.ds-form-fab:focus {
  filter: brightness(1.08);
  transform: scale(1.04);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(218, 165, 32, 0.36),
    inset 0 1px 0 rgba(255, 220, 160, 0.5);
  outline: none;
}
.ds-form-fab:active {
  transform: scale(0.97);
}
.ds-form-fab.ds-form-fab-active {
  border-color: rgba(255, 220, 160, 0.9);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(255, 220, 160, 0.55),
    inset 0 1px 0 rgba(255, 220, 160, 0.55);
}
/* In split mode the form panel takes the left 50vw; nudge the FABs into
 * the form panel's footprint so they ride along its left edge. */
body.ds-form-split .ds-form-fab-full  { left: 22px; }
body.ds-form-split .ds-form-fab-split { left: 90px; }
@media (max-width: 768px) {
  .ds-form-fab {
    bottom: 18px;
    width: 52px;
    height: 52px;
  }
  .ds-form-fab-full  { left: 18px; }
  .ds-form-fab-split { left: 80px; }
  .ds-form-fab:hover,
  .ds-form-fab:focus { transform: scale(1.05); }
  .ds-form-fab:active { transform: scale(0.97); }
}
.ds-form-fab-icon {
  line-height: 1;
}

/* Mobile: sheet covers more of the screen by default. */
@media (max-width: 640px) {
  .ds-form-wrapper-open {
    height: 62vh;
  }
  .ds-form-panel {
    border-radius: 12px 12px 0 0;
  }
}
/* On phones the nav stacks above the PDF rather than competing for
 * width — the PDF iframe already caps at 60vh on mobile. */
@media (max-width: 768px) {
  .ds-pdf-row { flex-direction: column; }
  .ds-page-nav-wrap {
    flex: 0 0 auto;
    position: static;
    max-height: none;
    width: 100%;
  }
  .ds-page-nav .nav-tabs {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--ds-parchment-shadow);
  }
  .ds-page-nav .nav-tabs .nav-link {
    border-radius: 6px 6px 0 0;
    margin-right: 0;
    margin-bottom: -1px;
  }
}
