/* Reset & base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
  background: #f5f7fb;
  color: #1e293b;
  line-height: 1.6;
  padding: 1rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  padding: 1rem 2rem;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: #0f172a;
}

nav button {
  background: transparent;
  border: none;
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 30px;
  cursor: pointer;
  transition: 0.2s;
  color: #64748b;
}

nav button.active {
  background: #eef2ff;
  color: #4338ca;
}

nav button:hover {
  background: #e2e8f0;
}

main {
  max-width: 1400px;
  margin: 0 auto;
}

section {
  display: none;
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

section.active {
  display: block;
}

/* Recherche */
.search-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.search-container input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.7rem 1.2rem;
  border: 2px solid #e2e8f0;
  border-radius: 40px;
  font-size: 1rem;
  transition: 0.2s;
}

.search-container input[type="text"]:focus {
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.search-container button {
  padding: 0.7rem 1.8rem;
  background: #4338ca;
  color: white;
  border: none;
  border-radius: 40px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.search-container button:hover {
  background: #3730a3;
}

#searchStatus {
  font-size: 0.9rem;
  color: #64748b;
  align-self: center;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.result-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  transition: 0.15s;
}

.result-card:hover {
  border-color: #6366f1;
  background: #f1f5f9;
}

.result-card .isin {
  font-family: monospace;
  font-weight: 600;
  color: #4338ca;
}

.result-card .name {
  font-weight: 500;
  margin: 0.25rem 0;
}

.result-card .meta {
  font-size: 0.85rem;
  color: #64748b;
}

/* Détail de la part */
#shareDetail {
  margin-bottom: 2rem;
}

.share-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.share-header h2 {
  font-size: 1.8rem;
  font-weight: 600;
}

.share-header .isin {
  font-family: monospace;
  font-size: 1.1rem;
  color: #475569;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem 1.5rem;
}

.field-item {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px dashed #e9edf2;
}

.field-item .label {
  font-weight: 500;
  color: #475569;
}

.field-item .value {
  font-weight: 400;
  word-break: break-word;
  max-width: 60%;
  text-align: right;
}

/* Performance tableaux */
.perf-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.perf-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
}

.perf-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #eef2f6;
}

/* Import PDF */
.pdf-import {
  background: #f8fafc;
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  border: 1px solid #e2e8f0;
}

.pdf-import h3 {
  margin-bottom: 1rem;
}

.pdf-import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pdf-import-row input[type="file"],
.pdf-import-row input[type="text"] {
  flex: 1;
  min-width: 150px;
  padding: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.pdf-import-row select {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: white;
}

.pdf-import-row button {
  padding: 0.5rem 1.5rem;
  background: #4338ca;
  color: white;
  border: none;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.pdf-import-row button:hover {
  background: #3730a3;
}

#pdfStatus {
  margin-top: 0.5rem;
  font-style: italic;
  color: #475569;
}

/* Résultats comparaison */
.comparison-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  background: #f1f5f9;
  border-radius: 16px;
  padding: 1.2rem 2rem;
  margin: 1.5rem 0;
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.summary-item .count {
  font-size: 1.8rem;
  font-weight: 700;
}

.summary-item .label {
  font-size: 0.9rem;
  color: #475569;
}

.summary-item.status-OK .count { color: #16a34a; }
.summary-item.status-DIFF .count { color: #dc2626; }
.summary-item.status-NOTFOUND .count { color: #f59e0b; }
.summary-item.status-UNCOMPARABLE .count { color: #8b5cf6; }
.summary-item.status-CHECK .count { color: #f97316; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.filters button {
  padding: 0.3rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 30px;
  background: white;
  cursor: pointer;
  font-weight: 500;
  transition: 0.15s;
}

.filters button.active {
  background: #4338ca;
  color: white;
  border-color: #4338ca;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.comparison-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.6rem 0.6rem;
  font-weight: 600;
  border-bottom: 2px solid #d1d9e6;
}

.comparison-table td {
  padding: 0.6rem;
  border-bottom: 1px solid #eef2f6;
  vertical-align: top;
}

.comparison-table .status-badge {
  display: inline-block;
  padding: 0.15rem 0.7rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.status-OK { background: #dcfce7; color: #166534; }
.status-DIFF { background: #fee2e2; color: #991b1b; }
.status-NOTFOUND { background: #fef9c3; color: #854d0e; }
.status-UNCOMPARABLE { background: #ede9fe; color: #5b21b6; }
.status-CHECK { background: #ffedd5; color: #9a3412; }

.source-preview {
  font-size: 0.8rem;
  color: #475569;
  max-width: 300px;
  word-break: break-word;
}

.preview-btn {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
}

.preview-btn:hover {
  background: #f1f5f9;
}

/* Historique */
#historyList {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1rem 1.5rem;
  background: #fafcff;
}

.history-item .head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
}

.history-item .head strong {
  font-size: 1.1rem;
}

.history-item .meta {
  color: #64748b;
  font-size: 0.85rem;
}

.history-item .summary-stats {
  display: flex;
  gap: 1.5rem;
  margin: 0.5rem 0;
}

.history-item .stats span {
  margin-right: 0.5rem;
}

.history-item .actions button {
  padding: 0.2rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  background: white;
  cursor: pointer;
}

.history-item .actions button:hover {
  background: #f1f5f9;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  color: #94a3b8;
  font-size: 0.85rem;
}

/* Accessibilité / responsive */
@media (max-width: 700px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .comparison-table {
    font-size: 0.8rem;
  }
  .comparison-table th,
  .comparison-table td {
    padding: 0.4rem;
  }
  .share-header {
    flex-direction: column;
  }
}

/* Impression */
@media print {
  body {
    background: white;
    padding: 0.5cm;
  }
  header, footer, .pdf-import, .filters, .actions, .preview-btn, #navSearch, #navHistory {
    display: none !important;
  }
  section {
    box-shadow: none;
    border: none;
    padding: 0;
  }
  .comparison-table {
    font-size: 0.8rem;
  }
  .comparison-table th {
    background: #eef2f6 !important;
  }
  .comparison-table td {
    border-bottom: 1px solid #ccc;
  }
}
/* Skeleton loading */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.skeleton-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.2rem 1.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}
.skeleton-line {
  height: 16px;
  background: #e2e8f0;
  border-radius: 4px;
  margin-bottom: 8px;
}
.skeleton-line.isin { width: 60%; }
.skeleton-line.name { width: 80%; height: 20px; }
.skeleton-line.meta { width: 40%; }

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}