// Modal
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: $z-modal;
  display: none;
  
  &.is-open {
    display: block;
  }
  
  &__overlay {
    @include absolute-cover;
    background-color: rgba(0, 0, 0, 0.6);
    @include flex-center;
    padding: $spacing-base;
    animation: fadeIn 0.3s ease-out;
  }
  
  &__container {
    background-color: white;
    @include border-radius($border-radius-lg);
    @include box-shadow($shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
    
    @include media-down('sm') {
      max-width: 95%;
      margin: $spacing-base;
    }
  }
  
  &__header {
    @include flex-between;
    padding: $spacing-lg $spacing-xl;
    border-bottom: 1px solid $border-light;
  }
  
  &__title {
    font-size: $font-size-xl;
    font-weight: $font-weight-semibold;
    margin: 0;
    color: $text-color;
  }
  
  &__close {
    background: none;
    border: none;
    font-size: $font-size-xl;
    width: 32px;
    height: 32px;
    @include flex-center;
    @include border-radius(50%);
    color: $text-muted;
    cursor: pointer;
    @include transition();
    
    &:hover {
      background-color: $bg-secondary;
      color: $text-color;
    }
    
    &:focus {
      outline: 2px solid $primary-color;
      outline-offset: 2px;
    }
    
    &::before {
      content: '×';
    }
  }
  
  &__content {
    padding: $spacing-xl;
    
    p:last-child {
      margin-bottom: 0;
    }
  }
  
  &__footer {
    @include flex-between;
    padding: $spacing-base $spacing-xl $spacing-xl;
    gap: $spacing-base;
    
    @include media-down('sm') {
      flex-direction: column-reverse;
      
      .btn {
        width: 100%;
      }
    }
  }
}

// Modal form styles
.modal-form {
  .form-group:last-child {
    margin-bottom: $spacing-base;
  }
}

// Modal animations
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

// Micromodal specific styles
.micromodal-slide {
  display: none;
  
  &.is-open {
    display: block;
  }
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
  animation: mmfadeIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
  animation: mmslideIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
  animation: mmfadeOut 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
  animation: mmslideOut 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
  will-change: transform;
}

@keyframes mmfadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes mmfadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes mmslideIn {
  from {
    transform: translateY(15%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes mmslideOut {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-10%);
  }
}