/* ========================================
   UTILITY CLASSES
   Replaces common inline styles
   ======================================== */

/* Display */
.hidden { display: none !important; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Flex utilities */
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-center-sm { display: flex; align-items: center; gap: var(--space-sm); }
.flex-center-md { display: flex; align-items: center; gap: var(--space-md); }

/* Gap */
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Grid */
.grid-full { grid-column: 1 / -1; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-md); }
.card-grid-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-md); }

/* Margin */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.ml-xs { margin-left: var(--space-xs); }

/* Padding */
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Text */
.text-center { text-align: center; }
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-muted { color: var(--color-gray); }
.text-dark { color: var(--color-dark); }
.text-primary { color: var(--color-dark); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.no-decoration { text-decoration: none; }

/* Common combos */
.desc-text { font-size: var(--font-size-sm); color: var(--color-gray); }
.section-heading { font-size: var(--font-size-base); font-weight: 600; margin-bottom: var(--space-sm); color: var(--color-dark); }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Misc */
.w-full { width: 100%; }
.overflow-auto { overflow: auto; }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-sm); }
.stack-md { display: flex; flex-direction: column; gap: var(--space-md); }

/* JS-generated element helpers */
.loading-text { text-align: center; color: var(--color-gray); }
.error-text { color: red; }
.empty-state { padding: var(--space-xl); text-align: center; }
.badge--inline { font-size: 0.65rem; padding: 1px 6px; }
.badge--type-sm { font-size: 0.7rem; padding: 2px 6px; margin-right: 6px; }
.thumb-img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-md); opacity: 0; transition: opacity 0.3s ease; }
.thumb-img.lazy-loaded { opacity: 1; }
.poster-link { color: var(--color-dark); text-decoration: none; font-size: 0.75rem; }

