/*
=============================================================
  Fichier    : history.css
  Projet     : Financial Analyzer
  Description: Styles pour l'onglet Historique — navigation
               par onglets et grille de graphiques Chart.js.
  Auteur     : Claude Marcel
  Version    : 1.0
  Date       : 2026-03-21
  Dépend de  : variables.css
=============================================================
*/

/* ==================== NAVIGATION PAR ONGLETS ==================== */

.tab-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: 10px;
  margin-bottom: 24px;
  width: fit-content;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.tab-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--color-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ==================== CONTENUS D'ONGLETS ==================== */

.tab-content {
  display: block;
}

.tab-content.hidden {
  display: none;
}

/* ==================== EN-TÊTE ONGLET HISTORIQUE ==================== */

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.history-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 5px 10px;
  border-radius: 6px;
}

.history-note svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--color-warning, #f59e0b);
}

/* ==================== GRILLE DE GRAPHIQUES ==================== */

.history-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
}

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.chart-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-card-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.chart-card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.chart-card-badge.positive {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.chart-card-badge.negative {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.chart-card-badge.neutral {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.chart-wrapper {
  position: relative;
  height: 150px;
}

.chart-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  color: var(--text-muted);
  font-size: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

/* ==================== TABLEAU RÉSUMÉ ==================== */

.history-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th {
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 11px;
}

.history-table th:first-child {
  text-align: left;
}

.history-table td {
  padding: 9px 14px;
  text-align: right;
  color: var(--text-primary);
  border-top: 1px solid var(--border-color);
}

.history-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
}

.history-table tr:hover td {
  background: var(--bg-secondary);
}

.history-table .current-col {
  font-weight: 600;
  color: var(--color-primary);
}

/* ==================== SECTION ANALYSE IA HISTORIQUE ==================== */

.history-ai-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.history-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.history-ai-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-ai-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

#btn-ai-history {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 12px;
}

#btn-ai-history svg {
  width: 14px;
  height: 14px;
}

#ai-history-result {
  display: none;
  margin-top: 16px;
}

#ai-history-result.visible {
  display: block;
}

.ai-history-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 12px 0;
}

.ai-history-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
  .history-charts-grid {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    width: 100%;
    justify-content: center;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 12px;
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-ai-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .history-table th,
  .history-table td {
    padding: 8px 10px;
    font-size: 11px;
  }
}
