/**
 * History tab styling
 */

.history-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  min-height: 300px;
  width: 100%;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  margin: 0;
  color: #f5f5f5;
}

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

.history-sort {
  background-color: #2c3e50;
  color: white;
  border: 1px solid #3e5770;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 14px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  overflow-y: auto;
  padding: 10px 0;
  min-height: 200px;
}

.history-item {
  display: flex;
  flex-direction: column;
  background-color: #2c3e50;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  position: relative; /* Enable absolute positioning of children */
}

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

/* Style for the currently active (loaded) history item */
.history-item.active {
  border: 2px solid #3498db;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.history-item-image {
  height: 100px;
  background-color: #1a2631;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.history-item-image img {
  max-height: 80px;
  max-width: 80px;
  image-rendering: pixelated;
}

.history-item-details {
  padding: 10px;
}

.history-item-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-prompt {
  font-size: 12px;
  color: #bdc3c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 11px;
  color: #7f8c8d;
  margin-top: 5px;
}

.history-item-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.history-item-action {
  background: none;
  border: none;
  color: #3498db;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 5px;
  transition: color 0.2s;
}

.history-item-action:hover {
  color: #2980b9;
}

.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: auto;
  padding: 10px 0;
}

.pagination-btn {
  background-color: #34495e;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background-color: #2c3e50;
}

.pagination-btn:disabled {
  background-color: #546979;
  color: #b8c4d0;
  cursor: not-allowed;
}

#historyPageInfo {
  font-size: 14px;
  color: #ecf0f1;
}

.history-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #95a5a6;
  text-align: center;
}

.history-empty p {
  margin-bottom: 20px;
}

.history-error-detail {
  font-size: 12px;
  color: #e74c3c;
  margin-top: -15px;
  margin-bottom: 25px !important;
}

.history-empty button {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.history-empty button:hover {
  background-color: #2980b9;
}

/* Favorite star styling */
.history-favorite {
  color: #f1c40f;
}

/* Loading indicator */
.history-loading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.history-loader, .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(52, 152, 219, 0.3);
  border-radius: 50%;
  border-top-color: #3498db;
  animation: spin 1s ease-in-out infinite;
}

.history-item-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  z-index: 10;
}

.history-item-loading .loading-spinner {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .history-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
  }
  
  .history-item-image {
    height: 80px;
  }
  
  .history-pagination {
    flex-wrap: wrap;
  }
}