/**
 * 📈 CSS für erweiterte Preishistorie
 * 
 * Moderne Styles für:
 * - Preishistorie-Header mit Statistiken
 * - Chart-Container
 * - Änderungsprotokoll
 * - Tab-Navigation
 * - Responsive Design
 */

/* ===== ENHANCED PRICE HISTORY CONTAINER ===== */
.enhanced-price-history {
  background: var(--card-bg, #2a2a2a);
  border-radius: 12px;
  padding: 20px;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color, #404040);
}

/* ===== PRICE HISTORY HEADER ===== */
.price-history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color, #404040);
}

.article-info h4 {
  margin: 0 0 5px 0;
  color: var(--text-primary, #ffffff);
  font-size: 18px;
  font-weight: 600;
}

.article-info small {
  color: var(--text-secondary, #b0b0b0);
  font-size: 12px;
}

.current-prices {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.price-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  background: var(--stat-bg, #3a3a3a);
  border-radius: 8px;
  border: 1px solid var(--border-color, #404040);
  min-width: 80px;
}

.price-stat .stat-label {
  font-size: 11px;
  color: var(--text-secondary, #b0b0b0);
  margin-bottom: 4px;
  text-align: center;
}

.price-stat .stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.price-stat.vk-neu .stat-value {
  color: var(--accent-color, #4ecdc4);
}

/* ===== PRICE STATISTICS ===== */
.price-statistics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  display: flex;
  align-items: center;
  padding: 15px;
  background: var(--stat-card-bg, #3a3a3a);
  border-radius: 10px;
  border: 1px solid var(--border-color, #404040);
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  font-size: 24px;
  margin-right: 15px;
  opacity: 0.8;
}

.stat-content {
  flex: 1;
}

.stat-content .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  margin-bottom: 4px;
}

.stat-content .stat-label {
  font-size: 12px;
  color: var(--text-secondary, #b0b0b0);
  margin-bottom: 2px;
}

.stat-content .stat-date,
.stat-content .stat-subtitle {
  font-size: 11px;
  color: var(--text-tertiary, #808080);
}

/* ===== PRICE HISTORY TAB NAVIGATION ===== */
.price-history-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color, #404040);
  padding-bottom: 10px;
}

/* 🎯 SPEZIELLE TAB-BUTTON-STYLES NUR FÜR PREISHISTORIE */
.price-history-tabs .tab-button {
  background: transparent;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  color: var(--text-secondary, #b0b0b0);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.price-history-tabs .tab-button:hover {
  background: var(--hover-bg, #404040);
  color: var(--text-primary, #ffffff);
}

.price-history-tabs .tab-button.active {
  background: var(--accent-color, #4ecdc4);
  color: var(--text-primary, #ffffff);
  border-color: var(--accent-color, #4ecdc4);
}

/* ===== TAB CONTENT ===== */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tab-pane.active {
  display: block;
  opacity: 1;
}

/* Sichtbarkeits-Fallbacks für das Preishistorie-Widget */
.enhanced-price-history .tab-content { position: relative; }
.enhanced-price-history #chart-tab,
.enhanced-price-history #log-tab {
  width: 100%;
}
.enhanced-price-history #log-tab .change-log-container {
  display: block;
  max-height: 400px;
  overflow-y: auto;
}
.enhanced-price-history .price-history-tabs .tab-button.active[data-tab="log"] ~ .tab-content #chart-tab { display: none !important; }
.enhanced-price-history .price-history-tabs .tab-button.active[data-tab="chart"] ~ .tab-content #log-tab { display: none !important; }

/* Debug-Styles für Preishistorie Tab-Navigation */
.price-history-tabs .tab-button {
  cursor: pointer;
  user-select: none;
}

.price-history-tabs .tab-button:hover {
  background: var(--hover-bg, #404040);
  color: var(--text-primary, #ffffff);
}

.price-history-tabs .tab-button.active {
  background: var(--accent-color, #4ecdc4);
  color: var(--text-primary, #ffffff);
  border-color: var(--accent-color, #4ecdc4);
  position: relative;
}

.price-history-tabs .tab-button.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color, #4ecdc4);
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  background: var(--chart-bg, #2a2a2a);
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--border-color, #404040);
}

.chart-controls {
  margin-bottom: 15px;
}

.timeframe-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timeframe-btn {
  background: var(--button-bg, #3a3a3a);
  border: 1px solid var(--border-color, #404040);
  color: var(--text-secondary, #b0b0b0);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeframe-btn:hover {
  background: var(--hover-bg, #404040);
  color: var(--text-primary, #ffffff);
}

.timeframe-btn.active {
  background: var(--accent-color, #4ecdc4);
  color: var(--text-primary, #ffffff);
  border-color: var(--accent-color, #4ecdc4);
}

.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

#priceChart {
  width: 100% !important;
  height: 100% !important;
}

/* ===== CHANGE LOG ===== */
.change-log-container {
  max-height: 400px;
  overflow-y: auto;
}

.change-log-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.change-log-entry {
  background: var(--log-entry-bg, #3a3a3a);
  border-radius: 8px;
  padding: 15px;
  border: 1px solid var(--border-color, #404040);
  transition: all 0.2s ease;
}

.change-log-entry:hover {
  background: var(--log-entry-hover-bg, #404040);
  transform: translateX(2px);
}

.change-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.change-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.change-type {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}

.change-type.manuell {
  background: var(--type-manual-bg, #4a90e2);
  color: var(--text-primary, #ffffff);
}

.change-type.import {
  background: var(--type-import-bg, #7ed321);
  color: var(--text-primary, #ffffff);
}

.change-type.csv {
  background: var(--type-csv-bg, #f5a623);
  color: var(--text-primary, #ffffff);
}

.change-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color, #404040);
}

.change-field {
  font-size: 13px;
  color: var(--text-secondary, #b0b0b0);
  font-weight: 500;
}

.change-values {
  display: flex;
  align-items: center;
  gap: 8px;
}

.old-value {
  color: var(--old-value-color, #ff6b6b);
  font-weight: 500;
}

.arrow {
  color: var(--text-secondary, #b0b0b0);
  font-size: 12px;
}

.new-value {
  color: var(--new-value-color, #4ecdc4);
  font-weight: 500;
}

.change-user {
  font-size: 11px;
  color: var(--text-tertiary, #808080);
  font-style: italic;
}

.change-log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary, #b0b0b0);
  text-align: center;
}

.change-log-empty svg {
  margin-bottom: 15px;
  opacity: 0.5;
}

.change-log-empty p {
  margin: 0;
  font-size: 14px;
}

/* ===== LOADING STATES ===== */
.price-history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary, #b0b0b0);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color, #404040);
  border-top: 3px solid var(--accent-color, #4ecdc4);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.price-history-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  color: var(--error-color, #ff6b6b);
  text-align: center;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .enhanced-price-history {
    padding: 15px;
  }
  
  .price-history-header {
    flex-direction: column;
    gap: 15px;
  }
  
  .current-prices {
    justify-content: center;
  }
  
  .price-statistics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-icon {
    font-size: 20px;
    margin-right: 12px;
  }
  
  .stat-content .stat-value {
    font-size: 16px;
  }
  
  .price-history-tabs {
    flex-wrap: wrap;
  }
  
  .price-history-tabs .tab-button {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  .chart-wrapper {
    height: 250px;
  }
  
  .change-log-entry {
    padding: 12px;
  }
  
  .change-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .change-values {
    align-self: flex-end;
  }
}

@media (max-width: 480px) {
  .enhanced-price-history {
    padding: 10px;
  }
  
  .price-statistics {
    grid-template-columns: 1fr;
  }
  
  .timeframe-filter {
    justify-content: center;
  }
  
  .chart-wrapper {
    height: 200px;
  }
}

/* ===== DARK MODE COMPATIBILITY ===== */
@media (prefers-color-scheme: dark) {
  .enhanced-price-history {
    --card-bg: #1a1a1a;
    --border-color: #333333;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --stat-bg: #2a2a2a;
    --stat-card-bg: #2a2a2a;
    --hover-bg: #333333;
    --chart-bg: #1a1a1a;
    --log-entry-bg: #2a2a2a;
    --log-entry-hover-bg: #333333;
    --button-bg: #2a2a2a;
    --accent-color: #4ecdc4;
    --old-value-color: #ff6b6b;
    --new-value-color: #4ecdc4;
    --error-color: #ff6b6b;
    --type-manual-bg: #4a90e2;
    --type-import-bg: #7ed321;
    --type-csv-bg: #f5a623;
  }
}

/* ===== LIGHT MODE COMPATIBILITY ===== */
@media (prefers-color-scheme: light) {
  .enhanced-price-history {
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --stat-bg: #f8f9fa;
    --stat-card-bg: #f8f9fa;
    --hover-bg: #e9ecef;
    --chart-bg: #ffffff;
    --log-entry-bg: #f8f9fa;
    --log-entry-hover-bg: #e9ecef;
    --button-bg: #f8f9fa;
    --accent-color: #007bff;
    --old-value-color: #dc3545;
    --new-value-color: #28a745;
    --error-color: #dc3545;
    --type-manual-bg: #007bff;
    --type-import-bg: #28a745;
    --type-csv-bg: #ffc107;
  }
} 