/**
 * @file
 * Administration coexistence and contextual links support for Wares Point Theme.
 * Ensures the Drupal Admin Toolbar and editorial tools operate smoothly without collision.
 */

/* Contextual links container */
.contextual-region {
  position: relative;
}

/* Ensure contextual links remain hidden by default until triggered */
.contextual-links:not(.open .contextual-links) {
  display: none;
}

.contextual.open .contextual-links {
  display: block !important;
}

/* Ensure admin toolbar is not hidden behind theme headers */
body.toolbar-fixed .site-header {
  top: auto;
}

/* Dropbuttons (e.g. node operation buttons Edit/Delete in tables or views) */
.dropbutton-wrapper {
  display: inline-block;
  vertical-align: middle;
}

.dropbutton-widget {
  background-color: var(--wp-white);
  border: 1px solid var(--wp-border-soft);
  border-radius: var(--wp-radius-sm);
}

.dropbutton a {
  color: var(--wp-brown-deep);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
}

.dropbutton a:hover {
  background-color: var(--wp-cream-light);
}

/* Action links (e.g. "+ Add content" on admin-accessible listings) */
.action-links {
  list-style: none;
  padding: 0;
  margin: var(--wp-space-md) 0 var(--wp-space-lg);
  display: flex;
  gap: var(--wp-space-sm);
}

.action-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--wp-space-xs);
  padding: 0.5rem 1rem;
  background-color: var(--wp-sand-primary);
  color: var(--wp-brown-deep);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--wp-radius-sm);
  text-decoration: none;
  transition: all var(--wp-transition-fast);
}

.action-links a::before {
  content: "+";
  font-weight: 700;
}

.action-links a:hover {
  background-color: var(--wp-tan-dark);
  color: var(--wp-white);
}

/* ==========================================================================
   Node Preview Bar & View Mode Controls
   ========================================================================== */

