/* ────────────────────────────────────────────
   Comparateur Santé — Clean Minimal Theme
   Font: DM Sans
   Palette: slate/emerald
   ──────────────────────────────────────────── */

:root {
  --bg: #f8fafb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --primary: #0f5132;
  --primary-light: #ecfdf5;
  --primary-hover: #0a3d26;
  --accent: #059669;
  --best: #dcfce7;
  --best-text: #166534;
  --danger: #fef2f2;
  --danger-text: #b91c1c;
  --success: #f0fdf4;
  --success-text: #166534;
  --info: #f0f9ff;
  --info-text: #0369a1;
  --star: #f59e0b;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.15s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

.app {
  min-height: 100vh;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Upload section ── */

.upload-section {
  margin-bottom: 24px;
}

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--primary-light);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

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

.dropzone-content {
  pointer-events: none;
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
  transition: color var(--transition);
}

.dropzone:hover .dropzone-icon {
  color: var(--accent);
}

.dropzone-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Files list ── */

.files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  min-height: 0;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #c6f6d5;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  animation: chipIn 0.25s ease;
}

.file-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Buttons ── */

.actions-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg);
}

/* ── Status ── */

.status-box {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.status-box.info { background: var(--info); color: var(--info-text); }
.status-box.success { background: var(--success); color: var(--success-text); }
.status-box.error { background: var(--danger); color: var(--danger-text); }

/* ── Loading overlay ── */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  min-width: 280px;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Summary card ── */

.summary-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.summary-card h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.summary-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 20px 0 12px;
}

.winner {
  font-size: 14px;
  color: var(--best-text);
  background: var(--best);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.score-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.score-item {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
}

.score-name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-stars {
  font-size: 20px;
  letter-spacing: 1px;
}

.star.filled { color: var(--star); }
.star.empty { color: var(--border); }

/* Category detail */

.category-scores { margin-top: 16px; }

.category-scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.category-score-block {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px;
}

.category-score-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}

.category-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.cat-doc-name {
  flex: 1;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.cat-doc-stars { font-size: 14px; letter-spacing: 1px; }
.cat-doc-detail { color: var(--text-muted); font-size: 11px; min-width: 28px; text-align: right; }

/* ── Comparison tables ── */

.category-block { margin-bottom: 28px; }

.category-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  padding-left: 2px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
}

thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-lg) 0 0; }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  vertical-align: top;
}

tbody tr:hover { background: #fafcfd; }

.garantie-cell {
  font-weight: 600;
  min-width: 200px;
  color: var(--text);
}

.detail-cell {
  min-width: 140px;
  color: var(--text-muted);
  font-size: 12px;
}

.best-value {
  background: var(--best);
  font-weight: 600;
  color: var(--best-text);
}

.empty-state {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .main { padding: 20px 14px 36px; }
  .header-inner { padding: 12px 14px; }
  .dropzone { padding: 32px 16px; }
  .actions-row { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
  table { min-width: 700px; }
  .category-scores-grid { grid-template-columns: 1fr; }
  .loading-card { min-width: auto; margin: 0 16px; padding: 28px 20px; }
}
