/* Gallery styles for Trail Intel */
.gallery-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-container label {
  font-weight: 500;
  white-space: nowrap;
}

.search-container .form-input {
  min-width: 200px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.gallery-item {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.3s;
  aspect-ratio: 3/2;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.empty-gallery-message {
  grid-column: 1 / -1;
  padding: 30px;
  text-align: center;
  background-color: #f9f9f9;
}

/* Styles for images that fail to load */
.image-load-error {
  opacity: 0.8;
  filter: grayscale(0.8);
}

.error-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(220, 38, 38, 0.8);
  color: white;
  padding: 5px;
  font-size: 12px;
  text-align: center;
}

/* Loading indicator for images */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
}

.gallery-item img.loading {
  opacity: 0.3;
}

/* Image warning banner for the modal */
.image-warning-banner {
  background-color: #FEF3C7;
  border: 1px solid #F59E0B;
  color: #92400E;
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 4px;
  text-align: center;
  font-weight: 500;
  border-radius: 5px;
  border: 1px dashed #ddd;
}

.gallery-pagination {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 20px;
}

.pagination-list {
  display: flex;
  gap: 5px;
  align-items: center;
}

.pagination-btn {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background-color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.pagination-btn.active {
  background-color: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

.pagination-ellipsis {
  padding: 8px 12px;
  color: #666;
}

/* No image placeholder styles */
.gallery-no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  background-color: #f8f9fa;
  color: #6c757d;
  font-size: 14px;
  border: 2px dashed #dee2e6;  border-radius: 4px;
  margin: 10px;
}

/* Weather and Animal Display Styles */
.weather-section, .animal-section {
  margin: 15px 0;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #4CAF50;
}

.weather-section h4, .animal-section h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #2c3e50;
}

.animal-item {
  padding: 10px 0;
}

.animal-separator {
  margin: 10px 0;
  border: none;
  border-top: 1px solid #dee2e6;
}

.weather-section p, .animal-section p {
  margin: 5px 0;
  font-size: 14px;
}

.weather-section strong, .animal-section strong {
  color: #2c3e50;
}

/* Split Panel Edit Mode Styles */
.analysis-edit-container {
  display: flex;
  gap: 25px;
  max-height: 75vh;
  overflow: hidden;
  margin: 20px 0;
  min-height: 500px;
}

.ai-reference-panel {
  flex: 0 0 42%;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
  border-left: 4px solid #17a2b8;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  overflow-y: auto;
  max-height: 100%;
}

.manual-edit-panel {
  flex: 0 0 55%;
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  border-left: 4px solid #28a745;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  overflow-y: auto;
  max-height: 100%;
}

.ai-reference-panel h4 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #17a2b8;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.manual-edit-panel h4 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #28a745;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.ai-analysis-readonly {
  pointer-events: none;
  opacity: 0.95;
  background: rgba(255,255,255,0.9);
  padding: 16px;
  border-radius: 8px;
  margin: 15px 0;
  border: 1px solid #e9ecef;
  line-height: 1.6;
}

.ai-analysis-readonly .animal-section,
.ai-analysis-readonly .weather-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #dee2e6;
}

.ai-analysis-readonly .animal-section:last-child,
.ai-analysis-readonly .weather-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.ai-analysis-readonly h4 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #495057;
  font-weight: 600;
}

.ai-analysis-readonly p {
  margin-bottom: 6px;
  line-height: 1.5;
  font-size: 14px;
}

.ai-analysis-readonly strong {
  color: #2c3e50;
  font-weight: 600;
}

.reference-note {
  margin-top: 20px;
  padding: 12px;
  background: #e7f3ff;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #b3d9ff;
}

.reference-note small {
  color: #0056b3;
  font-weight: 500;
  font-size: 13px;
}

.edit-form-container {
  margin: 15px 0;
}

.manual-edit-form .form-group {
  margin-bottom: 16px;
}

.manual-edit-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #333;
  font-size: 13px;
}

.manual-edit-form .form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.3s ease;
  background-color: #fff;
}

