.edit_post_modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
  box-sizing: border-box;
}

.modal_overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal_content {
  position: relative;
  background: white;
  border-radius: 10px;
  padding: 2rem;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin: 0;
  z-index: 1;
}

.edit-post-form {
    font-family: 'Arial', sans-serif;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.edit-post-form h2 {
    font-size: 1.75rem;
    font-weight: bold;
    text-align: center;
    color: #333;
    margin: 0 0 1rem 0;
}

.text-input, .textarea-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
}

.textarea-input {
    height: 200px;
    resize: vertical;
    min-height: 120px;
}

/* Labels */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  font-size: 0.95rem;
  color: #333;
}

/* Image upload section */
.image-upload-section {
  margin: 1rem 0;
}

.upload-box {
  border: 2px dashed #999;
  padding: 1.5rem;
  text-align: center;
  border-radius: 8px;
  background: #f9f9f9;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-box:hover {
  border-color: #3498db;
  background: #f0f8ff;
}

.upload-box.dragover {
  border-color: #3498db;
  background: #e3f2fd;
}

.upload-box input[type="file"] {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.upload-text {
  color: #666;
  font-size: 1rem;
  text-align: center;
}

.upload-text strong {
  color: #3498db;
}

.upload-text small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

/* Image preview */
#images-preview-container {
  display: none;
  margin-top: 1rem;
}

#images-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  max-height: 250px;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f9f9f9;
}

.image-preview-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  aspect-ratio: 1; /* Square aspect ratio */
  width: 100%;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .remove-image {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-item .remove-image:hover {
  background: rgba(255, 0, 0, 1);
}

/* Current images styling */
.current-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f9f9f9;
}

.current-image-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  aspect-ratio: 1; /* Square aspect ratio */
  width: 100%;
}

.current-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.current-image-item .remove-current-image {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.current-image-item .remove-current-image:hover {
  background: rgba(255, 0, 0, 1);
}

/* Button styles */
#buttons {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

/* Reset ALL button styles first */
#buttons button,
#buttons input[type="submit"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

/* Container for each button to ensure equal width */
#buttons .button-container {
  flex: 1;
  width: 50%;
}

.post-new-post {
  background-color: #009944;
  color: white;
}

.post-new-post:hover {
  background-color: #007a37;
  transform: translateY(-1px);
}

button.close-edit-modal {
  background-color: #900;
  color: white;
}

button.close-edit-modal:hover {
  background-color: #700;
  transform: translateY(-1px);
}

.delete-post-btn {
  padding: 0.75rem 1.5rem;
  background-color: #e53935;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 1rem;
}

.delete-post-btn:hover {
  background-color: #c62828;
  transform: translateY(-1px);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .edit_post_modal {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 1rem; /* Reduced from 2rem */
  }
  
  .modal_content {
    padding: 1rem; /* Reduced from 1.5rem */
    max-height: 85vh; /* Reduced from 95vh */
    width: 100%;
    max-width: none;
    border-radius: 8px;
  }
  
  .edit-post-form {
    gap: 0.8rem; /* Reduced from default 1.2rem */
  }
  
  .edit-post-form h2 {
    font-size: 1.4rem; /* Reduced from 1.5rem */
    margin-bottom: 0.5rem; /* Reduced margin */
  }
  
  .textarea-input {
    height: 120px; /* Reduced from 150px */
    min-height: 80px; /* Reduced from 100px */
  }
  
  /* Make images grid more compact */
  .current-images-grid,
  #images-preview {
    max-height: 150px; /* Reduced from default */
    padding: 0.5rem; /* Reduced padding */
  }
  
  #buttons {
    flex-direction: column;
    gap: 0.5rem; /* Reduced from 0.75rem */
    margin-top: 0.5rem; /* Reduced margin */
  }
  
  .post-new-post,
  button.close-edit-modal {
    width: 100%;
    min-width: auto;
    padding: 0.6rem 1rem; /* Reduced padding */
  }
  
  .delete-post-btn {
    margin-top: 0.5rem; /* Reduced margin */
    padding: 0.6rem 1rem; /* Reduced padding */
  }
}

@media (max-width: 480px) {
  .edit_post_modal {
    padding: 0.25rem;
    padding-top: 0.5rem; /* Reduced from 1rem */
  }
  
  .modal_content {
    padding: 0.75rem; /* Reduced from 1rem */
    max-height: 80vh; /* Further reduced */
  }
  
  .edit-post-form {
    gap: 0.6rem; /* Further reduced */
  }
  
  .edit-post-form h2 {
    font-size: 1.2rem; /* Reduced from 1.3rem */
    margin-bottom: 0.25rem;
  }
  
  .text-input,
  .textarea-input {
    padding: 0.5rem; /* Reduced from 0.6rem */
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .textarea-input {
    height: 100px; /* Further reduced */
    min-height: 80px;
  }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}
