/**
 * Modal Component
 * Generic modal structure classes following shadcn dialog patterns.
 * Used inside Unpoly overlay layers and standalone modal markup.
 */

/* ── Modal Container ─────────────────────────────────────────── */

.modal {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

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

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

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-base);
  line-height: var(--line-height-tight);
  margin: 0;
}

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

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

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

.modal-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Modal Close Button (ghost X) ────────────────────────────── */

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
  font-size: var(--font-size-base);
  line-height: 1;
}

.modal-close:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text-base);
}

.modal-close:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

/* X icon via pseudo-element when no icon is provided */
.modal-close::before {
  content: "\00d7"; /* × multiplication sign */
  font-size: 1.25rem;
  line-height: 1;
}

/* Hide pseudo when an icon child is present */
.modal-close:has(> *) ::before {
  display: none;
}

/* ── Mobile Responsive ───────────────────────────────────────── */

/* Payment history (seminar payment modal): each payment the student made,
   listed on its own line so ONE of them can be refunded without touching the
   others. */
.payment-history {
  margin: var(--space-4) 0;
}

.payment-history__title {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.payment-history__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border-base);
}

.payment-history__date {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.payment-history__amount {
  flex: 1 1 auto;
  font-variant-numeric: tabular-nums;
}

.payment-history__converted {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

/* Destructive, but quiet until hovered -- a refund should take a deliberate
   click, not catch the eye ahead of the amount itself. */
.payment-history__refund {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border-base);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.payment-history__refund:hover {
  color: var(--color-destructive);
  border-color: var(--color-destructive);
  background: color-mix(in srgb, var(--color-destructive) 10%, transparent);
}

@media (max-width: 767px) {
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--space-4);
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer > * {
    width: 100%;
  }
}
