/* ========================================
   VIEW CONTROLS AND LAYOUT MODES
   ======================================== */

/* Controls Container */
.controls-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
  gap: 2rem;
  flex-wrap: wrap;
}

/* Sort Controls */
.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--tree-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.sort-label {
  font-size: 0.9rem;
  color: var(--text-color);
  margin-right: 4px;
  font-weight: 500;
}

.sort-btn, .sort-order-btn {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 6px !important;
  padding: 6px 12px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  font-size: 0.85rem !important;
  color: var(--text-color) !important;
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  outline: none !important;
  text-decoration: none !important;
}

.sort-btn:hover, .sort-order-btn:hover {
  background: var(--button-bg) !important;
  color: white !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.sort-btn.active, .sort-order-btn.active {
  background: var(--button-bg) !important;
  color: white !important;
  border-color: var(--button-bg) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.sort-order-btn {
  min-width: 32px !important;
  justify-content: center !important;
  font-size: 1rem !important;
}

/* View Controls */
.view-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--tree-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: relative;
  z-index: 10;
}

.view-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.2rem;
  color: var(--text-color);
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-btn svg {
  width: 18px;
  height: 18px;
}

.view-btn:hover {
  background: var(--button-bg);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.view-btn.active {
  background: var(--button-bg);
  color: white;
  border-color: var(--button-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Plot Container Base Styles */
.plot-container {
  margin: 1rem 0;
  margin-bottom: 450px; /* Add extra bottom margin to prevent overlap with stats box */
  transition: all 0.3s ease;
  clear: both;
}

.plot-container .plot-item {
  transition: all 0.2s ease;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid transparent;
}

.plot-container .plot-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: var(--border-color);
}

.plot-container .plot-link {
  color: var(--link-color);
  text-decoration: none;
  display: block;
}

.plot-container .plot-thumbnail {
  width: 100%;
  height: auto;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.plot-container .plot-info {
  padding: 0.8rem;
}

.plot-container .plot-name {
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  font-size: 0.9rem;
  line-height: 1.3;
  font-weight: 500;
  color: var(--text-color);
}

.plot-container .plot-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  opacity: 0.7; /* Slightly lower opacity for differentiation */
}

/* Grid View - Override any conflicting styles */
.plot-container.grid-view {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
  gap: 1.2rem !important;
  padding: 1rem 0 !important;
}

.plot-container.grid-view .plot-item,
.plot-container.grid-view .grid-item {
  text-align: center !important;
  background: var(--card-bg) !important;
  border-radius: 8px !important;
  padding: 0.8rem !important;
  transition: all 0.2s ease !important;
  border: 1px solid transparent !important;
  display: block !important;
  width: auto !important;
  max-width: none !important;
}

.plot-container.grid-view .plot-item:hover,
.plot-container.grid-view .grid-item:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
  border-color: var(--border-color) !important;
}

.plot-container.grid-view .plot-link {
  display: block !important;
  color: var(--link-color) !important;
  text-decoration: none !important;
}

.plot-container.grid-view .plot-thumbnail {
  max-width: 100% !important;
  height: auto !important;
  border: 1px solid var(--border-color) !important;
  display: block !important;
  width: 100% !important;
  object-fit: contain !important;
  border-radius: 6px !important;
}

.plot-container.grid-view .plot-info {
  padding: 0.8rem 0 0 0 !important;
}

.plot-container.grid-view .plot-name {
  max-height: 3.9rem !important;
  overflow: hidden !important;
  margin-top: 0.8rem !important;
  display: block !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
  hyphens: auto !important;
  font-size: 0.9rem !important;
  line-height: 1.3 !important;
  font-weight: 500 !important;
  color: var(--text-color) !important;
  text-align: center !important;
}

/* Large List View */
.plot-container.list-large-view {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.8rem !important;
}

.plot-container.list-large-view .plot-item {
  display: flex !important;
  align-items: center !important;
  padding: 1rem !important;
  gap: 1rem !important;
}

.plot-container.list-large-view .plot-link {
  flex-shrink: 0 !important;
  width: 120px !important;
  height: 90px !important;
  overflow: hidden !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-color) !important;
}

.plot-container.list-large-view .plot-thumbnail {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.plot-container.list-large-view .plot-info {
  flex: 1 !important;
  padding: 0 !important;
  text-align: left !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.plot-container.list-large-view .plot-name {
  font-size: 1rem !important;
  line-height: 1.4 !important;
  max-height: none !important;
  overflow: visible !important;
  flex: 1 !important;
}

.plot-container.list-large-view .plot-date {
  flex-shrink: 0 !important;
  margin-left: 1rem !important;
  margin-top: 0 !important;
  font-size: 0.85rem !important;
  color: var(--text-secondary) !important;
  white-space: nowrap !important;
}

/* Compact List View */
.plot-container.list-compact-view {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.4rem !important;
}

.plot-container.list-compact-view .plot-item {
  display: flex !important;
  align-items: center !important;
  padding: 0.6rem 1rem !important;
  gap: 0.8rem !important;
  border-radius: 4px !important;
}

/* In compact view the thumbnail is hidden, so collapse the link out of the
   flex flow and stretch it as an invisible overlay — this keeps the whole
   row clickable without the empty link consuming horizontal space. */
.plot-container.list-compact-view .plot-item {
  position: relative !important;
}

.plot-container.list-compact-view .plot-link {
  position: absolute !important;
  inset: 0 !important;
  flex: none !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
}

.plot-container.list-compact-view .plot-thumbnail {
  display: none !important;
}

.plot-container.list-compact-view .plot-info {
  padding: 0 !important;
  flex: 1 !important;
  text-align: left !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.plot-container.list-compact-view .plot-name {
  font-size: 0.95rem !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  flex: 1 !important;
}

.plot-container.list-compact-view .plot-date {
  flex-shrink: 0 !important;
  margin-left: 1rem !important;
  margin-top: 0 !important;
  font-size: 0.8rem !important;
  color: var(--text-secondary) !important;
  white-space: nowrap !important;
}

/* Highlight effect for all views */
.plot-item.highlighted {
  border-color: var(--button-bg);
  box-shadow: 0 0 15px rgba(0, 120, 212, 0.3);
  transform: translateY(-2px);
  animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
  0%, 100% { transform: translateY(-2px) scale(1); }
  50% { transform: translateY(-2px) scale(1.02); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .view-controls {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  
  .plot-container.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }
  
  .plot-container.list-large-view .plot-link {
    width: 80px;
    height: 60px;
  }
  
  .plot-container.list-large-view .plot-item {
    padding: 0.8rem;
  }
  
  .plot-container.list-compact-view .plot-item {
    padding: 0.5rem 0.8rem;
  }
}

@media (max-width: 480px) {
  .view-controls {
    gap: 4px;
  }
  
  .view-btn {
    padding: 6px 8px;
    font-size: 1rem;
    min-width: 32px;
  }
  
  .plot-container.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .plot-container.list-large-view .plot-link {
    width: 60px;
    height: 45px;
  }
}
