/* ============================================================
   GLOBAL STYLES — WeWeb Project

     1. Custom scrollbar          (global)
     2. Date range picker         .dp__*  (Vue Datepicker)
     3. Radio buttons             .ww-input-radio*
     4. Scrollable table          .table-scroll*
     5. Fullscreen container      .fullscreen

   Sections 3-5 are opt-in: the class is set per element in WeWeb under
   Settings -> Custom CSS class. Sections 1-2 apply everywhere.
   ============================================================ */


/* ============================================================
   1. CUSTOM SCROLLBAR — neutral slate palette
   ============================================================ */

/* Firefox ONLY — wrapped in @supports so Chrome/Edge don't pick it up.
   In Chrome 121+, setting scrollbar-width / scrollbar-color makes it IGNORE
   the ::-webkit-scrollbar rules below and fall back to macOS overlay
   scrollbars, which hide when you're not scrolling. */
@supports (-moz-appearance: none) {
  * {
    scrollbar-width: thin;
    scrollbar-color: #CAD5E2 #F1F5F9;
  }
}

/* Chrome, Edge, Safari — global scrollbar */
*::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 9999px;
}

*::-webkit-scrollbar-thumb {
  background: #CAD5E2;
  border-radius: 9999px;
  border: 2px solid #F1F5F9;
  transition: background 0.2s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

*::-webkit-scrollbar-thumb:active {
  background: #62748E;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}


/* ============================================================
   2. DATE RANGE PICKER (Vue Datepicker - .dp__*)
   ============================================================ */

.dp__menu {
  --dp-background-color: #FFFFFF;
  --dp-text-color: #314158;
  --dp-hover-color: #F1F5F9;
  --dp-hover-text-color: #193CB8;
  --dp-primary-color: #155DFC;
  --dp-primary-text-color: #FFFFFF;
  --dp-secondary-color: #90A1B9;
  --dp-border-color: #E2E8F0;
  --dp-menu-border-color: #E2E8F0;
  --dp-border-color-hover: #8EC5FF;
  --dp-disabled-color: #F8FAFC;
  --dp-icon-color: #62748E;
  --dp-highlight-color: #EFF6FF;
  --dp-font-family: 'Inter', sans-serif;
  --dp-border-radius: 4px;
  --dp-cell-border-radius: 9999px;
  --dp-font-size: 13px;
  --dp-cell-size: 32px;
  --dp-cell-padding: 5px;
  --dp-menu-min-width: 480px;

  border-radius: 4px !important;
  border: 0.8px solid #E2E8F0 !important;
  box-shadow: 0px 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
  font-family: 'Inter', sans-serif !important;
  padding: 0 !important;
}

.dp__arrow_top,
.dp__arrow_bottom {
  display: none !important;
}

/* Month / year header */
.dp__month_year_row {
  padding: 16px 20px 8px !important;
  height: auto !important;
}

.dp__month_year_select {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  color: #1D293D !important;
  height: auto !important;
}

.dp__month_year_select:hover {
  background: #F1F5F9 !important;
  border-radius: 4px !important;
}

/* Month navigation arrows */
.dp__month_year_col_nav .dp__inner_nav {
  color: #62748E !important;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
}

.dp__month_year_col_nav .dp__inner_nav:hover {
  background: #F1F5F9 !important;
}

.dp__icon {
  fill: #62748E !important;
  color: #62748E !important;
  width: 18px;
  height: 18px;
}

/* Weekday header (Mo, Tu, We...) */
.dp__calendar_header {
  padding: 0 !important;
  margin-bottom: 4px;
}

.dp__calendar_header_item {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  font-size: 10px !important;
  line-height: 15px !important;
  letter-spacing: 0.4px !important;
  color: #90A1B9 !important;
  text-transform: none !important;
  height: 15px !important;
  padding: 0 !important;
}

.dp__calendar_header_separator {
  background: transparent !important;
  display: none !important;
}

/* Day cells */
.dp__calendar_item {
  padding: 0 !important;
}

.dp__cell_inner {
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  line-height: 19.5px !important;
  color: #314158 !important;
  border-radius: 9999px !important;
  border: none !important;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  font-weight: 400;
}

.dp__cell_offset {
  color: #CBD5E1 !important;
}

/* Today - circle with light blue border */
.dp__today {
  border: 0.8px solid #8EC5FF !important;
  color: #155DFC !important;
  background: transparent !important;
  font-weight: 400 !important;
}

/* Hover state */
.dp__cell_inner:hover:not(.dp__active_date):not(.dp__range_start):not(.dp__range_end):not(.dp__cell_disabled) {
  background: #F1F5F9 !important;
  color: #193CB8 !important;
  border: none !important;
}

/* Selected date / range start / range end */
.dp__active_date,
.dp__range_start,
.dp__range_end {
  background: #155DFC !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
  border-radius: 9999px !important;
  border: none !important;
}

/* Days between range start and end */
.dp__range_between {
  background: #EFF6FF !important;
  color: #193CB8 !important;
  border-radius: 0 !important;
  border: none !important;
}

/* Range endpoints — pale background half for visual connection */
.dp__range_start {
  position: relative;
}
.dp__range_start::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  background: #EFF6FF;
  z-index: -1;
}

.dp__range_end {
  position: relative;
}
.dp__range_end::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 50%;
  background: #EFF6FF;
  z-index: -1;
}

