/* Modal Overlay */
.custom-modal {
  box-sizing: border-box;
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100vw;
  height: 100vh;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Class added by JS to show the modal */
.custom-modal.show {
  display: flex;
  opacity: 1;
}

/* Modal Content Box */
.modal-content {
  box-sizing: border-box;
  background-color: #856404;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  width: min(400px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Responsive Image */
.modal-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  max-height: calc(100vh - 140px);
  margin-bottom: 20px;
  border-radius: 4px;
  object-fit: contain;
}

/* Modal Buttons Layout */
.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  width: 100%;
}

.modal-btn {
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  font-family: "Playfair Display", serif;
  transition: background-color 0.2s;
}

.primary-btn {
  background-color: cadetblue;
  color: white;
}

.primary-btn:hover {
  background-color: #4b8a8b;
}

.secondary-btn {
  background-color: #e0e0e0;
  color: #333;
}

.secondary-btn:hover {
  background-color: #cccccc;
}

/* Mobile Fallback for 600px min-width */
@media (max-width: 900px) {
  .custom-modal {
    left: 0;
    right: 0;
    align-items: flex-start;
    justify-content: center;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .modal-content {
    width: min(400px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    margin: 0 auto;
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .modal-image {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100vh - 120px);
    min-width: 0 !important;
    height: auto !important;
    object-fit: contain;
  }

  .modal-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .modal-btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
  }
}
