/* GradCAM Explorer Styles */
.gradcam-controls {
  background: #f5f5f5;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-group:last-of-type {
  margin-bottom: 0;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.control-label {
  font-weight: 600;
  font-size: 1rem;
  color: #363636;
}

.control-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action {
  background: #dbdbdb;
  border: none;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-action:hover {
  background: #b5b5b5;
}

/* Model Pills */
.model-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid #dbdbdb;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.model-pill:hover {
  border-color: #3273dc;
}

.model-pill.active {
  background: #3273dc;
  border-color: #3273dc;
  color: white;
}

.model-pill .pill-check {
  margin-right: 0.5rem;
  font-size: 0.75rem;
}

/* Class Search & Checkboxes */
.class-search-wrapper {
  margin-bottom: 0.75rem;
}

.class-search {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 2px solid #dbdbdb;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.class-search:focus {
  border-color: #3273dc;
}

.class-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: white;
  border-radius: 6px;
  border: 1px solid #dbdbdb;
}

.class-checkbox-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.85rem;
}

.class-checkbox-item:hover {
  background: #f0f0f0;
}

.class-checkbox-item.hidden {
  display: none;
}

.class-checkbox-item input {
  margin-right: 0.5rem;
  cursor: pointer;
}

.class-checkbox-item.selected {
  background: #e8f4fd;
}

/* Selection Summary */
.selection-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #dbdbdb;
}

#summary-text {
  color: #666;
  font-size: 0.9rem;
}

/* Results Grid */
.gradcam-results {
  min-height: 100px;
}

.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  color: #999;
  text-align: center;
}

.results-placeholder i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.results-grid {
  display: grid;
  gap: 1rem;
}

/* Desktop: Dynamic columns based on model count */
.results-grid[data-cols="1"] { grid-template-columns: 1fr; max-width: 250px; margin: 0 auto; }
.results-grid[data-cols="2"] { grid-template-columns: repeat(2, 1fr); max-width: 500px; margin: 0 auto; }
.results-grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); max-width: 700px; margin: 0 auto; }
.results-grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
.results-grid[data-cols="5"] { grid-template-columns: repeat(5, 1fr); }
.results-grid[data-cols="6"] { grid-template-columns: repeat(6, 1fr); }
.results-grid[data-cols="7"] { grid-template-columns: repeat(7, 1fr); }

.class-row {
  display: contents;
}

.class-label {
  grid-column: 1 / -1;
  background: #363636;
  color: white;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.class-label:first-child {
  margin-top: 0;
}

.gradcam-card {
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.gradcam-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gradcam-card img {
  width: 100%;
  height: auto;
  display: block;
}

.gradcam-card .card-label {
  padding: 0.35rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: #363636;
  background: #f9f9f9;
  border-top: 1px solid #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lightbox */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
}

.lightbox-caption {
  color: white;
  text-align: center;
  margin-top: 1rem;
  font-size: 1rem;
}

/* Warning Message */
.warning-message {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
  .gradcam-controls {
    padding: 1rem;
  }

  .model-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scroll-snap-type: x mandatory;
  }

  .model-pill {
    flex-shrink: 0;
    scroll-snap-align: start;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .class-checkboxes {
    grid-template-columns: repeat(2, 1fr);
    max-height: 160px;
  }

  .selection-summary {
    text-align: center;
  }

  /* Mobile grid: 2 columns */
  .results-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    max-width: 100% !important;
    gap: 0.5rem;
  }

  .gradcam-card .card-label {
    font-size: 0.6rem;
    padding: 0.25rem;
  }

  .class-label {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  .lightbox-content {
    padding: 1rem;
  }

  .lightbox-close {
    top: -35px;
    font-size: 2rem;
  }
}

@media screen and (max-width: 480px) {
  .class-checkboxes {
    grid-template-columns: 1fr;
  }

  .model-pill {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }
}
