/* ─────────────────────────────────────────
   OVERLAY CONTAINER
   ───────────────────────────────────────── */
#new-post-modal {
  position: fixed;             /* stick to viewport               */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;               /* above everything else           */
  display: flex;               /* flex-box centering              */
  align-items: center;         /* vertical center                 */
  justify-content: center;     /* horizontal center               */
  background: rgba(0, 0, 0, .4); /* translucent dark backdrop     */
  padding: 1rem;               /* Add padding for mobile         */
  box-sizing: border-box;
}

/* ─────────────────────────────────────────
   FORM BOX
   ───────────────────────────────────────── */
.new-post-form {
  font-family: Arial, sans-serif;
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0,0,0,.2);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  
  /* Remove margin since centering is handled by parent */
  margin: 0;
  
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  
  /* Ensure it doesn't exceed viewport */
  position: relative;
}

/* ─────────────────────────────────────────
   FORM HEADER
   ───────────────────────────────────────── */
.new-post-form h2 {
  margin: 0 0 1rem 0;
  font-size: 1.75rem;
  text-align: center;
  color: #333;
}

/* ─────────────────────────────────────────
   MULTIPLE IMAGES 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);
}

.image-preview-item img {
  width: 100%;
  height: 100px;
  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);
}

.images-count {
  font-size: 0.9rem;
  color: #666;
  margin-top: 0.5rem;
  text-align: center;
}

/* ─────────────────────────────────────────
   DRAG-AND-DROP / FILE CHOOSER
   ───────────────────────────────────────── */
.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;
}

/* ─────────────────────────────────────────
   TEXT + TEXTAREA INPUTS
   ───────────────────────────────────────── */
.text-input,
.textarea-input,
.textarea-input-large {
  width: 100%;
  padding: .75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  box-sizing: border-box;
  font-family: inherit;
}

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

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

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

/* ─────────────────────────────────────────
   BUTTON BAR
   ───────────────────────────────────────── */
#buttons {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.post-new-post,
button.close-new-post {
  padding: .75rem 1.5rem;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  flex: 1;
}

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

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

button.close-new-post { 
  background: #900; 
  color: #fff; 
}

button.close-new-post:hover {
  background: #700;
  transform: translateY(-1px);
}

/* ─────────────────────────────────────────
   MOBILE RESPONSIVE STYLES
   ───────────────────────────────────────── */
@media (max-width: 768px) {
  #new-post-modal {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 1rem; /* Reduced from 2rem */
  }
  
  .new-post-form {
    padding: 1rem; /* Reduced from 1.5rem */
    max-height: 85vh; /* Reduced from 95vh */
    width: 100%;
    max-width: none;
    border-radius: 8px;
    gap: 0.8rem; /* Reduced from 1.2rem */
  }
  
  .new-post-form h2 {
    font-size: 1.4rem; /* Reduced from 1.5rem */
    margin-bottom: 0.5rem; /* Reduced from 1rem */
  }
  
  .upload-box {
    padding: 0.75rem; /* Reduced from 1rem */
    min-height: 50px; /* Reduced from 60px */
  }
  
  .upload-text {
    font-size: 0.85rem; /* Reduced from 0.9rem */
  }
  
  .upload-text small {
    font-size: 0.75rem; /* Reduced from 0.8rem */
  }
  
  #images-preview {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Smaller grid */
    gap: 0.4rem; /* Reduced from 0.5rem */
    max-height: 120px; /* Reduced from 200px */
    padding: 0.5rem; /* Reduced from 0.75rem */
  }
  
  .image-preview-item img {
    height: 60px; /* Reduced from 80px */
  }
  
  .image-preview-item .remove-image {
    width: 18px; /* Reduced from 20px */
    height: 18px;
    font-size: 10px; /* Reduced from 11px */
  }
  
  .textarea-input-large {
    height: 120px; /* Reduced from 150px */
    min-height: 80px; /* Reduced from 100px */
  }
  
  #buttons {
    flex-direction: column;
    gap: 0.5rem; /* Reduced from 0.75rem */
    margin-top: 0.5rem;
  }
  
  .post-new-post,
  button.close-new-post {
    padding: 0.6rem 1rem; /* Reduced padding */
    font-size: 0.9rem; /* Reduced from 0.95rem */
    min-width: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  #new-post-modal {
    padding: 0.25rem;
    padding-top: 0.5rem; /* Reduced from 1rem */
  }
  
  .new-post-form {
    padding: 0.75rem; /* Reduced from 1rem */
    gap: 0.6rem; /* Reduced from 1rem */
    max-height: 80vh; /* Further reduced */
  }
  
  .new-post-form h2 {
    font-size: 1.2rem; /* Reduced from 1.3rem */
    margin-bottom: 0.25rem;
  }
  
  .text-input,
  .textarea-input,
  .textarea-input-large {
    padding: 0.5rem; /* Reduced from 0.6rem */
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .textarea-input-large {
    height: 100px; /* Further reduced */
  }
  
  label {
    font-size: 0.85rem; /* Reduced from 0.9rem */
    margin-bottom: 0.25rem; /* Reduced margin */
  }
  
  .upload-box {
    padding: 0.5rem; /* Reduced from 0.75rem */
    min-height: 40px;
  }
  
  .upload-text {
    font-size: 0.8rem; /* Reduced from 0.85rem */
  }
  
  #images-preview {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); /* Even smaller */
    max-height: 100px; /* Further reduced */
  }
  
  .image-preview-item img {
    height: 50px; /* Reduced from 60px */
  }
}

/* ─────────────────────────────────────────
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ───────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices */
  .upload-box {
    min-height: 100px;
  }
  
  .post-new-post,
  button.close-new-post {
    min-height: 48px; /* Minimum touch target size */
  }
  
  .image-preview-item .remove-image {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}

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