
/* Modal Styling */
:root {
  --er24-accent: var(--color-primary, #d71920); /* fallback red */
  --er24-bg: var(--surface, #ffffff);
  --er24-text: var(--text, #111111);
  --er24-muted: var(--muted, #6b7280);
  --er24-overlay: rgba(0, 0, 0, 0.52);
  --er24-radius: var(--radius-md, 12px);
  --er24-shadow: var(--shadow-lg, 0 12px 28px rgba(0, 0, 0, 0.18));
  --er24-spacing: 16px;
  --er24-z-modal: var(--z-modal, 1000);
  --er24-title-size: clamp(18px, 2.5vw, 20px);
  --er24-text-size: 14.5px;
}

/* Modal container */
.er24-modal[hidden] { display: none !important; }

.er24-modal {
  position: fixed;
  inset: 0;
  z-index: var(--er24-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Backdrop */
.er24-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--er24-overlay);
  backdrop-filter: saturate(120%) blur(2px);
}

/* Panel */
.er24-modal__panel {
  position: relative;
  z-index: 1;
  width: min(92vw, 420px);
  margin: 0 var(--er24-spacing);
  background: var(--er24-bg);
  color: var(--er24-text);
  border-radius: var(--er24-radius);
  box-shadow: var(--er24-shadow);
  padding: calc(var(--er24-spacing) * 1.25);
  font: inherit;
}

.er24-modal__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.er24-modal__icon {
  color: var(--er24-accent);
  display: inline-flex;
}

.er24-modal__title {
  font-size: var(--er24-title-size);
  line-height: 1.2;
  margin: 0;
  font-weight: 700;
}

.er24-modal__body {
  margin-top: 6px;
}

.er24-modal__message {
  font-size: var(--er24-text-size);
  line-height: 1.45;
  margin: 0 0 12px 0;
}

.er24-modal__progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--er24-muted);
  font-size: 12.5px;
}

.er24-modal__footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Close button */
.er24-modal__close {
  position: absolute;
  top: -3px;
  right: 10px;
  height: 36px;
  width: 36px;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  border: none;
  padding: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.er24-modal__close:focus-visible { outline: 2px solid var(--er24-accent); outline-offset: 2px; }

/* Spinner */
.er24-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--er24-accent);
  border-radius: 50%;
  animation: er24-spin 900ms linear infinite;
}
@keyframes er24-spin { to { transform: rotate(360deg); } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .er24-spinner { animation: none; border-top-color: currentColor; }
  .er24-modal__backdrop { backdrop-filter: none; }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  :root {
    --er24-bg: var(--surface-inverse, #1d1f23);
    --er24-text: var(--text-inverse, #eef0f2);
    --er24-muted: #a3aab3;
    --er24-overlay: rgba(0,0,0,0.62);
  }
  .er24-modal__panel { box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
}

/* Buttons—use site styles if available; otherwise fallback */
.button {
  font: inherit;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button--primary {
  background: var(--er24-accent);
  color: #fff;
}
.button--secondary {
  background: transparent;
  border-color: color-mix(in srgb, var(--er24-text), transparent 80%);
  color: var(--er24-text);
}
.button:focus-visible { outline: 2px solid var(--er24-accent); outline-offset: 2px; }
