/**
 * 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-item-action.history-delete {
  color: #95a5a6;
}

.history-item-action.history-delete:hover {
  color: #e74c3c;
}

.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); }
}

/* Delete Confirmation Modal */
.delete-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.delete-modal-content {
  background-color: #1f1f2e;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 0;
  max-width: 400px;
  width: 90%;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.delete-modal-header {
  background-color: #2c3e50;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid #34495e;
}

.delete-modal-header h3 {
  margin: 0;
  color: #ecf0f1;
  font-size: 20px;
}

.delete-modal-body {
  padding: 25px;
  text-align: center;
}

.delete-modal-body p {
  margin: 10px 0;
  color: #bdc3c7;
  font-size: 16px;
}

.delete-item-name {
  color: #ecf0f1;
  font-weight: bold;
  font-size: 18px;
  margin: 15px 0;
}

.delete-warning {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 20px;
}

.delete-modal-actions {
  display: flex;
  gap: 10px;
  padding: 20px;
  background-color: #1a1a28;
  border-radius: 0 0 12px 12px;
  border-top: 1px solid #2c3e50;
}

.delete-cancel-btn,
.delete-confirm-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.delete-cancel-btn {
  background-color: #34495e;
  color: #ecf0f1;
}

.delete-cancel-btn:hover {
  background-color: #2c3e50;
}

.delete-confirm-btn {
  background-color: #e74c3c;
  color: white;
}

.delete-confirm-btn:hover {
  background-color: #c0392b;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* 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;
  }
}