/* ─────────────────────────────────────────
   suraModal — v1.1.0
   Requires Bootstrap 5
───────────────────────────────────────── */

/* Container where all modals live */
#suraModalContainer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1055;
}

/* ── <dialog> base ─────────────────────── */
dialog.sura-modal {
  pointer-events: all;
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;

  /* sizes */
  width: 90vw;
}

dialog.sura-modal.modal-sm {
  max-width: 300px;
}
dialog.sura-modal.modal-lg {
  max-width: 800px;
}
dialog.sura-modal.modal-xl {
  max-width: 1140px;
}
dialog.sura-modal.modal-xx {
  max-width: 96vw;
}

/* Backdrop via ::backdrop (native dialog) */
dialog.sura-modal::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Open animation ────────────────────── */
@keyframes sura-modal-in {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

dialog.sura-modal[open] {
  animation: sura-modal-in 0.52s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes sura-modal-out {
  /* fase 1: comprimir a trapecio en el centro (~10% del tamaño) */
  0% {
    opacity: 1;
    transform: scale(1) perspective(700px) rotateX(0deg) rotateY(0deg) skewX(0deg);
    border-radius: 6px;
  }
  18% {
    opacity: 1;
    transform: scale(0.5) perspective(700px) rotateX(20deg) rotateY(6deg) skewX(10deg);
    border-radius: 6px;
  }
  36% {
    opacity: 1;
    /* trapecio comprimido al ~10% */
    transform: scale(0.1) perspective(700px) rotateX(34deg) rotateY(10deg) skewX(18deg) skewY(6deg);
    border-radius: 6px;
  }
  /* fase 2: trapecio → esfera en el centro */
  52% {
    opacity: 1;
    transform: scale(0.1);
    border-radius: 50%;
  }
  /* fase 3: esfera vuela a esquina superior izquierda, reduciéndose */
  75% {
    opacity: 0.75;
    transform: translate(-32vw, -32vh) scale(0.05);
    border-radius: 50%;
  }
  92% {
    opacity: 0.2;
    transform: translate(-48vw, -46vh) scale(0.02);
    border-radius: 50%;
  }
  100% {
    opacity: 0;
    transform: translate(-52vw, -50vh) scale(0.01);
    border-radius: 50%;
  }
}

dialog.sura-modal.sura-modal-closing {
  animation: sura-modal-out 0.42s cubic-bezier(0.4, 0, 0.75, 0.55) both;
  pointer-events: none;
}

/* ── Header / title bar ────────────────── */
.sura-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  background: var(--sura-veo-navy);
  border-radius: 6px 6px 0 0;
  min-height: 36px;
  flex-shrink: 0;
  user-select: none;
}

.sura-modal-title {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Close button ──────────────────────── */
.sura-modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--bs-danger, #dc3545);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.sura-modal-close-x {
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.sura-modal-close-btn:hover {
  background: #a71d2a;
}

.sura-modal-close-btn:hover .sura-modal-close-x,
.sura-modal-close-btn:focus .sura-modal-close-x {
  color: #fff;
}

.sura-modal-close-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 1px;
}

/* ── Body / <section> ──────────────────── */
.sura-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
}

/* Ensure inner containers fill the section */
.sura-modal-body .container,
.sura-modal-body .container-fluid {
  padding-left: 0;
  padding-right: 0;
}

/* ── Footer ────────────────────────────── */
.sura-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 10px;
  border-top: 1px solid #dee2e6;
  background: var(--sura-footer-bg);
  border-radius: 0 0 6px 6px;
  flex-shrink: 0;
}

/* Button wrappers inside footer */
.sura-modal-footer > div {
  display: inline-flex;
}

/* ── Dark theme ────────────────────────── */
body.sura-dark-theme dialog.sura-modal {
  background: var(--bs-gray-700);
  color: #f8fafc;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--sura-surface-border, rgba(30, 41, 59, 0.65));
}

body.sura-dark-theme dialog.sura-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.sura-dark-theme .sura-modal-body {
  color: #e2e8f0;
}

body.sura-dark-theme .sura-modal-body a {
  color: #93c5fd;
}

body.sura-dark-theme .sura-modal-body a:hover,
body.sura-dark-theme .sura-modal-body a:focus {
  color: #dbeafe;
}

body.sura-dark-theme .sura-modal-footer {
  background: var(--sura-footer-bg-dark-theme);
  border-top-color: var(--sura-surface-border, rgba(30, 41, 59, 0.65));
  color: #e2e8f0;
}
