/*
 * Enhanced Drupal 11 Node Form Styles
 * Optimized for better visual hierarchy and usability
 */

/* ============================================
   1. OVERALL FORM CONTAINER
   ============================================ */
.node-form {
  max-width: 1000px;
  margin: 2rem auto;
  background: #ffffff;
  border: 1px solid #dce1e6;
  border-radius: 8px;
  padding: 2.5rem 3rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  line-height: 1.6;
}

/* Remove any background colors from form sections */
.node-form details,
.node-form .details-wrapper,
.node-form fieldset {
  background: transparent !important;
}

/* ============================================
   2. PAGE TITLE & SECTION HEADINGS
   ============================================ */
.node-form>h1,
.node-form .page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e2e8f0;
}

/* Hide specific section headings - RMS Cloud and Drupal Data */
.node-form details.field-group-details summary {
  display: none !important;
}

/* Hide "Show media item weights" button */
.node-form .tabledrag-toggle-weight-wrapper,
.node-form .tabledrag-toggle-weight,
.node-form button.link.tabledrag-toggle-weight {
  display: none !important;
}

/* Hide "The maximum number of media items have been selected" message */
.node-form .media-library-widget .messages,
.node-form .media-library-widget .messages--status,
.node-form .messages.messages--status,
.node-form .field--widget-media-library-widget .description,
.node-form .field--widget-media-library-widget+.description {
  display: none !important;
}

/* Hide "RICH TEXT EDITOR" label */
.node-form .js-form-type-text-format>label,
.node-form .filter-wrapper>label:first-child {
  display: none !important;
}

/* Hide "About text formats" link */
.node-form .filter-help,
.node-form .filter-wrapper .tips-link,
.node-form .text-format-wrapper a[href*="filter"],
.node-form a[href*="/filter/tips"] {
  display: none !important;
}

/* ============================================
   3. FORM FIELD GROUPS (details/summary)
   ============================================ */
.node-form details {
  border: none;
  border-radius: 0;
  margin-bottom: 1.5rem;
  background: transparent !important;
  transition: none;
  box-shadow: none;
}

.node-form details:hover {
  border-color: transparent;
  box-shadow: none;
}

.node-form details summary {
  font-size: 1.125rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  color: #2d3748;
  background: transparent !important;
  border-radius: 0;
  border: none;
  display: none;
}

.node-form details summary:hover {
  background: transparent !important;
}

.node-form details[open] summary {
  border-bottom: none;
  background: transparent !important;
}

.node-form details .details-wrapper {
  padding: 0;
  background: transparent !important;
}

/* ============================================
   4. FORM ITEMS & LABELS
   ============================================ */
.node-form .form-item {
  margin-bottom: 1.5rem;
  width: 100%;
}

.node-form .form-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.625rem;
  color: #2d3748;
  font-size: 0.9375rem;
  padding-left: 0.5rem;
}

.node-form .form-required {
  color: #e53e3e;
  margin-left: 0.25rem;
}

