@import url("../../variables.css");

/* Modal Base Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto; /* Allow scrolling on the modal overlay */
  padding: 20px; /* Add padding to keep content from touching edges */
}

/* Modal Content */
.modal-content {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  margin: 40px auto; /* Center horizontally and add space at top/bottom */
  position: relative;
  padding: 2rem;
  max-height: calc(100vh - 80px); /* Subtract margin from viewport height */
  overflow-y: auto; /* Make content scrollable if it's too long */
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  height: auto;
}

/* Modal Header */
.modal-header {
  margin: -2rem -2rem 2rem -2rem;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: -2rem;
  background: var(--white);
  z-index: 1;
  flex-shrink: 0;
}

/* Close Button */
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  color: var(--gray-600);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  z-index: 2;
}

.modal-close:hover {
  color: var(--gray-900);
}

/* Form Styling */
.modal form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Progress Container */
#uploadProgress,
#editUploadProgress {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: 8px;
  width: 100%;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .modal {
    padding: 10px;
  }

  .modal-content {
    width: 95%;
    margin: 20px auto;
    padding: 1.5rem;
    max-height: calc(100vh - 40px);
  }

  .modal-header {
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 1rem 1.5rem;
  }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

.modal-header h2 {
  margin: 0;
  color: var(--primary-dark);
}

.modal-body {
  margin-bottom: 20px;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.modal-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--gray-200);
  padding: 15px 20px;
  background: var(--white);
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-footer .progress-container {
  display: none;
  align-items: center;
  gap: 10px;
  margin-left: 10px;
}

.modal-footer .progress-container.active {
  display: flex;
}

.modal-footer progress {
  width: 200px;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
}

/* Progress bar styling */
progress::-webkit-progress-bar {
  background-color: var(--gray-200);
}

progress::-webkit-progress-value {
  background-color: var(--primary);
  transition: width 0.3s ease;
}

progress.error::-webkit-progress-value {
  background-color: var(--danger);
}

.modal-footer .btn-primary {
  min-width: 120px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
}

.progress-container {
  display: none;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.progress-container.active {
  display: block;
}

.progress-label {
  margin-bottom: 0.5rem;
  color: var(--gray-700);
}

progress {
  width: 100%;
  height: 20px;
  border-radius: 4px;
}

#editProgressText,
#progressText {
  display: inline-block;
  margin-left: 10px;
  color: var(--gray-600);
}
