/*
=============================================================
  Fichier    : pdf-analyzer.css
  Projet     : Financial Analyzer
  Description: Styles du modal d'analyse de rapports PDF
               (zone de dépôt, champ URL, panneau de résultats)
  Auteur     : Claude Marcel
  Version    : 1.0
  Date       : 2026-03-22
  Dépend de  : variables.css
=============================================================
*/

/* ==================== OVERLAY MODAL ==================== */

.pdf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pdf-modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ==================== MODAL CONTAINER ==================== */

.pdf-modal {
  background: var(--bg-card, #1e2433);
  border: 1px solid var(--border-color, #2d3548);
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.pdf-modal-overlay.visible .pdf-modal {
  transform: translateY(0);
}

/* ==================== EN-TÊTE DU MODAL ==================== */

.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color, #2d3548);
  flex-shrink: 0;
}

.pdf-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}

.pdf-modal-title svg {
  width: 20px;
  height: 20px;
  color: #f59e0b;
  flex-shrink: 0;
}

.pdf-modal-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pdf-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #94a3b8);
  transition: background 0.15s, color 0.15s;
}

.pdf-modal-close:hover {
  background: var(--bg-hover, #2d3548);
  color: var(--text-primary, #e2e8f0);
}

.pdf-modal-close svg {
  width: 16px;
  height: 16px;
}

/* ==================== CORPS DU MODAL ==================== */

.pdf-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==================== NOTICE COÛTS ==================== */

.pdf-cost-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  font-size: 12.5px;
  color: #f59e0b;
}

.pdf-cost-notice svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.pdf-cost-notice span {
  color: var(--text-secondary, #94a3b8);
}

.pdf-cost-notice span strong {
  color: #f59e0b;
}

/* ==================== ONGLETS UPLOAD / URL ==================== */

.pdf-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface, #151b2e);
  border-radius: 8px;
  padding: 3px;
}

.pdf-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pdf-tab svg {
  width: 14px;
  height: 14px;
}

.pdf-tab:hover {
  color: var(--text-primary, #e2e8f0);
}

.pdf-tab.active {
  background: var(--bg-card, #1e2433);
  color: var(--accent-blue, #3b82f6);
  font-weight: 600;
}

/* ==================== ZONE DE DÉPÔT (UPLOAD) ==================== */

.pdf-upload-zone {
  border: 2px dashed var(--border-color, #2d3548);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.pdf-upload-zone:hover,
.pdf-upload-zone.dragover {
  border-color: var(--accent-blue, #3b82f6);
  background: rgba(59, 130, 246, 0.05);
}

.pdf-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.pdf-upload-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
}

.pdf-upload-icon svg {
  width: 22px;
  height: 22px;
}

.pdf-upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  margin-bottom: 4px;
}

.pdf-upload-hint {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
}

.pdf-file-selected {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  font-size: 13px;
  color: #10b981;
  margin-top: 8px;
}

.pdf-file-selected.visible {
  display: flex;
}

.pdf-file-selected svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ==================== CHAMP URL ==================== */

.pdf-url-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.pdf-url-panel.active {
  display: flex;
}

.pdf-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-upload-panel.hidden {
  display: none;
}

.pdf-url-label {
  font-size: 12.5px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.pdf-url-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface, #151b2e);
  border: 1px solid var(--border-color, #2d3548);
  border-radius: 8px;
  color: var(--text-primary, #e2e8f0);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.pdf-url-input::placeholder {
  color: var(--text-muted, #64748b);
}

.pdf-url-input:focus {
  border-color: var(--accent-blue, #3b82f6);
}

.pdf-url-hint {
  font-size: 11.5px;
  color: var(--text-muted, #64748b);
}

/* ==================== BOUTON ANALYSER ==================== */

.pdf-analyze-btn {
  width: 100%;
  padding: 11px 20px;
  background: #f59e0b;
  color: #0f1117;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, opacity 0.15s;
}

.pdf-analyze-btn:hover:not(:disabled) {
  background: #d97706;
}

.pdf-analyze-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pdf-analyze-btn svg {
  width: 16px;
  height: 16px;
}

/* ==================== SPINNER ==================== */

.pdf-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #0f1117;
  border-radius: 50%;
  animation: pdf-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ==================== PANNEAU DE RÉSULTATS ==================== */

.pdf-result-panel {
  display: none;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-color, #2d3548);
  border-radius: 10px;
  overflow: hidden;
}

.pdf-result-panel.visible {
  display: flex;
}

.pdf-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface, #151b2e);
  border-bottom: 1px solid var(--border-color, #2d3548);
}

.pdf-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
}

.pdf-result-meta svg {
  width: 13px;
  height: 13px;
  color: #10b981;
}

.pdf-result-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pdf-result-tag.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.pdf-result-content {
  padding: 20px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-primary, #e2e8f0);
  max-height: 420px;
  overflow-y: auto;
}

/* Styles Markdown dans le résultat */
.pdf-result-content h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-blue, #3b82f6);
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color, #2d3548);
}

.pdf-result-content h2:first-child {
  margin-top: 0;
}

.pdf-result-content ul {
  padding-left: 18px;
  margin: 6px 0;
}

.pdf-result-content li {
  margin-bottom: 4px;
  color: var(--text-secondary, #94a3b8);
}

.pdf-result-content strong {
  color: var(--text-primary, #e2e8f0);
  font-weight: 600;
}

.pdf-result-content p {
  margin: 6px 0;
  color: var(--text-secondary, #94a3b8);
}

/* ==================== MESSAGE D'ERREUR ==================== */

.pdf-error-msg {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 13px;
  color: #ef4444;
}

.pdf-error-msg.visible {
  display: flex;
}

.pdf-error-msg svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ==================== NAV ITEM PDF (sidebar) ==================== */

.nav-item-pdf {
  color: #f59e0b !important;
}

.nav-item-pdf:hover {
  background: rgba(245, 158, 11, 0.1) !important;
  color: #fbbf24 !important;
}

.nav-badge-pdf {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
  font-size: 9px !important;
  padding: 1px 5px !important;
}

/* ==================== BANNIÈRE SOURCE PDF ==================== */

.pdf-source-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.04));
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  padding: 12px 24px;
  flex-shrink: 0;
}

.pdf-banner-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
}

.pdf-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.pdf-banner-left > svg {
  width: 18px;
  height: 18px;
  color: #f59e0b;
  flex-shrink: 0;
  margin-top: 2px;
}

.pdf-banner-title {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pdf-banner-title strong {
  color: #f59e0b;
}

.pdf-banner-meta {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.pdf-banner-raw {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pdf-banner-raw-item {
  font-size: 11.5px;
  padding: 2px 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 4px;
  color: #f59e0b;
}

.pdf-banner-highlights {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pdf-banner-highlight {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  font-style: italic;
}

/* ── Sections de données structurées dans la bannière ── */

.pdf-banner-section {
  margin-top: 8px;
}

.pdf-banner-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  margin-bottom: 4px;
}

/* ── Badge "N années extraites" ── */

.pdf-banner-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  vertical-align: middle;
}

.pdf-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: flex-start;
}

.pdf-banner-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

.pdf-banner-btn:hover {
  background: rgba(245, 158, 11, 0.2);
}

.pdf-banner-btn-secondary {
  background: transparent;
  border-color: var(--border-color, #2d3548);
  color: var(--text-secondary, #94a3b8);
}

.pdf-banner-btn-secondary:hover {
  background: var(--bg-hover, #2d3548);
  color: var(--text-primary, #e2e8f0);
}

/* ==================== RESPONSIVE — MOBILE ==================== */

@media (max-width: 480px) {
  .pdf-modal {
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }

  .pdf-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .pdf-modal-body {
    padding: 16px;
  }

  .pdf-result-content {
    max-height: 280px;
  }
}
