@use '../variables' as v;
@use '../mixins' as m;

// ─────────────────────────────────────────────
// Modal overlay
// ─────────────────────────────────────────────
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(v.$gray-900, 0.45);
  backdrop-filter: blur(2px);
  z-index: v.$z-modal;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity v.$transition-slow;

  &.is-open {
    opacity: 1;
    pointer-events: all;
  }
}

// ─────────────────────────────────────────────
// Modal dialog
// ─────────────────────────────────────────────
.modal {
  background: var(--bg-surface);
  border-radius: v.$radius-xl;
  box-shadow: v.$shadow-xl;
  width: 100%;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: transform v.$transition-slow;
  overflow: hidden;

  .modal-overlay.is-open & {
    transform: translateY(0);
  }

  &--sm {
    max-width: 400px;
  }

  &--md {
    max-width: 540px;
  }

  &--lg {
    max-width: 720px;
  }

  &--xl {
    max-width: 900px;
  }

  &--2xl {
    max-width: 1100px;
  }
}

// ─────────────────────────────────────────────
// Modal header
// ─────────────────────────────────────────────
.modal-header {
  @include m.flex-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 12px;

  h3,
  .modal-title {
    font-size: v.$font-size-lg;
    font-weight: 600;
    color: var(--text-primary);
  }

  p,
  .modal-subtitle {
    font-size: v.$font-size-xs;
    color: var(--text-secondary);
    margin-top: 2px;
  }
}

.modal-close {
  @include m.flex-center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: v.$radius;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background v.$transition-base, color v.$transition-base;

  &:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }

  svg {
    width: 18px;
    height: 18px;
  }
}

// ─────────────────────────────────────────────
// Modal body
// ─────────────────────────────────────────────
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  @include m.scrollbar-thin;
}

// ─────────────────────────────────────────────
// Modal footer
// ─────────────────────────────────────────────
.modal-footer {
  @include m.flex-between;
  padding: 16px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-page);
  flex-shrink: 0;
  gap: 10px;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;

  &-right {
    @include m.flex-start;
    gap: 10px;
    margin-left: auto;
  }
}

.dropdown-wrap {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius-lg;
  box-shadow: v.$shadow-md;
  min-width: 160px;
  z-index: v.$z-dropdown;
  padding: 5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity v.$transition-base, transform v.$transition-base;

  &.is-open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
  }

  &--right {
    left: auto;
    right: 0;
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: v.$radius;
  font-size: v.$font-size-sm;
  color: var(--text-primary)!important;
  cursor: pointer;
  transition: background v.$transition-fast;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;

  svg {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
  }

  &:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }

  &--danger {
    color: var(--danger);

    svg {
      color: var(--danger);
    }

    &:hover {
      
      color: var(--danger);
    }
  }
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}