.manual-edit-form .form-control:focus {
  outline: none;
  border-color: #28a745;
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.manual-edit-form textarea.form-control {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}

.manual-edit-form select.form-control {
  cursor: pointer;
}

.edit-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid #eee;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.edit-actions .btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: center;
}

.edit-actions .btn-success {
  background-color: #28a745;
  color: white;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.edit-actions .btn-success:hover {
  background-color: #218838;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.edit-actions .btn-secondary {
  background-color: #6c757d;
  color: white;
  box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

.edit-actions .btn-secondary:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}

/* Form row layout for better organization */
.manual-edit-form .form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 16px;
}

.manual-edit-form .form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Ensure single form groups still have proper spacing */
.manual-edit-form .form-group:not(.form-row .form-group) {
  margin-bottom: 16px;
}

/* Inline editing styles */
.editable-animal-form {
  background-color: #f8f9fa;
  border: 2px dashed #007bff;
  border-radius: 8px;
  padding: 20px;
  margin: 15px 0;
}

.editable-animal-form .form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 16px;
}

.editable-animal-form .form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.editable-animal-form .form-group {
  margin-bottom: 16px;
}

.editable-animal-form .form-group:not(.form-row .form-group) {
  margin-bottom: 16px;
}

.editable-animal-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #495057;
}

.editable-animal-form .form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.editable-animal-form .form-control:focus {
  border-color: #007bff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.editable-animal-form textarea.form-control {
  resize: vertical;
  min-height: 60px;
}

/* Enhanced override message with animation */
.override-message {
  margin-top: 8px;
  animation: fadeIn 0.3s ease-in;
}

.override-message small {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  background-color: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Editing mode indicator */
.editing-mode .override-message small {
  background-color: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.2);
  color: #28a745;
}

/* Animation for smooth transitions */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced form focus states */
.editable-animal-form .form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  transform: scale(1.02);
  transition: all 0.2s ease;
}

/* Button hover animations */
.btn-edit-analysis {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-edit-analysis:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-edit-analysis:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Success state animation */
.btn-edit-analysis.btn-success {
  animation: pulseGreen 0.6s ease-in-out;
}

@keyframes pulseGreen {
  0% {
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
  }
}

/* Enhanced saving indicator */
.saving-indicator {
  text-align: center;
  padding: 30px 20px;
  font-size: 16px;
  color: #007bff;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px dashed #007bff;
  border-radius: 12px;
  margin: 20px 0;
  animation: savingPulse 1.5s ease-in-out infinite;
}

@keyframes savingPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

/* Form validation feedback */
.form-control:invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control:valid {
  border-color: #28a745;
}

/* Tooltip styles for form guidance */
.form-group {
  position: relative;
}

.form-group label:not([for="location-food-plot"])::after,
.form-group:not(.food-plot-container) label::after {
  content: '?';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: #6c757d;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  text-align: center;
  line-height: 16px;
  margin-left: 5px;
  cursor: help;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.form-group label:not([for="location-food-plot"]):hover::after,
.form-group:not(.food-plot-container) label:hover::after {
  opacity: 1;
}

/* Explicitly hide question marks for food plot options */
.food-plot-option::after,
.food-plot-option label::after {
  display: none !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .analysis-edit-container {
    flex-direction: column;
    gap: 20px;
    max-height: none;
    min-height: auto;
  }
  
  .ai-reference-panel,
  .manual-edit-panel {
    flex: none;
    padding: 15px;
    max-height: none;
  }
  
  .edit-actions {
    flex-direction: column;
    gap: 10px;
  }
  
  .edit-actions .btn {
    width: 100%;
    min-width: auto;
  }
  
  .editable-animal-form .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .editable-animal-form .form-row .form-group {
    margin-bottom: 16px;
  }
  
  .editable-animal-form {
    padding: 15px;
  }
}

/* Tablet Responsive */
@media (max-width: 992px) and (min-width: 769px) {
  .analysis-edit-container {
    gap: 20px;
    max-height: 75vh;
  }
  
  .ai-reference-panel {
    flex: 0 0 42%;
    padding: 15px;
  }
  
  .manual-edit-panel {
    flex: 0 0 55%;
    padding: 15px;
  }
}

/* Large screens - optimize for wide monitors */
@media (min-width: 1400px) {
  .analysis-edit-container {
    gap: 40px;
    max-height: 85vh;
  }
  
  .ai-reference-panel {
    flex: 0 0 40%;
  }
  
  .manual-edit-panel {
    flex: 0 0 55%;
  }
}

/* Section-based editing styles */
.section-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--background-color);
  overflow: hidden;
}

