/* Post Create Modal Styles */

.post-create-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
}

.post-create-modal .modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  padding: 40px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.post-create-modal .modal-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 800px;
  position: relative;
  animation: modalSlideIn 0.3s ease-out;
  margin: auto;
}

.post-create-modal .modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.post-create-modal .modal-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.post-create-modal .modal-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.post-create-modal .modal-close-btn {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.post-create-modal .modal-close-btn:hover {
  background: var(--background-light);
  color: var(--text);
}

/* Form Styles */

.post-create-form {
  padding: 0;
}

.form-sections {
  padding: 24px 32px;
  max-height: 70vh;
  overflow-y: auto;
}

.form-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.form-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section h3::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--primary-color);
  border-radius: 50%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group label {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: white;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
  border-color: var(--danger-color);
}

.form-group input.error:focus,
.form-group select.error:focus,
.form-group textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Image Upload Styles */

.image-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  transition: all 0.2s ease;
  background: var(--background-light);
}

.image-upload-area:hover {
  border-color: var(--primary-color);
  background: rgba(34, 197, 94, 0.05);
}

.upload-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 8px;
}

.upload-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.uploaded-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.uploaded-image {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--background-light);
  border: 2px solid var(--border-color);
}

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

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--danger-color);
  transition: all 0.2s ease;
}

.remove-image:hover {
  background: var(--danger-color);
  color: white;
}

.no-images {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px;
  background: var(--background-light);
  border-radius: 12px;
}

/* Form Actions */

.form-actions {
  padding: 20px 32px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: var(--background-light);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.form-actions .btn {
  min-width: 120px;
}

/* Error Messages */

.error-message {
  color: var(--danger-color);
  font-size: 14px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-message::before {
  content: "⚠️";
  font-size: 12px;
}

.general-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 16px;
  margin: 20px 32px;
  color: var(--danger-color);
}

.general-error::before {
  content: "❌";
  margin-right: 8px;
}

/* Loading Spinner */

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design */

@media (max-width: 768px) {
  .post-create-modal .modal-overlay {
    padding: 20px 10px;
  }

  .post-create-modal .modal-container {
    max-width: none;
    margin: 0;
  }

  .post-create-modal .modal-header {
    padding: 20px 24px;
  }

  .form-sections {
    padding: 20px 24px;
    max-height: 60vh;
  }

  .form-actions {
    padding: 16px 24px;
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .uploaded-images {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .post-create-modal .modal-overlay {
    padding: 10px;
  }

  .post-create-modal .modal-container {
    border-radius: 12px;
  }

  .form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
  }

  .form-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .image-upload-area {
    padding: 24px 16px;
  }
}

/* Custom Select Styling */

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

/* Focus within form section */

.form-section:focus-within h3::before {
  background: var(--primary-hover);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Quill.js WYSIWYG Editor Styles */

.quill-editor-section {
  flex: 1;
  padding-right: 20px;
}

.quill-editor-section h4 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.template-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  flex-wrap: wrap;
}

.template-btn {
  padding: 8px 12px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.template-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  color: #343a40;
  transform: translateY(-1px);
}

.template-btn:active {
  background: #dee2e6;
  transform: translateY(0px);
}

/* Quill editor customization */
.ql-toolbar {
  border: 1px solid #e9ecef !important;
  border-bottom: none !important;
  border-radius: 8px 8px 0 0 !important;
  background: #f8f9fa !important;
}

.ql-container {
  border: 1px solid #e9ecef !important;
  border-top: none !important;
  border-radius: 0 0 8px 8px !important;
  font-family: Inter, Arial, sans-serif !important;
}

.ql-editor {
  min-height: 250px;
  font-size: 14px;
  line-height: 1.6;
}

.ql-editor.ql-blank::before {
  color: #adb5bd;
  font-style: italic;
}

/* Custom styles for template content in Quill */
.ql-editor .funeral-info {
  background: #f8f9fa;
  padding: 15px;
  border-left: 4px solid #28a745;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
}

.ql-editor .family-section {
  background: #fff3cd;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
  border: 1px solid #ffeaa7;
}

.ql-editor .prayer-section {
  background: #d1ecf1;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
  text-align: center;
  font-style: italic;
  border: 1px solid #b8daff;
}

/* Preview container styles for template sections */
.preview-container .funeral-info {
  background: #f8f9fa;
  padding: 15px;
  border-left: 4px solid #28a745;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
}

.preview-container .family-section {
  background: #fff3cd;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
  border: 1px solid #ffeaa7;
}

.preview-container .prayer-section {
  background: #d1ecf1;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
  text-align: center;
  font-style: italic;
  border: 1px solid #b8daff;
}

.preview-container .family-section h4 {
  color: #856404;
  margin-bottom: 8px;
}

.preview-container .prayer-section p {
  margin: 8px 0;
}

.preview-container .prayer-section em {
  color: #0c5460;
}

/* Responsive adjustments for template toolbar */
@media (max-width: 768px) {
  .template-toolbar {
    flex-direction: column;
    gap: 6px;
  }

  .template-btn {
    width: 100%;
    justify-content: center;
  }

  .ql-toolbar {
    padding: 8px !important;
  }

  .ql-editor {
    min-height: 200px;
  }
}
