/* ── Modal ──────────────────────────────────────────────────────
   BEM block: .modal
   Replaces: .modal-overlay, .slide-panel-overlay, 15+ per-page
   modal patterns. Mobile-first: base = full-screen sheet,
   480px+ = centered dialog.

   Activation: toggle .active class on .modal__overlay
   ──────────────────────────────────────────────────────────── */

/* ── Overlay ───────────────────────────────────────────────── */

.modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal__overlay.active {
  display: flex;
}

/* ── Dialog ────────────────────────────────────────────────── */

.modal__dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────── */

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ── Title ─────────────────────────────────────────────────── */

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

/* ── Close ─────────────────────────────────────────────────── */

.modal__close {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal__close:hover {
  color: var(--color-text);
}

/* ── Body ──────────────────────────────────────────────────── */

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

/* ── Footer ────────────────────────────────────────────────── */

.modal__footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal__footer > button {
  min-height: var(--input-height-lg);
  width: 100%;
}

/* ── Slide modifier (right-side panel) ─────────────────────── */

.modal--slide .modal__dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  max-height: none;
  border-radius: 0;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.modal--slide.active .modal__dialog {
  transform: translateX(0);
}

.modal--slide.active {
  display: block;
}

/* ── 480px+: centered dialog ──────────────────────────────── */

@media (min-width: 480px) {
  .modal__overlay {
    align-items: center;
  }

  .modal__dialog {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  .modal__footer > button {
    width: auto;
    min-height: var(--input-height-md);
  }

  /* Slide panel: constrained width */
  .modal--slide .modal__dialog {
    width: 480px;
    max-width: 90vw;
    border-left: 1px solid var(--color-border);
  }
}

/* ── Width modifiers ───────────────────────────────────────── */

@media (min-width: 480px) {
  .modal--wide .modal__dialog {
    max-width: 800px;
  }

  .modal--narrow .modal__dialog {
    max-width: 400px;
  }
}