/* Disabled days */
.dp__cell_disabled {
  color: #CBD5E1 !important;
  cursor: not-allowed !important;
  background: transparent !important;
}

/* Two-month layout (range picker) */
.dp__flex_display {
  gap: 20px;
  padding: 0 20px 16px;
}

.dp__instance_calendar + .dp__instance_calendar {
  border-left: 1px solid #F1F5F9;
  padding-left: 20px;
}

/* Narrow screens (tablet / phone): months stacked one under the other,
   menu never wider than the screen, so it doesn't go off the left edge */
@media (max-width: 767px) {
  .dp__menu {
    --dp-menu-min-width: 0px;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
  }
  .dp__flex_display {
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 16px 12px !important;
  }
  .dp__instance_calendar + .dp__instance_calendar {
    border-left: none !important;
    padding-left: 0 !important;
    border-top: 1px solid #F1F5F9;
    padding-top: 8px;
  }
  .dp__month_year_row {
    padding: 12px 16px 8px !important;
  }
}

/* Footer with Cancel + Done buttons */
.dp__action_row {
  background: rgba(248, 250, 252, 0.7) !important;
  border-top: 0.8px solid #F1F5F9 !important;
  padding: 12px 20px !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dp__selection_preview {
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  line-height: 19.5px !important;
  color: #62748E !important;
  font-weight: 400 !important;
}

.dp__action_buttons {
  display: flex !important;
  gap: 8px !important;
  align-items: center;
}

/* Cancel button */
.dp__action_cancel {
  font-family: 'Inter', sans-serif !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  line-height: 19.5px !important;
  color: #314158 !important;
  background: #FFFFFF !important;
  border: 0.8px solid #E2E8F0 !important;
  border-radius: 4px !important;
  padding: 6px 15px !important;
  height: auto !important;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dp__action_cancel:hover {
  background: #F1F5F9 !important;
  border-color: #CBD5E1 !important;
  color: #1D293D !important;
}

/* Done / Select button */
.dp__action_select {
  background: #155DFC !important;
  color: #FFFFFF !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  line-height: 19.5px !important;
  border-radius: 4px !important;
  padding: 6px 15px !important;
  border: none !important;
  height: auto !important;
  cursor: pointer;
  transition: background 0.15s ease;
}

.dp__action_select:hover {
  background: #1447D1 !important;
}


/* ============================================================
   3. RADIO BUTTONS — card-style, checkbox look
   Target markup:
   .ww-input-radio
     .ww-input-radio__container
       input.ww-input-radio__radio[type=radio]
       label
         p (option text)
   ============================================================ */

:root {
  --radio-border: #E2E8F0;      /* неактивний бордер / іконка */
  --radio-border-hover: #cbd5e1;
  --radio-accent: #155DFC;      /* активна іконка (заливка) */
  --radio-accent-border: #8EC5FF; /* активний бордер картки */
  --radio-accent-bg: #EFF6FF;   /* активний бекграунд */
  --radio-accent-text: #1447E6; /* активний текст */
  --radio-text: #45556C;        /* неактивний колір тексту */
}

/* lay the options out horizontally, aligned to the left */
.ww-input-radio {
  display: flex !important;
  flex-flow: row wrap !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 12px !important;
}

/* each option = bordered pill/card, stretches to fill available row width */
.ww-input-radio__container {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  width: auto !important;
  flex: 1 1 0 !important;
  min-height: 38px !important;
  box-sizing: border-box !important;
  padding: 8px 12px !important;
  border: 1px solid var(--radio-border);
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.ww-input-radio__container:hover {
  border-color: var(--radio-border-hover);
}

/* highlight the whole card when its radio is checked */
.ww-input-radio__container:has(.ww-input-radio__radio:checked) {
  border-color: var(--radio-accent-border);
  background: var(--radio-accent-bg);
}

/* label fills the row, sits to the right of the checkbox */
.ww-input-radio__container label {
  display: flex;
  align-items: center;
  width: auto;
  margin: 0;
  cursor: pointer;
}

.ww-input-radio__container label p {
  font-family: 'Inter', sans-serif !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  color: var(--radio-text) !important;
  transition: color .15s ease;
}

.ww-input-radio__radio:checked + label p {
  color: var(--radio-accent-text) !important;
}

/* fallback in case the radio/label sibling order differs in the actual DOM */
.ww-input-radio__container:has(.ww-input-radio__radio:checked) label p {
  color: var(--radio-accent-text) !important;
}

/* turn the native radio into a checkbox-style square */
.ww-input-radio__radio {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--radio-border);
  border-radius: 4px;
  background: #ffffff;
  position: relative;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}

.ww-input-radio__radio:checked {
  background: var(--radio-accent);
  border-color: var(--radio-accent);
}

/* checkmark drawn with a rotated border, no image needed */
.ww-input-radio__radio:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.ww-input-radio__radio:focus-visible {
  outline: 2px solid var(--radio-accent);
  outline-offset: 2px;
}


/* ============================================================
   4. REUSABLE SCROLLABLE TABLE  (generic: scroll + sticky header only)
   Classes in WeWeb (Settings -> Custom CSS class):
     table-scroll         -> element that holds header row + rows list
                             (the ONLY element that scrolls, X + Y)
     table-scroll-inner   -> the rows list (Repeater): no own scroll
     table-scroll-header  -> header row: sticks to the top
   Column widths are NOT set here: set them in WeWeb on each column
   (header cell and row cell of the same column = same width).
   ============================================================ */

/* the only scroll container.
   Grid with ONE column: header and rows list always get the SAME width
   (never narrower than the table; wider only when the columns' minimum
   widths, e.g. minmax(110px, 1fr), don't fit -> horizontal scroll) */
.table-scroll {
  display: grid !important;
  grid-template-columns: minmax(100%, min-content) !important;
  align-content: start !important;
  max-width: 100% !important;
  min-width: 0 !important;
  max-height: calc(100vh - 280px) !important; /* adjust 280px if needed */
  overflow: auto !important;
}

/* header + rows list stretch to that shared width and are never
   narrower than their columns (so backgrounds cover the whole row) */
.table-scroll > * {
  width: auto !important;
  min-width: min-content !important;
  justify-self: stretch !important;
}

/* rows list: no scroll of its own, every row = full width */
.table-scroll-inner {
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
  align-items: stretch !important;
}
.table-scroll-inner > * {
  width: 100% !important;
  min-width: min-content !important;
}

/* vertical scrollbar starts BELOW the header (Chrome / Edge / Safari).
   --table-header-h = header height; change it per table if needed */
.table-scroll {
  --table-header-h: 44px;
  --table-header-bg: #F8FAFC;   /* same colour as the header */
}
.table-scroll::-webkit-scrollbar-track:vertical {
  margin-top: var(--table-header-h);
}
/* the empty strip above the scrollbar gets the header colour */
.table-scroll::-webkit-scrollbar:vertical {
  background: linear-gradient(
    to bottom,
    var(--table-header-bg) var(--table-header-h),
    transparent var(--table-header-h)
  );
}

/* header row stays visible while scrolling down */
.table-scroll-header {
  position: sticky !important;
  top: 0;
  min-width: min-content !important;
  z-index: 3;
  background-color: var(--table-header-bg, #F8FAFC) !important;
}


/* ============================================================
   5. FULLSCREEN CONTAINER
   Class in WeWeb (Settings -> Custom CSS class):
     fullscreen   -> the element that should cover the whole viewport

   FIXED, NOT ABSOLUTE — on purpose. `absolute` is measured from the
   nearest positioned ancestor, and in WeWeb there is nearly always one,
   so an absolute box stretches to fill that parent instead of the screen.
   `fixed` is measured from the viewport, which is what "the whole screen"
   means. If you ever do want it bounded by a specific parent, change the
   one line to `position: absolute` and give that parent `position:
   relative` — but then it is no longer fullscreen.

   ONE CAVEAT, and it is the thing that breaks this: if ANY ancestor has
   transform, filter, perspective, backdrop-filter or will-change on it,
   that ancestor becomes the reference instead of the viewport and the
   element silently stops covering the screen. WeWeb adds transforms for
   animations and transitions, so if this ever looks "almost fullscreen",
   that is where to look — move the element higher up the tree, ideally a
   direct child of the page.
   ============================================================ */

.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;

  /* 100vh first as the fallback, then 100dvh for browsers that have it.
     On phones 100vh counts the area UNDER the address bar, so a 100vh box
     is taller than what you can see and the bottom is cut off. dvh tracks
     the bar as it hides and shows. */
  height: 100vh !important;
  height: 100dvh !important;

  z-index: 10000 !important;

  /* scroll lives INSIDE this box, and only when the content needs it */
  overflow: auto !important;

  /* stops the scroll from "escaping" to the page behind once this box
     reaches its end — otherwise the background creeps up under it */
  overscroll-behavior: contain;

  padding: 24px !important;

  /* box-sizing is what makes that padding safe: it is counted INSIDE the
     100% width and 100dvh height rather than added to them, so the box
     still measures exactly one screen and no scrollbar appears from the
     padding alone. Removing this line brings back a 48px overflow on both
     axes. */
  box-sizing: border-box !important;
}

/* phones / small tablets — same breakpoint as the date picker above, so
   the two never disagree about where "mobile" starts */
@media (max-width: 767px) {
  .fullscreen {
    padding: 16px !important;
  }
}

/* While a fullscreen box is open, the page behind it must not scroll: its
   scrollbar would stay next to the box's own, because a fixed box of width
   100% stops at the viewport's scrollbar. WeWeb scrolls a container inside
   the page as well as the page itself, so this covers every ancestor of the
   box, not only html and body. It does not touch the box's own scrollbar,
   and it stops applying as soon as the class comes off. */
:has(.fullscreen) {
  overflow: hidden !important;
}

/* WeWeb wraps a form container's children in an inner layout div. Without
   this it is sized by its content, so the box is fullscreen but what is in
   it is not. */
.fullscreen > .ww-form-container__content {
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

/* A bound layout container that currently renders nothing still occupies
   height in a flex column — that is the empty strip above the first real
   row. Collapsing the empty ones removes it without touching anything that
   has content.

   Scoped to inside .fullscreen on purpose: :empty is blunt, and elsewhere
   in the app an empty div may be a deliberate spacer. If a container here
   is ever MEANT to be empty and reserve space, give it a non-breaking
   space in WeWeb so it stops matching :empty. */
.fullscreen .ww-layout:empty,
.fullscreen .ww-flexbox:empty {
  display: none !important;
}
