/* Fiches Bilan A4L - Interface moderne */
:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: #ccfbf1;
  --accent-bg: rgba(13, 148, 136, 0.08);
  --success: #059669;
  --error: #dc2626;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.5;
}

/* ========== Top navigation ========== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topnav-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}

.topnav-logo-badge {
  background: var(--accent);
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.topnav-logo-text {
  color: var(--text-muted);
  font-weight: 600;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topnav-link {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s, background 0.2s;
}

.topnav-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.topnav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.topnav-logout {
  margin-left: 0.5rem;
  color: var(--text-muted);
}

/* ========== Main content ========== */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
}

.page-title {
  margin: 0 0 1.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.card-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
}

/* ========== Tabs ========== */
.tabs-wrap {
  margin-bottom: 1.5rem;
}

.tab-head {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--accent);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: var(--bg-card);
}

.tab-panel {
  display: none;
  padding-top: 1.5rem;
  animation: tabIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes tabIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== Chips (remplace les cases à cocher) ========== */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all 0.2s;
  user-select: none;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.chip-input:checked + .chip-label,
.chip:has(.chip-input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-label {
  pointer-events: none;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.fiche-form .form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.05s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
}

/* ========== Alerts ========== */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

/* ========== Section titles (formulaire) ========== */
.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
}

.section-title:first-of-type {
  margin-top: 0;
}

.section-block {
  margin-bottom: 2.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.section-block:last-of-type {
  border-bottom: none;
}

.section-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-bottom: none;
}

.section-subtitle {
  font-weight: 600;
  margin: 0.75rem 0 0.4rem;
  color: var(--text);
  font-size: 0.95rem;
}

/* ========== Bilan : layout avec nav latérale ========== */
.bilan-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.bilan-nav {
  flex-shrink: 0;
  width: 200px;
  position: sticky;
  top: 5rem;
}

.bilan-nav-inner {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.bilan-nav-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.bilan-nav-link {
  display: block;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.bilan-nav-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  padding-right: 0.5rem;
  margin-right: -0.5rem;
}

.bilan-form-wrap {
  flex: 1;
  min-width: 0;
}

/* ========== Localisation (douleur droite/gauche) ========== */
.localisation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.localisation-block {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.localisation-block .douleur-input {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.localisation-block .douleur-input input {
  width: 4rem;
  padding: 0.5rem;
  text-align: center;
  border-radius: var(--radius-sm);
}

/* ========== Inline text next to chips ========== */
.chip-inline-text {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
}

.chip-inline-text input {
  width: 100px;
  padding: 0.4rem 0.5rem;
  margin-left: 0.25rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ========== Page Info ========== */
.info-page-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-top: 0.5rem;
}

.info-nav {
  flex-shrink: 0;
  width: 200px;
  position: sticky;
  top: 5rem;
}

.info-nav-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.info-nav-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.info-nav-link {
  display: block;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.info-nav-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  padding-right: 0.5rem;
  margin-right: -0.5rem;
}

.info-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.info-section {
  margin-bottom: 2rem;
  padding: 2rem 2.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 5rem;
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section h2 {
  font-size: 1.4rem;
  margin: 0 0 1.5rem;
  color: var(--text);
  padding-bottom: 0.6rem;
  border-bottom: 3px solid var(--accent);
  font-weight: 700;
}

.info-section h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.75rem;
  color: var(--text);
  font-weight: 600;
}

.info-section h3:first-of-type {
  margin-top: 0;
}

.info-section p, .info-section ul, .info-section ol {
  margin: 0 0 1.25rem;
  line-height: 1.75;
  font-size: 1.05rem;
  color: var(--text);
}

.info-section ul, .info-section ol {
  padding-left: 1.75rem;
}

.info-section li {
  margin-bottom: 0.5rem;
}

.info-grid dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 2rem;
  max-width: 520px;
}

.info-grid dt {
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
}

.info-grid dd {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.6;
}

.info-list-nums {
  max-width: 320px;
  font-size: 1.05rem;
  line-height: 1.8;
}

.info-list-nums li {
  margin-bottom: 0.35rem;
}

.info-table {
  width: 100%;
  max-width: 360px;
  border-collapse: collapse;
  font-size: 1rem;
}

.info-table th, .info-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.info-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.info-pdf-card .card-title {
  margin-bottom: 0.5rem;
}

.info-pdf-desc {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.info-pdf-wrap {
  width: 100%;
  max-width: 820px;
  height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f8fafc;
}

.info-pdf-embed {
  width: 100%;
  height: 100%;
  border: none;
}

.info-pdf-link {
  margin: 1.25rem 0 0;
  font-size: 1rem;
}

.info-pdf-link a {
  color: var(--accent);
  font-weight: 500;
}

.info-pdf-placeholder {
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1.25rem;
  font-size: 1.05rem;
}

@media (max-width: 768px) {
  .info-page-layout {
    flex-direction: column;
  }
  .info-nav {
    position: static;
    width: 100%;
  }
  .info-nav-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .info-nav-title {
    width: 100%;
  }
  .info-nav-link {
    padding: 0.35rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
  }
  .info-pdf-wrap {
    height: 400px;
  }
}

/* ========== Dashboard stats ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ========== Dashboard diagrammes ========== */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card .card-title {
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  height: 220px;
  margin-bottom: 0.75rem;
}

.chart-wrap canvas {
  max-width: 100%;
}

.chart-legend {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.dashboard-welcome {
  margin-bottom: 1.5rem;
}

/* ========== Fiche list (cards cliquables) ========== */
.fiche-list {
  display: grid;
  gap: 0.75rem;
}

.fiche-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fiche-list-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.12);
}

.fiche-list-item-left {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  display: block;
}

.fiche-list-item-left:hover {
  color: inherit;
}

.fiche-list-item-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.fiche-list-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fiche-list-item-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.25rem;
}

.fiche-list-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.fiche-list-item-actions .btn {
  text-decoration: none;
}

.fiche-list-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ========== Tables (admin, etc.) ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #f8fafc;
}

/* ========== Login page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f0fdfa 0%, #e0f2fe 40%, #f1f5f9 100%);
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  box-shadow: var(--shadow-card);
}

.login-box h1 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  text-align: center;
  color: var(--text);
  font-weight: 600;
}

.login-box .badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .topnav-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
  }
  .topnav-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .form-row,
  .form-row-3,
  .localisation-grid {
    grid-template-columns: 1fr;
  }
  .tab-head {
    overflow-x: auto;
  }
  .fiche-list-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .bilan-layout {
    flex-direction: column;
  }
  .bilan-nav {
    position: static;
    width: 100%;
  }
  .bilan-nav-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  .bilan-nav-title {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  .bilan-nav-link {
    padding: 0.35rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
  }
}
