/* Shared modal / dialog styles. Loaded once via base.html. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
}
.modal[hidden] { display: none !important; }
.modal.modal--open {
  opacity: 1;
  pointer-events: auto;
}

.modal__dialog {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.22);
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.modal--open .modal__dialog {
  transform: translateY(0) scale(1);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  gap: 12px;
  border-bottom: 1px solid #f3f4f6;
}
.modal__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
  flex: 1;
  min-width: 0;
}
.modal__close {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.modal__close:hover { color: #111827; background: #f3f4f6; }
.modal__close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.modal__body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  color: #374151;
  font-size: 14.5px;
  line-height: 1.5;
}
.modal__body p { margin: 0 0 10px; }
.modal__body p:last-child { margin-bottom: 0; }

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid #f3f4f6;
  flex-wrap: wrap;
}

.modal__footer .btn { min-height: 40px; }

/* Danger button helper (used by Modal.confirm({danger:true})) */
.btn--danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #dc2626;
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Variants */
.modal--confirm .modal__body p,
.modal--alert .modal__body p { font-size: 14.5px; }

/* Mobile → bottom sheet */
@media (max-width: 640px) {
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal__dialog {
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
    transform: translateY(100%);
  }
  .modal.modal--open .modal__dialog { transform: translateY(0); }
  .modal__header { padding: 14px 16px 8px; }
  .modal__body { padding: 14px 16px; }
  .modal__footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal__footer .btn { width: 100%; min-height: 44px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal__dialog { transition: none; }
}
