/**
 * History Panel Styles
 * Upload history tracking and re-editing functionality
 */

/* ========== HISTORY TOGGLE ========== */
.history-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary);
  color: var(--white);
  padding: 16px 12px;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: all 0.3s;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 600;
  font-size: 0.875rem;
}

.history-toggle:hover {
  background: var(--primary-dark);
  padding-right: 16px;
}

.history-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: var(--white);
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ========== HISTORY PANEL ========== */
.history-panel {
  position: fixed;
  right: -400px;
  top: 0;
  bottom: 0;
  width: 400px;
  background: var(--white);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.history-panel.open {
  right: 0;
}

.history-header {
  padding: var(--spacing-xl);
  border-bottom: 1px solid #e0e0e0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
}

.history-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.history-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.history-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s;
}

.history-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.history-subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* ========== HISTORY FILTERS ========== */
.history-filters {
  padding: var(--spacing-lg);
  border-bottom: 1px solid #e0e0e0;
  background: var(--bg-gray);
}

.filter-tabs {
  display: flex;
  gap: var(--spacing-sm);
}

.filter-tab {
  flex: 1;
  padding: 8px 12px;
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.filter-tab:hover {
  background: #e8e7ff;
  color: var(--primary);
}

.filter-tab.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary-dark);
}

/* ========== HISTORY CONTENT ========== */
.history-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

.history-content::-webkit-scrollbar {
  width: 8px;
}

.history-content::-webkit-scrollbar-track {
  background: var(--bg-gray);
}

.history-content::-webkit-scrollbar-thumb {
  background: var(--light-gray);
  border-radius: var(--radius-sm);
}

.history-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray);
}

.history-empty {
  text-align: center;
  padding: var(--spacing-2xl);
  color: var(--gray);
}

.history-empty-icon {
  font-size: 4rem;
  color: var(--light-gray);
  margin-bottom: var(--spacing-md);
}

.history-empty-text {
  font-size: 1rem;
  margin-bottom: var(--spacing-sm);
}

.history-empty-hint {
  font-size: 0.875rem;
  color: var(--light-gray);
}

/* ========== HISTORY GROUPS ========== */
.history-group {
  margin-bottom: var(--spacing-xl);
}

.history-group-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.history-group-count {
  background: var(--bg-gray);
  color: var(--gray);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ========== HISTORY ITEMS ========== */
.history-items {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.history-item {
  background: var(--bg-gray);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}

.history-item:hover {
  transform: translateX(-4px);
  box-shadow: var(--shadow-md);
}

.history-item-preview {
  width: 100%;
  height: 120px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.history-item-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.history-item-tool {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.history-item-info {
  padding: var(--spacing-md);
}

.history-item-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: var(--spacing-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gray);
}

.history-item-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-item-size {
  font-family: var(--font-mono);
}

.history-item-actions {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.history-item-btn {
  flex: 1;
  padding: 6px 12px;
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

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

/* ========== HISTORY FOOTER ========== */
.history-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid #e0e0e0;
  background: var(--bg-gray);
}

.history-clear-btn {
  width: 100%;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--error);
  cursor: pointer;
  transition: all 0.2s;
}

.history-clear-btn:hover {
  background: var(--error);
  color: var(--white);
  border-color: var(--error);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .history-panel {
    width: 100%;
    right: -100%;
  }
  
  .history-toggle {
    display: none;
  }
}