/* Help text / Description */
.node-form .description {
  font-size: 0.875rem;
  color: #718096;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ============================================
   5. TEXT INPUTS & TEXTAREAS
   ============================================ */
.node-form .form-text,
.node-form input[type="text"],
.node-form input[type="email"],
.node-form input[type="url"],
.node-form input[type="number"],
.node-form input[type="tel"],
.node-form textarea {
  width: 100%;
  max-width: 700px;
  padding: 0.625rem 0.875rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.9375rem;
  line-height: 1.5;
  transition: all 0.2s ease;
  box-sizing: border-box;
  margin-left: 0.5rem;
}

.node-form .form-text:focus,
.node-form input[type="text"]:focus,
.node-form input[type="email"]:focus,
.node-form input[type="url"]:focus,
.node-form input[type="number"]:focus,
.node-form input[type="tel"]:focus,
.node-form textarea:focus {
  border-color: #4299e1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
  background: #ffffff;
}

.node-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* ============================================
   6. SELECT DROPDOWNS
   ============================================ */
.node-form select {
  width: 100%;
  max-width: 700px;
  padding: 0.625rem 0.875rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background-color: #ffffff;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.node-form select:focus {
  border-color: #4299e1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* ============================================
   7. CHECKBOXES
   ============================================ */
.node-form .form-item.form-type-checkbox {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  margin-bottom: 1rem !important;
  text-align: left !important;
  vertical-align: top !important;
}

.node-form .form-item.form-type-checkbox input[type="checkbox"] {
  order: 1 !important;
  width: 18px !important;
  height: 18px !important;
  margin: 2px 0.625rem 0 0 !important;
  cursor: pointer;
  flex-shrink: 0 !important;
  float: none !important;
  display: inline-block !important;
  vertical-align: top !important;
}

.node-form .form-item.form-type-checkbox label {
  order: 2 !important;
  display: inline-block !important;
  margin: 0 !important;
  padding: 0 !important;
  font-weight: 500 !important;
  font-size: 0.9375rem;
  cursor: pointer;
  white-space: nowrap !important;
  text-align: left !important;
  float: none !important;
  line-height: 1.4 !important;
  vertical-align: top !important;
}

/* Checkbox Groups - Horizontal Layout (Left-Aligned, Properly Aligned) */
.node-form .form-checkboxes,
.node-form .field--widget-options-buttons .details-wrapper,
.node-form details .form-checkboxes {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 0.75rem 2.5rem !important;
  margin-top: 0.5rem;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  text-align: left !important;
  max-width: 100%;
  overflow: visible;
}

.node-form .form-checkboxes .form-item.form-type-checkbox,
.node-form .field--widget-options-buttons .details-wrapper .form-item.form-type-checkbox,
.node-form details .form-checkboxes .form-item.form-type-checkbox {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
  min-width: auto !important;
  width: auto !important;
  max-width: none !important;
  text-align: left !important;
  vertical-align: top !important;
}

.node-form .form-checkboxes .form-item.form-type-checkbox label,
.node-form .field--widget-options-buttons .details-wrapper .form-item.form-type-checkbox label,
.node-form details .form-checkboxes .form-item.form-type-checkbox label {
  white-space: nowrap !important;
  display: inline-block !important;
  width: auto !important;
  max-width: none !important;
  text-align: left !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
  line-height: 1.4 !important;
  vertical-align: top !important;
}

.node-form .form-checkboxes .form-item.form-type-checkbox input[type="checkbox"],
.node-form .field--widget-options-buttons .details-wrapper .form-item.form-type-checkbox input[type="checkbox"],
.node-form details .form-checkboxes .form-item.form-type-checkbox input[type="checkbox"] {
  flex-shrink: 0 !important;
  margin: 2px 0.625rem 0 0 !important;
  float: none !important;
  display: inline-block !important;
  vertical-align: top !important;
}

/* ============================================
   8. MEDIA LIBRARY WIDGET
   ============================================ */
/* Keep the field labels visible for Profile Image and Images */
.node-form .field--widget-media-library-widget>label {
  display: block !important;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #2d3748;
  font-size: 0.9375rem;
  padding-left: 0;
}

/* Force 2-column grid for media items */
.node-form .field--widget-media-library-widget .details-wrapper>div,
.node-form .js-media-library-selection,
.node-form .media-library-selection {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 1.25rem !important;
  margin-bottom: 1rem;
}

/* Ensure each media item takes full width of its grid cell */
.node-form .media-library-item,
.node-form .media-library-item__preview,
.node-form .js-media-library-item {
  width: 100% !important;
  max-width: 100% !important;
}

/* Responsive: Single column on mobile */
@media (max-width: 640px) {

  .node-form .field--widget-media-library-widget .details-wrapper>div,
  .node-form .js-media-library-selection,
  .node-form .media-library-selection {
    grid-template-columns: 1fr !important;
  }
}

/* Media Library Items */
.node-form .media-library-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.node-form .media-library-item:hover {
  border-color: #cbd5e0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.node-form .media-library-item__preview {
  border-radius: 6px;
  overflow: hidden;
  width: 100%;
  height: 120px;
  margin-bottom: 0.75rem;
  background: #f7fafc;
  order: 1;
}

.node-form .media-library-item__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.node-form .media-library-item__name {
  font-size: 0.8125rem;
  color: #4a5568;
  margin-bottom: 0.75rem;
  word-break: break-word;
  line-height: 1.4;
  order: 2;
}

.node-form .js-media-library-widget-toggle-weight {
  display: none !important;
}

/* Move Remove button below using CSS Grid on parent container */
.node-form .js-media-library-item,
.node-form .media-library-item-wrapper {
  display: grid !important;
  grid-template-areas:
    "preview"
    "name"
    "remove" !important;
}

.node-form .js-media-library-item .media-library-item__preview {
  grid-area: preview !important;
}

.node-form .js-media-library-item .media-library-item__name {
  grid-area: name !important;
}

.node-form .media-library-item__remove-button,
.node-form .media-library-item__remove,
.node-form .js-media-library-item .media-library-item__remove-button,
.node-form .js-media-library-item .media-library-item__remove {
  background: transparent !important;
  color: #e53e3e !important;
  border: 1px solid #fc8181 !important;
  border-radius: 4px !important;
  font-size: 0.75rem !important;
  padding: 0.375rem 0.75rem !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  text-transform: uppercase !important;
  font-weight: 600 !important;
  letter-spacing: 0.025em !important;
  grid-area: remove !important;
  justify-self: start !important;
  order: 3 !important;
  margin-top: 0 !important;
  width: auto !important;
  display: inline-block !important;
  position: static !important;
}

.node-form .media-library-item__remove-button:hover,
.node-form .media-library-item__remove:hover {
  background: #e53e3e !important;
  color: #ffffff !important;
  border-color: #e53e3e !important;
}

/* Add Media Button */
.node-form .js-media-library-add-button,
.node-form .media-library-add-button {
  background: #ebf8ff;
  border: 2px dashed #90cdf4;
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  color: #2b6cb0;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  width: 100%;
}

.node-form .js-media-library-add-button:hover,
.node-form .media-library-add-button:hover {
  background: #bee3f8;
  border-color: #4299e1;
  color: #2c5282;
}

/* ============================================
   9. WYSIWYG / CKEditor
   ============================================ */
/* Hide the toolbar label "RICH TEXT EDITOR" */
.node-form .js-form-type-text-format>.fieldset-wrapper>label:first-child,
.node-form .text-format-wrapper>label:first-child,
.node-form .form-item--cancellation-policy .fieldset-wrapper>.form-item>label:first-child {
  display: none !important;
}

.node-form .cke_chrome {
  width: 100% !important;
  max-width: 700px !important;
  border-radius: 6px !important;
  border: 1px solid #cbd5e0 !important;
  box-sizing: border-box;
}

.node-form .form-item .cke_chrome {
  margin-top: 0.5rem;
}

/* ============================================
   10. FORM ACTIONS (Save Button)
   ============================================ */
.node-form .form-actions {
  border-top: 1px solid #e2e8f0;
  padding-top: 1.75rem;
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.node-form .button--primary,
.node-form input[type="submit"].button--primary {
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
  border: none;
  color: #ffffff;
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.node-form .button--primary:hover,
.node-form input[type="submit"].button--primary:hover {
  background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
}

.node-form .button--primary:active,
.node-form input[type="submit"].button--primary:active {
  transform: translateY(0);
}

/* Secondary Buttons */
.node-form .button:not(.button--primary) {
  background: #4f98e0;
  border: 1px solid #cbd5e0;
  color: #FFF !important;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.node-form .button:not(.button--primary):hover {
  background: #4f98e0;
  border-color: #a0aec0;
}

/* ============================================
   11. RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
  .node-form {
    padding: 1.5rem;
    margin: 1rem;
  }

  .node-form>h1,
  .node-form .page-title {
    font-size: 1.5rem;
  }

  .node-form details summary {
    font-size: 1rem;
    padding: 0.875rem 1rem;
  }

  .node-form .form-actions {
    flex-direction: column-reverse;
  }

  .node-form .form-actions .button {
    width: 100%;
  }
}

/* ============================================
   12. ACCESSIBILITY IMPROVEMENTS
   ============================================ */
.node-form *:focus-visible {
  outline: 2px solid #4299e1;
  outline-offset: 2px;
}

.node-form .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================
   13. ERROR STATES
   ============================================ */
.node-form .form-item.error input,
.node-form .form-item.error textarea,
.node-form .form-item.error select {
  border-color: #fc8181;
  background: #fff5f5;
}

.node-form .form-item.error label {
  color: #c53030;
}

.node-form .form-item .error-message {
  color: #c53030;
  font-size: 0.875rem;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