.node-preview-container {
  position: sticky !important;
  top: var(--drupal-displace-offset-top, 0) !important;
  z-index: 500 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background-color: var(--wp-cream-light, #FFF2E0) !important;
  border-bottom: 2px solid var(--wp-sand-primary, #C8A97E) !important;
  box-shadow: 0 4px 16px rgba(137, 100, 50, 0.16) !important;
  padding: 0.65rem 1.5rem !important;
  margin: 0 !important;
  transition: top var(--wp-transition-fast, 0.2s ease) !important;
}

/* Ensure proper offset when Admin Toolbar is fixed */
body.toolbar-horizontal.toolbar-fixed .node-preview-container {
  top: var(--drupal-displace-offset-top, 39px) !important;
}

body.toolbar-horizontal.toolbar-fixed.toolbar-tray-open .node-preview-container {
  top: var(--drupal-displace-offset-top, 79px) !important;
}

/* Form layout inside the preview container */
.node-preview-form-select {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 0.75rem 1.5rem !important;
  width: 100% !important;
  max-width: var(--wp-selected-width, 1280px) !important;
  margin: 0 auto !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

/* Back to content editing link - styled as a prominent button */
.node-preview-backlink,
.node-preview-backlink-btn,
.node-preview-form-select a.node-preview-backlink,
.node-preview-form-select a.node-preview-backlink-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 0.5rem 1.15rem !important;
  background-color: var(--wp-white, #FFFFFF) !important;
  color: var(--wp-brown-deep, #896432) !important;
  border: 1.5px solid var(--wp-sand-primary, #C8A97E) !important;
  border-radius: var(--wp-radius-sm, 6px) !important;
  font-family: var(--wp-font-ui, var(--wp-font-body)) !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all var(--wp-transition-fast, 0.2s ease) !important;
  box-shadow: 0 1px 3px rgba(137, 100, 50, 0.08) !important;
  margin: 0 !important;
}

.node-preview-backlink::before {
  content: "←";
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
  transition: transform var(--wp-transition-fast, 0.2s ease);
}

.node-preview-backlink:hover,
.node-preview-backlink-btn:hover,
.node-preview-form-select a.node-preview-backlink:hover,
.node-preview-form-select a.node-preview-backlink-btn:hover {
  background-color: var(--wp-sand-primary, #C8A97E) !important;
  color: var(--wp-white, #FFFFFF) !important;
  border-color: var(--wp-tan-dark, #A88554) !important;
  box-shadow: 0 2px 8px rgba(137, 100, 50, 0.25) !important;
  text-decoration: none !important;
}

.node-preview-backlink:hover::before,
.node-preview-backlink-btn:hover::before {
  transform: translateX(-3px);
}

.node-preview-backlink:focus-visible,
.node-preview-backlink-btn:focus-visible {
  outline: 2px solid var(--wp-brown-deep, #896432) !important;
  outline-offset: 2px !important;
}

/* Informative preview pill badge */
.node-preview-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  font-family: var(--wp-font-ui, var(--wp-font-body)) !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  color: var(--wp-brown-deep, #896432) !important;
  background-color: var(--wp-beige-light, #EED6B5) !important;
  border: 1px solid var(--wp-sand-primary, #C8A97E) !important;
  border-radius: 9999px !important;
  padding: 0.35rem 0.85rem !important;
  letter-spacing: 0.02em !important;
}

.node-preview-pill::before {
  content: "📝";
  font-size: 0.95rem;
}

/* Right-hand side View mode wrapper */
.node-preview-form-select .form-item,
.node-preview-form-select .form-item-view-mode,
.node-preview-form-select .js-form-item-view-mode {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.65rem !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* View mode label */
.node-preview-form-select label,
.node-preview-form-select .form-item label {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  margin: 0 !important;
  padding: 0 !important;
  font-family: var(--wp-font-ui, var(--wp-font-body)) !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  color: var(--wp-brown-deep, #896432) !important;
  white-space: nowrap !important;
  cursor: pointer !important;
}

.node-preview-form-select label::before {
  content: "👁";
  font-size: 0.95rem;
}

/* View mode select element */
.node-preview-form-select select,
.node-preview-form-select .form-select {
  display: inline-block !important;
  width: auto !important;
  min-width: 130px !important;
  max-width: 200px !important;
  padding: 0.45rem 2.25rem 0.45rem 0.9rem !important;
  margin: 0 !important;
  background-color: var(--wp-white, #FFFFFF) !important;
  border: 1.5px solid var(--wp-sand-primary, #C8A97E) !important;
  border-radius: var(--wp-radius-sm, 6px) !important;
  color: var(--wp-text, #24211E) !important;
  font-family: var(--wp-font-ui, var(--wp-font-body)) !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  cursor: pointer !important;
  box-shadow: 0 1px 3px rgba(137, 100, 50, 0.08) !important;
  transition: all var(--wp-transition-fast, 0.2s ease) !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23896432' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 0.85rem !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

.node-preview-form-select select:hover,
.node-preview-form-select .form-select:hover {
  border-color: var(--wp-tan-dark, #A88554) !important;
  box-shadow: 0 2px 6px rgba(137, 100, 50, 0.18) !important;
}

.node-preview-form-select select:focus,
.node-preview-form-select .form-select:focus {
  outline: none !important;
  border-color: var(--wp-brown-deep, #896432) !important;
  box-shadow: 0 0 0 3px rgba(200, 169, 126, 0.35) !important;
}

/* Hidden submit button (handled automatically via autosubmit) */
.node-preview-container .js-hide,
.node-preview-form-select input[type="submit"] {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .node-preview-container {
    padding: 0.5rem 1rem !important;
  }

  .node-preview-form-select {
    gap: 0.5rem 1rem !important;
    justify-content: space-between !important;
  }

  .node-preview-pill {
    order: 3;
    width: 100%;
    justify-content: center;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.6rem !important;
  }
}

@media (max-width: 480px) {
  .node-preview-backlink,
  .node-preview-form-select a.node-preview-backlink {
    font-size: 0.8125rem !important;
    padding: 0.4rem 0.75rem !important;
  }

  .node-preview-form-select .form-item-view-mode {
    gap: 0.4rem !important;
  }

  .node-preview-form-select select,
  .node-preview-form-select .form-select {
    min-width: 100px !important;
    max-width: 130px !important;
    font-size: 0.8125rem !important;
    padding: 0.4rem 1.8rem 0.4rem 0.65rem !important;
  }
}

