.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  transition: opacity var(--ccl-modal-transition-ms, 320ms) cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay--top {
  align-items: flex-start;
}

.modal-overlay--center {
  align-items: center;
}

.modal-overlay--bottom {
  align-items: flex-end;
}

.modal-overlay--entered {
  opacity: 1;
}

.modal-overlay--exit {
  opacity: 0;
}

.modal-content {
  background-color: var(--color-background, #fff);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-14px) scale(0.98);
  transition:
    opacity var(--ccl-modal-transition-ms, 320ms) cubic-bezier(0.16, 1, 0.3, 1),
    transform var(--ccl-modal-transition-ms, 320ms) cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(0, 0, 0, 0.175);
}

.modal-content--entered {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-overlay--bottom .modal-content {
  transform: translateY(14px) scale(0.98);
}

.modal-overlay--bottom .modal-content--entered {
  transform: translateY(0) scale(1);
}

.modal-overlay--top .modal-content {
  transform: translateY(-14px) scale(0.98);
}

.modal-content--exit {
  opacity: 0;
}

.modal-content--scrollable {
  display: flex;
  flex-direction: column;
}

/* Size variants */
.modal-content--sm {
  max-width: 300px; /* sm */
}

.modal-content--md {
  max-width: 500px; /* default */
}

.modal-content--lg {
  max-width: 800px; /* lg */
}

.modal-content--xl {
  max-width: 1140px; /* xl */
}

.modal-content--fullscreen {
  max-width: none;
  max-height: none;
  height: 100vh;
  width: 100vw;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
}

/* Remove overlay padding for true fullscreen */
.modal-overlay:has(.modal-content--fullscreen) {
  padding: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem;
  border-bottom: 1px solid #dee2e6;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-text, #212529);
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}

.modal-close {
  flex-shrink: 0;
  padding: 0.5rem;
  margin: -0.5rem -0.5rem -0.5rem auto;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  color: var(--color-text, #212529);
  opacity: 0.5;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.15s ease-in-out,
    box-shadow 0.15s ease-in-out;
}

.modal-close:hover:not(:disabled) {
  opacity: 0.75;
}

.modal-close:disabled {
  cursor: not-allowed;
  opacity: 0.25;
}

.modal-close-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.modal-body {
  padding: 1rem;
  overflow-y: visible;
  max-height: none;
}

.modal-content--fullscreen .modal-body {
  max-height: none;
}

.modal-content--scrollable .modal-body {
  overflow-y: auto;
  max-height: calc(100vh - 6rem);
  flex: 1 1 auto;
}

/* When there's no title, add extra top padding to account for close button */
.modal-header--no-title + .modal-body {
  padding-top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-content {
    transition: none;
  }
}

/* Focus styles for accessibility */
.modal-close:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.modal-close:focus:not(:focus-visible) {
  outline: none;
}