.section-container:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

/* Section headers with edit buttons */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--light-gray);
  border-bottom: 1px solid var(--border-color);
}

.section-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
}

/* Section button container */
.section-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section edit buttons */
.section-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 40px;
  height: 36px;
}

.section-edit-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.section-edit-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Section clear buttons */
.section-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid #ffc107;
  border-radius: 4px;
  background: #ffc107;
  color: #212529;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: auto;
  height: 36px;
  white-space: nowrap;
}

.section-clear-btn:hover {
  background: #e0a800;
  border-color: #d39e00;
  color: #000;
}

.section-clear-btn:focus {
  outline: 2px solid #ffc107;
  outline-offset: 2px;
}

/* Section save buttons */
.section-save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid #28a745;
  border-radius: 4px;
  background: #28a745;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 8px;
  min-width: 40px;
  height: 36px;
}

.section-save-btn:hover {
  background: #218838;
  border-color: #218838;
}

/* Section content */
.section-content {
  padding: 16px;
}

/* Section actions (for bottom buttons like clear) */
.section-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.section-actions .section-clear-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
  height: 32px;
}

/* Override messages */
.section-override-message {
  background: #fff3cd;
  color: #856404;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #ffeaa7;
}

/* Animal and environmental info displays */
.animal-info, .environmental-info {
  display: grid;
  gap: 8px;
}

.animal-info > div, .environmental-info > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--light-gray);
}

.animal-info > div:last-child, .environmental-info > div:last-child {
  border-bottom: none;
}

.animal-info strong, .environmental-info strong {
  color: var(--text-color);
  min-width: 100px;
  flex-shrink: 0;
}

/* Style for environmental values */
.environmental-info .env-value {
  text-align: right;
  font-weight: 500;
  color: var(--primary-color);
  flex-grow: 1;
  margin-left: 10px;
}

/* Style for animal analysis values */
.animal-info .animal-value {
  text-align: right;
  font-weight: 500;
  color: var(--primary-color);
  flex-grow: 1;
  margin-left: 10px;
}

/* Special styling for confidence values */
.animal-info .confidence-ai {
  color: #28a745 !important;
  font-weight: bold;
}

.animal-info .confidence-manual {
  color: #dc3545 !important;
  font-weight: bold;
}

/* Section edit forms */
.section-edit-form {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 16px;
}

.section-edit-form .form-row {
  margin-bottom: 12px;
}

.section-edit-form .form-row:last-child {
  margin-bottom: 0;
}

.section-edit-form label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.875rem;
}

.section-edit-form .form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
  height: 38px; /* Fixed height for all form controls */
  line-height: 1.4;
}

/* Specific styles for different input types */
.section-edit-form select.form-control {
  height: 38px;
  padding: 7px 12px; /* Slightly adjusted for select dropdown */
  width: 100%;
}

.section-edit-form input[type="number"].form-control,
.section-edit-form input[type="text"].form-control {
  height: 38px;
  padding: 8px 12px;
}

.section-edit-form .form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.section-edit-form textarea.form-control {
  resize: vertical;
  min-height: 80px;
  height: auto; /* Override fixed height for textarea */
  padding: 8px 12px;
}

.section-edit-form .form-note {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #6c757d;
  font-style: italic;
}

/* Responsive design for section editing */
@media (max-width: 768px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .section-edit-btn, .section-save-btn {
    align-self: flex-end;
  }
  
  .section-edit-form {
    padding: 12px;
  }
  
  .animal-info > div, .environmental-info > div {
    flex-direction: column;
    gap: 2px;
  }
  
  .animal-info strong, .environmental-info strong {
    min-width: auto;
  }
}
