/* Field Cards Styling */
/* Scoped to Fields tab only (#fields-content) to prevent affecting other tabs */

#fields-content .field-cards-container {
  width: 100%;
  margin-top: 20px;
}

/* Category Headers - Compact spacing */
#fields-content .field-category-section {
  margin-bottom: 20px;
}

#fields-content .field-category-section:last-child {
  margin-bottom: 0;
}

/* Field Card - Accordion Layout */
#fields-content .field-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
  overflow: visible;
  position: relative;
  z-index: 1;
}

#fields-content .field-card:hover,
#fields-content .field-card.has-open-menu {
  z-index: 2001;
}

#fields-content .field-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-color: #007bff;
}

#fields-content .field-card.expanded {
  border-color: #007bff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#fields-content .field-card:last-child {
  margin-bottom: 0;
}

/* Card Header - Collapsed View (clickable) */
#fields-content .field-card-header {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 60px;
  user-select: none;
  overflow: visible;
  position: relative;
}

#fields-content .field-card-header:hover {
  background: #f8f9fa;
}

#fields-content .field-card.expanded .field-card-header {
  background: #f0f7ff;
  border-bottom: 1px solid #e0e0e0;
}

/* Card Main Content - Name and Primary Info */
#fields-content .field-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Card Name - Prominent */
#fields-content .field-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #007bff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Meta Info Line - Type + Model */
#fields-content .field-card-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 0.875rem;
  color: #6c757d;
  flex-wrap: wrap;
}

#fields-content .field-card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

#fields-content .field-card-meta-label {
  font-weight: 600;
  color: #495057;
}

#fields-content .field-card-meta-value {
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Description Preview - Truncated to 2 lines */
#fields-content .field-card-description-preview {
  margin-top: 6px;
  font-size: 0.875rem;
  color: #6c757d;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Gear Actions Section */
#fields-content .field-actions {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible;
  z-index: 2000;
}

#fields-content .gear-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: #666;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#fields-content .gear-btn:hover {
  background: #f5f5f5;
  color: #007bff;
  border-color: #007bff;
}

#fields-content .gear-btn.active {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

/* Expand/Collapse Icon */
#fields-content .field-card-expand-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f0f0f0;
  color: #495057;
  transition: all 0.2s ease;
  margin-top: 2px;
}

#fields-content .field-card-expand-icon i {
  transition: transform 0.3s ease;
}

#fields-content .field-card.expanded .field-card-expand-icon i {
  transform: rotate(180deg);
}

#fields-content .field-card-header:hover .field-card-expand-icon {
  background: #007bff;
  color: white;
}

/* Generators Menu Dropdown */
#fields-content .generators-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 280px;
  max-width: 320px;
  z-index: 2000;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

#fields-content .generators-menu.show {
  display: block;
}

#fields-content .generators-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  font-weight: 600;
  color: #495057;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#fields-content .generator-group {
  border-bottom: 1px solid #e0e0e0;
}

#fields-content .generator-group:last-child {
  border-bottom: none;
}

#fields-content .generator-group-label {
  padding: 10px 16px;
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.875rem;
  color: #6c757d;
  border-bottom: 1px solid #e0e0e0;
}

#fields-content .generator-option {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  color: #495057;
  font-size: 0.875rem;
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
}

#fields-content .generator-option:hover {
  background: #e9ecef;
  color: #007bff;
}

#fields-content .generator-option:active {
  background: #dee2e6;
}

/* Card Body - Expanded View */
#fields-content .field-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 16px;
}

#fields-content .field-card.expanded .field-card-body {
  max-height: 5000px;
  overflow: hidden;
  padding: 16px;
  transition: max-height 0.5s ease, padding 0.3s ease;
}

/* Field Info Grid - Compact spacing */
#fields-content .field-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  overflow: visible;
}

#fields-content .field-info-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}

#fields-content .field-info-item.full-width {
  grid-column: 1 / -1;
}

#fields-content .field-info-item label {
  font-weight: 600;
  color: #6c757d;
  font-size: 0.75rem;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#fields-content .field-info-item .value {
  color: #2c3e50;
  font-size: 0.875rem;
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: visible;
  white-space: normal;
}

#fields-content .field-info-item .value.empty {
  color: #adb5bd;
  font-style: italic;
}

/* Links in field values */
#fields-content .field-info-item .value a {
  color: #007bff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

#fields-content .field-info-item .value a:hover {
  border-bottom-color: #007bff;
}

/* Expandable Text (for descriptions) */
#fields-content .expandable-text {
  position: relative;
}

#fields-content .expandable-text .text-content {
  display: block;
  color: #2c3e50;
  line-height: 1.6;
}

#fields-content .expandable-text .text-content.truncated {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#fields-content .expandable-text .show-more-btn {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}

#fields-content .expandable-text .show-more-btn:hover {
  color: #0056b3;
  text-decoration: underline;
}

#fields-content .expandable-text .show-more-btn i {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

#fields-content .expandable-text .show-more-btn.expanded i {
  transform: rotate(180deg);
}

/* Badges */
#fields-content .field-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#fields-content .field-badge.type {
  background: #e3f2fd;
  color: #1976d2;
}

#fields-content .field-badge.status {
  background: #e8f5e9;
  color: #388e3c;
}

/* Empty State */
#fields-content .field-cards-empty {
  text-align: center;
  padding: 60px 20px;
  color: #6c757d;
}

#fields-content .field-cards-empty i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: #adb5bd;
}

/* Loading State */
#fields-content .field-cards-loading {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
}

#fields-content .field-cards-loading .spinner-border {
  width: 2rem;
  height: 2rem;
  margin-bottom: 12px;
}

/* Responsive Design */
@media (max-width: 992px) {
  #fields-content .field-info-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #fields-content .field-info-item.full-width {
    grid-column: 1;
  }
}

@media (max-width: 768px) {
  #fields-content .field-card {
    padding: 16px;
  }

  #fields-content .field-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #fields-content .field-actions {
    margin-left: 0;
    margin-top: 12px;
    align-self: flex-end;
  }

  #fields-content .field-name {
    font-size: 1.1rem;
  }

  #fields-content .generators-menu {
    right: 0;
    min-width: 260px;
  }
}

@media (max-width: 576px) {
  #fields-content .field-card {
    padding: 12px;
    margin-bottom: 12px;
  }

  #fields-content .field-name {
    font-size: 1rem;
  }

  #fields-content .field-info-item label {
    font-size: 0.75rem;
  }

  #fields-content .field-info-item .value {
    font-size: 0.875rem;
  }

  #fields-content .generators-menu {
    position: fixed;
    right: 10px;
    left: 10px;
    min-width: auto;
    max-width: none;
  }
}

/* Print Styles */
@media print {
  #fields-content .field-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    margin-bottom: 12px;
    page-break-inside: avoid;
  }

  #fields-content .field-actions {
    display: none;
  }

  #fields-content .generators-menu {
    display: none !important;
  }
}
