/* Modal Styles */

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-modal-backdrop);
  width: 100vw;
  height: 100vh;
  background-color: var(--color-black);
  opacity: 0.5;
}

.modal-backdrop.fade {
  opacity: 0;
  transition: opacity 0.15s linear;
}

.modal-backdrop.show {
  opacity: 0.5;
}

/* Modal Container */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-modal);
  display: none;
  width: var(--width-full);
  height: var(--width-full);
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}

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

.modal.show .modal-dialog {
  transform: none;
}

/* Modal Dialog */
.modal-dialog {
  position: relative;
  width: var(--width-auto);
  margin: var(--spacing-sm);
  pointer-events: none;
}

@media (min-width: 576px) {
  .modal-dialog {
    max-width: var(--max-width-modal-md);
    margin: 1.75rem auto;
  }
  
  .modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
  }
}

/* Modal Content */
.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--width-full);
  pointer-events: auto;
  background-color: var(--color-white);
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  outline: 0;
}

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

.modal-header .btn-close {
  padding: 0.5rem 0.5rem;
  margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Modal Title */
.modal-title {
  margin-bottom: 0;
  line-height: 1.5;
  font-size: 1.25rem;
  font-weight: 500;
}

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

/* Modal Footer */
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  padding: 0.75rem;
  border-top: 1px solid #dee2e6;
  border-bottom-right-radius: calc(0.3rem - 1px);
  border-bottom-left-radius: calc(0.3rem - 1px);
  gap: 0.5rem;
}

/* Modal Scrollable */
.modal-dialog-scrollable {
  height: calc(100% - 1rem);
}

.modal-dialog-scrollable .modal-content {
  max-height: 100%;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

@media (min-width: 576px) {
  .modal-dialog-scrollable {
    height: calc(100% - 3.5rem);
  }
}

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

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

.modal-fullscreen .modal-body {
  overflow-y: auto;
}

/* Modal Sizes */
.modal-sm {
  max-width: 300px;
}

@media (min-width: 992px) {
  .modal-lg,
  .modal-xl {
    max-width: 800px;
  }
}

@media (min-width: 1200px) {
  .modal-xl {
    max-width: 1140px;
  }
}

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

/* Modal Dark */
.modal-dark .modal-content {
  background-color: #212529;
  color: #fff;
}

.modal-dark .modal-header,
.modal-dark .modal-footer {
  border-color: #495057;
}

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

/* Modal Animations */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-100px);
  }
  to {
    transform: translateY(0);
  }
}

.modal.fade-in {
  animation: modalFadeIn 0.3s ease-out;
}

.modal.slide-in .modal-dialog {
  animation: modalSlideIn 0.3s ease-out;
}

/* Stacked Modals */
.modal-open .modal {
  overflow-x: hidden;
  overflow-y: auto;
}

/* Body class when modal is open */
.modal-open {
  overflow: hidden;
  padding-right: 0;
}

/* Responsive */
@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0.5rem;
  }
  
  .modal-sm {
    max-width: 300px;
  }
}

/* Custom Close Button */
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background-color: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: #000;
  opacity: 0.5;
  cursor: pointer;
}

.modal-close:hover {
  opacity: 0.75;
}