// ============================================
// Modal Component
// ============================================

@use "variables" as *;

// Modal Container
.jbs-modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  display: none;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}

// Modal Dialog
.jbs-modal-dialog {
  position: relative;
  width: auto;
  margin: 0.5rem;
  pointer-events: none;
}

// Modal Fade Animation
.jbs-modal.fade .jbs-modal-dialog {
  transition: transform 0.3s ease-out;
  transform: translate(0, -50px);
}

@media (prefers-reduced-motion: reduce) {
  .jbs-modal.fade .jbs-modal-dialog {
    transition: none;
  }
}

// Modal Show State
.jbs-modal.show .jbs-modal-dialog {
  transform: none;
}

// Modal Static
.jbs-modal.jbs-modal-static .jbs-modal-dialog {
  transform: scale(1.02);
}

// Modal Dialog Centered
.jbs-modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}

// Modal Content
.jbs-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background-color: var(--jbs_box_bg_color_opt);
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: $border-radius-xl;
  outline: 0;
}

// Modal Header
.jbs-modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--black_100, #dee2e6);
  border-top-left-radius: calc($border-radius-xl - 1px);
  border-top-right-radius: calc($border-radius-xl - 1px);
}

// Modal Title
.jbs-modal-title {
  margin: 0;
  line-height: 1.5;
}

// Modal Body
.jbs-modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: 1rem;
}

// Responsive Modal
@media (min-width: 576px) {
  .jbs-modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
  }
}

// Fullscreen Modal
.jbs-modal-fullscreen {
  width: 100vw;
  max-width: none;
  height: 100%;
  margin: 0;
}

.jbs-modal-fullscreen .jbs-modal-content {
  height: 100%;
  border: 0;
  border-radius: 0;
}

// NOTE: `.jbs-popUpModal` is a sidebar-filter-only class and its
// backdrop style now lives in `main/_sidebar.scss` alongside the
// rest of the filter popup chrome. The `.jbs-collapse` and
// `.jbs-offcanvas` primitives below remain here because they are
// shared framework utilities (also used by dashboard templates).

.jbs-modal .jbs-modal-dialog {
  height: auto !important;
}

// Collapse Styles for Sidebar Filter
.jbs-collapse {
  display: none;
}

.jbs-collapse.jbs-show {
  display: block;
}

// Offcanvas Styles for Sidebar Filter
.jbs-offcanvas {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1050;
  width: 400px;
  max-width: 100%;
  background-color: $text-white;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out, visibility 0s linear 0.3s;
}

// Offcanvas Show State
.jbs-offcanvas.show {
  visibility: visible;
  transform: translateX(0);
  transition-delay: 0s;
}

// Offcanvas Header
.jbs-offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}

// Offcanvas Close Button
.jbs-offcanvas-close {
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
}

// Offcanvas Body
.jbs-offcanvas-body {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
}

// Offcanvas Backdrop
.jbs-offcanvas-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
}

.jbs-offcanvas-backdrop.show {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

// Offcanvas Start (Left)
.jbs-offcanvas-start {
  top: 0;
  left: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.2);
  transform: translateX(-100%);
}

// Offcanvas End (Right)
.jbs-offcanvas-end {
  top: 0;
  right: 0;
  border-left: 1px solid rgba(0, 0, 0, 0.2);
  transform: translateX(100%);
}

// Offcanvas Top
.jbs-offcanvas-top {
  left: 0;
  right: 0;
  top: 0;
  height: 30vh;
  max-height: 100%;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  transform: translateY(-100%);
}

// Offcanvas Bottom
.jbs-offcanvas-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 30vh;
  max-height: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
}

// Show for Top/Bottom
.jbs-offcanvas-top.show,
.jbs-offcanvas-bottom.show {
  transform: translateY(0);
  visibility: visible;
}

// Reduced Motion
@media (prefers-reduced-motion: reduce) {

  .jbs-offcanvas,
  .jbs-offcanvas-backdrop {
    transition: none;
  }
}

// Button Close
.jbs-btn-close {
  box-sizing: content-box;
  width: 1em;
  height: 1em;
  padding: 0.25em 0.25em;
  color: #000;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center / 1em auto no-repeat;
  border: 0;
  border-radius: $border-radius;
  opacity: 0.5;

  &:hover {
    color: #000;
    text-decoration: none;
    opacity: 0.75;
  }

  &:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba($primary-color, 0.25);
    opacity: 1;
  }

  &:disabled,
  &.disabled {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    opacity: 0.25;
  }
}

.jbs-btn-close-white {
  filter: invert(1) grayscale(100%) brightness(200%);
}