/* FILE: sap-popup-manager/assets/css/sap-popup-front.css */

/* ─── Base overlay ─── */
.sap-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.sap-popup-overlay.is-open {
  display: flex;
}

.sap-popup-overlay *,
.sap-popup-overlay *::before,
.sap-popup-overlay *::after {
  box-sizing: border-box;
}

/* ─── Container ─── */
.sap-popup-container {
  position: relative;
  width: 100%;
  margin: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

/* ─── Positions ─── */
.sap-loc-top          { align-items: flex-start; }
.sap-loc-bottom       { align-items: flex-end; }
.sap-loc-top-left     { align-items: flex-start; justify-content: flex-start; }
.sap-loc-top-right    { align-items: flex-start; justify-content: flex-end; }
.sap-loc-bottom-left  { align-items: flex-end;   justify-content: flex-start; }
.sap-loc-bottom-right { align-items: flex-end;   justify-content: flex-end; }
.sap-loc-left         { justify-content: flex-start; }
.sap-loc-right        { justify-content: flex-end; }

/* ─── Notification Bar ─── */
.sap-type-notification-bar {
  inset: auto;
  width: 100%;
  align-items: stretch;
  justify-content: center;
}
.sap-loc-top.sap-type-notification-bar    { top: 0; }
.sap-loc-bottom.sap-type-notification-bar { bottom: 0; }

.sap-type-notification-bar .sap-popup-container {
  margin: 0;
  max-width: 100% !important;
  max-height: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border-radius: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─── Close button ─── */
.sap-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  color: #333;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s ease, color 0.15s ease;
}
.sap-popup-close:hover,
.sap-popup-close:focus {
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}
.sap-close-light {
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
}
.sap-close-light:hover,
.sap-close-light:focus {
  background: rgba(255, 255, 255, 0.15);
}

/* ─── Notification content ─── */
.sap-popup-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sap-type-notification-bar .sap-popup-body {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.sap-notification-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}
.sap-notification-btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: #2271b1;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-start;
}
.sap-notification-btn:hover,
.sap-notification-btn:focus {
  background: #135e96;
  color: #fff;
}

/* Notification preview image areas */
.sap-popup-preview {
  background: #f1f1f1;
  border-radius: inherit;
  min-height: 120px;
}

/* ─── Entry animations [FIX D1#6]: every keyframe defined ─── */
.sap-anim-open-fadeIn    { animation: sapFadeIn      0.3s ease forwards; }
.sap-anim-open-slideDown { animation: sapSlideDown   0.3s ease forwards; }
.sap-anim-open-zoomIn    { animation: sapZoomIn      0.3s ease forwards; }
.sap-anim-open-slideFade { animation: sapSlideFadeIn 0.3s ease forwards; }
.sap-anim-open-none      { animation: none; }

@keyframes sapFadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes sapSlideDown   { from { transform: translateY(-20px); opacity: 0; }
                            to   { transform: translateY(0);     opacity: 1; } }
@keyframes sapZoomIn      { from { transform: scale(0.8); opacity: 0; }
                            to   { transform: scale(1);   opacity: 1; } }
@keyframes sapSlideFadeIn { from { transform: translateY(-20px) scale(0.95); opacity: 0; }
                            to   { transform: translateY(0) scale(1);        opacity: 1; } }

/* ─── Exit animations ─── */
.sap-anim-exit-fadeOut      { animation: sapFadeOut      0.3s ease forwards; }
.sap-anim-exit-slideUp      { animation: sapSlideUp      0.3s ease forwards; }
.sap-anim-exit-zoomOut      { animation: sapZoomOut      0.3s ease forwards; }
.sap-anim-exit-slideFadeOut { animation: sapSlideFadeOut 0.3s ease forwards; }
.sap-anim-exit-none         { animation: none; }

@keyframes sapFadeOut      { to { opacity: 0; } }
@keyframes sapSlideUp      { to { transform: translateY(-20px); opacity: 0; } }
@keyframes sapZoomOut      { to { transform: scale(0.8); opacity: 0; } }
@keyframes sapSlideFadeOut { to { transform: translateY(-20px) scale(0.95); opacity: 0; } }

/* ─── Screen reader only ─── */
.sap-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Popup image layout ─── */
.sap-popup-with-image {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

/* Left/right: side by side */
.sap-img-left  { flex-direction: row; }
.sap-img-right { flex-direction: row-reverse; }

/* Top/bottom: stacked */
.sap-img-top    { flex-direction: column; }
.sap-img-bottom { flex-direction: column-reverse; }

/* Image area */
.sap-popup-image-wrap {
  flex-shrink: 0;
  overflow: hidden;
  border-radius: inherit;
}
.sap-popup-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Top/bottom: full width, capped height */
.sap-img-top    .sap-popup-image-wrap,
.sap-img-bottom .sap-popup-image-wrap {
  width: 100%;
  max-height: 260px;
  flex-basis: auto;
}

/* Embed / form area */
.sap-popup-embed-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
}
.sap-popup-inner {
  width: 100%;
}

/* ─── Mobile: image ALWAYS on top, form below (regardless of position) ─── */
@media (max-width: 767px) {
  .sap-popup-with-image {
    flex-direction: column !important;
  }
  .sap-popup-image-wrap {
    width: 100% !important;
    flex-basis: auto !important;
    max-height: 200px;
    order: 0 !important; /* image first */
  }
  .sap-popup-embed-wrap {
    order: 1 !important;
  }
}

/* ─── [FIX D2#8]: Mobile full width ─── */
@media (max-width: 767px) {
  .sap-mobile-full .sap-popup-container {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    margin: 0;
  }
  .sap-mobile-full.sap-popup-overlay {
    align-items: stretch;
  }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .sap-popup-container {
    animation: none !important;
  }
}
