@use 'global/common' as global;

/* ------------------------------
 モーダル
------------------------------- */

@keyframes fade-in-bottom {
  0% {
    opacity: 0;
    transform: translateY(50px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-out-top {
  0% {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    visibility: hidden;
    opacity: 0;
    transform: translateY(-50px);
  }
}

.acms-modal {
  --acms-modal-width: 800px;
  --acms-modal-margin: 10px;

  position: fixed;
  inset: 0;
  z-index: global.zIndex(acms-modal);
  width: 100%;
  height: 100%;
  padding-right: calc(constant(safe-area-inset-right));
  padding-left: calc(constant(safe-area-inset-left));
  overflow: hidden auto;
  outline: 0;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  -webkit-overflow-scrolling: touch;

  @if global.$admin == true {
    font-family: global.$acms-admin-font-family;
  }
}

.acms-modal.in {
  opacity: 1;
  transition: opacity 0.3s;
}

.acms-modal.out {
  opacity: 0;
  transition: opacity 0.3s;
}

.acms-modal.display {
  opacity: 1;
}

.acms-modal.in .acms-modal-dialog {
  animation: fade-in-bottom 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) forwards;
}

.acms-modal.out .acms-modal-dialog {
  animation: fade-out-top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@media (prefers-reduced-motion) {
  .acms-modal.in .acms-modal-dialog {
    animation: none;
  }

  .acms-modal.out .acms-modal-dialog {
    animation: none;
  }
}

.acms-modal-middle {
  position: fixed;
  overflow: hidden;

  &.display {
    bottom: 0;
  }

  .acms-modal-dialog {
    height: 100vh;
    box-shadow: none;
  }

  .acms-modal-content {
    margin: 50px auto;
  }
}

.acms-modal-middle-scroll {
  max-height: 50vh;
  overflow: auto;
}

.acms-modal-dialog {
  position: relative;
  width: 95%;
  max-width: var(--acms-modal-width);
  margin: var(--acms-modal-margin) auto;
  box-shadow: 0 5px 15px #000;
}

.acms-modal-dialog.large {
  --acms-modal-width: 1200px;
}

.acms-modal-dialog.medium {
  --acms-modal-width: 1200px;
}

.acms-modal-dialog.small {
  --acms-modal-width: 600px;
}

@media screen and (min-width: global.$breakpoint-md-min) {
  .acms-modal-dialog {
    --acms-modal-margin: 30px;

    margin: var(--acms-modal-margin) auto;
  }

  .acms-modal-dialog.medium {
    width: 75%;
  }
}

.acms-modal-content {
  padding: 5px;
  overflow: hidden;
  background: global.$acms-color-white;
  border-radius: 6px;
}

.acms-modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  margin: 0 -5px;
  border-bottom: 1px solid global.$acms-color-gray60;
}

.acms-modal-heading {
  margin: 0;
  color: global.$acms-color-black;

  @include global.font-size(14);
}

.acms-modal-body {
  padding: 0 10px;
  margin: 0 -5px;

  @include global.font-size(14);
}

.acms-modal-body-fit {
  margin: 0 -10px;
}

.acms-modal-body-tab-scrollable .acms-tabs-panel {
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.acms-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: global.zIndex(acms-modal);
  overflow: hidden auto;
  background-color: rgba(global.$acms-color-black, 0.5);
  transform: translateZ(0);
}

.acms-modal-hide {
  order: 99; // 一番右に配置（互換性のために指定している。利用する場合はHTML構造として最後に配置することを推奨）
  padding: 0;
  margin-left: auto;
  font-size: 20px;
  line-height: 1;
  color: global.$acms-color-gray90;
  cursor: pointer;
  background: global.$acms-color-white;
  border: 1px solid transparent;

  &:focus {
    border-color: global.$acms-btn-focus-border-color;
    outline: 0;
  }
}

.acms-modal-footer {
  padding: 15px;
  margin: 0 -5px;
  text-align: right;
  border-top: 1px solid global.$acms-color-gray60;

  .acms-btn {
    margin-left: 5px;
  }

  .acms-btn:first-child {
    margin-left: 0;
  }
}

.acms-modal .acms-modal-quick-search {
  max-width: 600px;
  height: auto;

  .acms-table-hover tr:hover td,
  .acms-table-hover tr:focus-within td {
    background: global.$acms-color-info10;
  }

  .acms-table-hover tr.hover td {
    background: global.$acms-color-info10;
  }
}

@media screen and (min-width: global.$breakpoint-md-min) {
  .acms-modal-header {
    padding: 15px;
  }

  .acms-modal-heading {
    @include global.font-size(18);
  }

  .acms-modal-body {
    padding: 0 15px;
  }
}

// モジュールのタイトル
.acms-title-wrapper {
  position: relative;

  .acms-modal-heading {
    margin: 15px 0;
  }

  // アイコン
  .acms-icon {
    position: absolute;
    top: 2px;
    left: 0;
  }

  strong {
    display: block;
    margin-bottom: 10px;

    @include global.font-size(13);
  }

  h1 {
    margin: 0;

    @include global.font-size(20);
  }

  .acms-module-en {
    display: inline-block;
    margin: 0 15px 10px 0;
    font-weight: bold;
    color: global.$acms-color-gray90;

    @include global.font-size(12);
  }
}