/* Global focus-visible indicator for keyboard users */
a:focus-visible,
button:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--color-dark);
  outline-offset: 2px;
}
.sub-badge-static { position: static; }
.search-bar--inline { max-width: 300px; margin: 0; }
.btn--ml-auto { margin-left: auto; }
.card--no-pad { padding: 0; }
.formula-parent--sm { padding: 2px 6px; font-size: 0.75rem; }
.formula-operator--sm { font-size: 0.875rem; }
.whitespace-nowrap { white-space: nowrap; }
.max-w-600 { max-width: 600px; }
.max-w-400 { max-width: 400px; }
.max-w-200 { max-width: 200px; }
.text-danger-border { color: #dc3545; border: 1px solid #dc3545; background: transparent; }
.font-xs-btn { font-size: 0.8rem; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.ml-xs { margin-left: var(--space-xs); }
.mb-0 { margin-bottom: 0; }
.mx-auto { margin-left: auto; margin-right: auto; }
.flex-shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.word-break-all { word-break: break-word; white-space: normal; }
.text-inherit { color: inherit; }

/* Mobile nav divider */
.mobile-nav__divider { border-top: 1px solid var(--color-light); padding-top: var(--space-sm); }

/* Section border-top separator */
.section-separator { padding-top: var(--space-lg); border-top: 1px solid var(--color-light); }

/* Login benefits card */
.login-benefits-bg { background: linear-gradient(135deg, #e8f5e9, #f1f8e9); border: 1px solid #c8e6c9; }

/* Cultivar detail title */
.detail-title { font-size: var(--font-size-2xl); margin-bottom: var(--space-xs); }

/* Edit key input compact */
.edit-key-input { width: 100px; padding: 4px 8px; font-size: 0.85rem; }

/* Share menu popup */
.share-menu-popup { position: absolute; z-index: 50; background: var(--color-white); border: 1px solid var(--color-light); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: var(--space-sm); display: flex; gap: var(--space-sm); }

/* Admin footer link */
.admin-link { opacity: 0.3; font-size: 0.7rem; text-decoration: none; color: inherit; margin-left: 8px; }

/* Delete request dialog */
.dialog-clean { border: none; border-radius: 12px; padding: 24px; max-width: 400px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.dialog-title { margin: 0 0 8px 0; font-size: 1.1rem; }
.dialog-subtitle { margin: 0 0 16px 0; font-size: 0.9rem; color: #666; }
.dialog-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dialog-textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.9rem; margin-bottom: 16px; resize: vertical; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn--danger { background: #dc3545; color: #fff; border: none; }

/* Favorite remove button (star overlay) */
.fav-remove-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.9); border: none; border-radius: 50%; width: 28px; height: 28px; font-size: 1.1rem; color: #f5c518; cursor: pointer; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }

/* Photo preview (contribution form) */
.photo-preview { position: relative; display: inline-block; }
.photo-preview__img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 2px solid var(--color-light); cursor: pointer; }
.photo-preview__remove { position: absolute; top: -6px; right: -6px; background: #dc3545; color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; cursor: pointer; line-height: 1; padding: 0; }

/* Avatar sizes */
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder-sm { width: 40px; height: 40px; border-radius: 50%; background: var(--color-lighter); display: flex; align-items: center; justify-content: center; color: var(--color-gray); font-size: 18px; }

/* User list item (search results) */
.user-list-item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--color-lighter); text-decoration: none; color: inherit; cursor: pointer; }

/* Parent photo in origin */
.parent-photo { width: 60px; height: 60px; }
.parent-photo-placeholder { width: 60px; height: 60px; border-radius: var(--radius-md); border: 2px dashed var(--color-light); display: flex; align-items: center; justify-content: center; color: var(--color-gray); font-size: 0.65rem; }

/* Origin tier badge */
.tier-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; color: #fff; }

/* Variation detail collapsible */
.variation-detail { margin-top: 8px; }
.variation-summary { margin-bottom: 8px; font-style: italic; }

/* Formula box parent display */
.formula-parent-display { display: inline-block; word-break: break-word; white-space: normal; max-width: 100%; }

/* Card image container */
.card-img-container { height: 160px; overflow: hidden; border-radius: var(--radius-md) var(--radius-md) 0 0; }
.card-img-cover { width: 100%; height: 100%; object-fit: cover; }

/* Username input with prefix/suffix icons */
.input-with-icons { position: relative; }
.input-icon-left { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--color-gray); font-size: 14px; }
.input-icon-right { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; }

/* Required indicator */
.text-required { color: #dc3545; }

/* Disabled input */
.form-input--disabled { background: var(--color-lighter); cursor: not-allowed; }

/* Duplicate alert */
.duplicate-alert { background: var(--color-lighter); border: 2px solid var(--color-dark); border-radius: var(--radius-md); }

/* Log box (admin bulk operations) */
.log-box {
  max-height: 300px;
  overflow-y: auto;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  margin-top: var(--space-sm);
  background: var(--color-bg);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-light);
}

.tab-btn {
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  color: var(--color-mid);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin-bottom: -2px;
  opacity: 0.6;
  transition: var(--transition);
}

.tab-btn.active {
  border-bottom: 2px solid var(--color-primary);
  font-weight: 600;
  color: var(--color-dark);
  opacity: 1;
}

/* Admin service card */
.svc-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.svc-card-desc {
  font-size: var(--font-size-sm);
  color: var(--color-gray);
  margin-bottom: var(--space-md);
}

.svc-card-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.btn-link {
  text-align: center;
  text-decoration: none;
}

/* Inline form error messages */
.field-error {
  color: var(--color-danger);
  font-size: var(--font-size-xs);
  margin-top: 4px;
  display: none;
}
.field-error.visible { display: block; }
.form-input--invalid,
.form-textarea--invalid {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}

/* ========================================
   SEEDLING MOSAIC / LOCK OVERLAY
   ======================================== */
.seedling-mosaic {
  filter: blur(10px) saturate(0.5);
  -webkit-filter: blur(10px) saturate(0.5);
  pointer-events: none;
  user-select: none;
}
.card--seedling-locked {
  position: relative;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.seedling-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(242, 245, 244, 0.7);
  color: var(--color-dark);
  font-size: var(--font-size-xs);
  font-weight: 600;
  z-index: 2;
  backdrop-filter: blur(2px);
}
.seedling-lock-overlay svg {
  opacity: 0.9;
}

/* Card placeholder (no-image) same height as card-img-container */
.recent-card__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-lighter);
}

/* PWA install banner */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-white);
  border-top: 1px solid var(--color-light);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.pwa-install-banner--visible { transform: translateY(0); }
.pwa-install-banner__text { flex: 1; font-size: var(--font-size-sm); }
.pwa-install-banner__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-gray);
  padding: 0 4px;
  line-height: 1;
}
