/*
 * MS Liton Traders — Right-side popup panel behavior
 * Visual/interaction layer only. Existing Bootstrap modal markup, IDs,
 * JavaScript functions and business workflows remain unchanged.
 */

:root {
  --mlt-popup-width: min(1120px, calc(100vw - 72px));
  --mlt-popup-radius: 24px 0 0 24px;
  --mlt-popup-speed: 280ms;
  --mlt-popup-ease: cubic-bezier(.22, 1, .36, 1);
}

/* Keep Bootstrap backdrop and focus management, but align the panel right. */
.modal {
  padding: 0 !important;
}

.modal .modal-dialog,
.modal .modal-dialog.modal-xl,
.modal .modal-dialog.modal-lg,
.modal .modal-dialog.modal-sm {
  position: fixed !important;
  inset: 0 0 0 auto !important;
  width: var(--mlt-popup-width) !important;
  max-width: none !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  margin: 0 !important;
  pointer-events: none;
}

/* Override Bootstrap's vertical fade with a clean horizontal right slide. */
.modal.fade .modal-dialog {
  transform: translate3d(104%, 0, 0) !important;
  transition: transform var(--mlt-popup-speed) var(--mlt-popup-ease) !important;
}

.modal.show .modal-dialog {
  transform: translate3d(0, 0, 0) !important;
}

.modal .modal-content {
  width: 100% !important;
  height: 100% !important;
  max-height: 100dvh !important;
  min-height: 100vh !important;
  border: 0 !important;
  border-radius: var(--mlt-popup-radius) !important;
  overflow: hidden !important;
  pointer-events: auto;
  background: #fff !important;
  box-shadow: -24px 0 70px rgba(15, 23, 42, .24) !important;
}

.modal .modal-header {
  position: sticky;
  top: 0;
  z-index: 5;
  flex: 0 0 auto;
  min-height: 68px;
  padding: 16px 20px !important;
  border-bottom: 1px solid rgba(255, 255, 255, .16) !important;
}

.modal .modal-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  padding: 20px !important;
  scrollbar-gutter: stable;
}

.modal .btn-close {
  flex: 0 0 auto;
}

/* Keep action buttons accessible at the bottom of long forms/views. */
.modal .modal-action-footer {
  position: sticky;
  bottom: -20px;
  z-index: 4;
  margin: 20px -20px -20px !important;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom)) !important;
  background: rgba(255, 255, 255, .96) !important;
  border-top: 1px solid #e2e8f0 !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.modal-backdrop.show {
  opacity: .48 !important;
}

@media (max-width: 991.98px) {
  :root {
    --mlt-popup-width: min(94vw, 820px);
    --mlt-popup-radius: 20px 0 0 20px;
  }
}

@media (max-width: 575.98px) {
  :root {
    --mlt-popup-width: 100vw;
    --mlt-popup-radius: 0;
  }

  .modal .modal-header {
    min-height: 62px;
    padding: 13px 15px !important;
  }

  .modal .modal-body {
    padding: 15px !important;
  }

  .modal .modal-action-footer {
    bottom: -15px;
    margin: 16px -15px -15px !important;
    padding: 12px 15px calc(12px + env(safe-area-inset-bottom)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal.fade .modal-dialog {
    transition-duration: 1ms !important;
  }
}

@media print {
  .modal,
  .modal-backdrop {
    display: none !important;
  }
}
