/* ==========================================================================
   AFQ Custom Announcement Modal CSS (v2.1 - Tema Biru #1b7eca)
   Prefix: .afq-modal-* (Aman dari konflik dengan Bootstrap 4 & Naevaweb)
   ========================================================================== */

:root {
  --afq-modal-accent: #166db3;
  --afq-modal-accent-hover: #11558c;
  --afq-modal-btn-text: #ffffff;
  --afq-modal-bg: #ffffff;
  --afq-modal-text: #1e293b;
  --afq-modal-muted: #64748b;
  --afq-modal-border: #e2e8f0;
  --afq-modal-radius: 16px;
  --afq-modal-anim-duration: 0.35s;
}

/* Kunci scroll halaman utama saat modal aktif */
html.afq-modal-open,
body.afq-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* Backdrop / Overlay */
.afq-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 105000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--afq-modal-anim-duration) ease,
    visibility var(--afq-modal-anim-duration) ease;
}

.afq-modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Container Card Modal */
.afq-modal-card {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--afq-modal-bg);
  color: var(--afq-modal-text);
  border-radius: var(--afq-modal-radius);
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.18),
    0 8px 10px -6px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  transition:
    transform var(--afq-modal-anim-duration) cubic-bezier(0.16, 1, 0.3, 1),
    opacity var(--afq-modal-anim-duration) ease;
}

.afq-modal-overlay.is-visible .afq-modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Animasi halus saat user klik di luar modal */
@keyframes afqModalShake {
  0%, 100% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-6px) scale(1); }
  50% { transform: translateX(6px) scale(1); }
  75% { transform: translateX(-4px) scale(1); }
}

.afq-modal-card.is-shaking {
  animation: afqModalShake 0.32s ease-in-out;
}

/* Tombol Close (X) di Pojok Kanan Atas */
.afq-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background-color: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.afq-modal-close:hover {
  background-color: rgba(15, 23, 42, 0.9);
  transform: rotate(90deg) scale(1.05);
}

.afq-modal-close:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Area Scrollable di dalam Modal (Gambar + Konten) */
.afq-modal-scroll-area {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

/* Wrapper Gambar */
.afq-modal-media {
  position: relative;
  width: 100%;
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--afq-modal-border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.afq-modal-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 52vh;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

/* Keterangan jika gambar gagal dimuat */
.afq-modal-img-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 24px;
  width: 100%;
  color: var(--afq-modal-muted);
  background-color: #f8fafc;
}

.afq-modal-img-error.is-shown {
  display: flex;
}

.afq-modal-img-error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}

.afq-modal-img-error-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #475569;
  font-weight: 500;
}

/* Area Teks (Title & Deskripsi) */
.afq-modal-body {
  padding: 20px 24px 16px;
}

.afq-modal-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  color: #0f172a;
}

.afq-modal-desc {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #475569;
  white-space: pre-line;
}

.afq-modal-desc a {
  color: var(--afq-modal-accent);
  text-decoration: underline;
}

.afq-modal-desc a:hover {
  color: var(--afq-modal-accent-hover);
}

/* Footer & Tombol Aksi (Mengerti / Link) di Kanan Bawah */
.afq-modal-footer {
  padding: 12px 24px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background-color: var(--afq-modal-bg);
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.afq-modal-btn-ok,
.afq-modal-btn-link,
.afq-modal-btn-link:visited {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.925rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  color: var(--afq-modal-btn-text) !important;
  background-color: var(--afq-modal-accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(27, 126, 202, 0.28);
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.afq-modal-btn-link span,
.afq-modal-btn-link:hover span,
.afq-modal-btn-link:focus span {
  color: var(--afq-modal-btn-text) !important;
}

.afq-modal-btn-ok:hover,
.afq-modal-btn-link:hover {
  background-color: var(--afq-modal-accent-hover);
  color: var(--afq-modal-btn-text) !important;
  text-decoration: none !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27, 126, 202, 0.36);
}

.afq-modal-btn-ok:active,
.afq-modal-btn-link:active {
  transform: translateY(0);
}

.afq-modal-btn-ok:focus,
.afq-modal-btn-link:focus {
  outline: 2px solid var(--afq-modal-accent);
  outline-offset: 2px;
  color: var(--afq-modal-btn-text) !important;
}

.afq-modal-btn-link-arrow {
  font-size: 1.05em;
  line-height: 1;
  transition: transform 0.2s ease;
}

.afq-modal-btn-link:hover .afq-modal-btn-link-arrow {
  transform: translateX(3px);
}

/* ==========================================================================
   Responsive Breakpoints (Laptop, Tablet, Mobile)
   ========================================================================== */

@media (max-width: 991px) {
  .afq-modal-card {
    max-width: 480px;
  }
}

@media (max-width: 575px) {
  .afq-modal-overlay {
    padding: 12px;
  }

  .afq-modal-card {
    max-width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 14px;
  }

  .afq-modal-close {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .afq-modal-img {
    max-height: 44vh;
  }

  .afq-modal-body {
    padding: 16px 18px 12px;
  }

  .afq-modal-title {
    font-size: 1.1rem;
  }

  .afq-modal-desc {
    font-size: 0.88rem;
  }

  .afq-modal-footer {
    padding: 10px 18px 14px;
  }

  .afq-modal-btn-ok,
  .afq-modal-btn-link,
  .afq-modal-btn-link:visited {
    padding: 9px 20px;
    font-size: 0.88rem;
  }
}

/* Aksesibilitas untuk user dengan pengaturan reduce motion */
@media (prefers-reduced-motion: reduce) {
  .afq-modal-overlay,
  .afq-modal-card,
  .afq-modal-close,
  .afq-modal-btn-ok,
  .afq-modal-btn-link,
  .afq-modal-btn-link-arrow {
    transition: none !important;
    animation: none !important;
  }
}