/* ======== Base ======== */
body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 1.5rem;
  background: #f6f6f6;
  color: #333;
}

h1 {
  margin-bottom: 1.5rem;
  text-align: center;
}

h2 {
  margin: 1rem 0;
  text-align: center;
}

input, select, textarea, button {
  font-family: inherit;
}

/* ======== Tables ======== */
.table-container {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

th, td {
  padding: 10px 8px;
  border: 1px solid #ccc;
  text-align: left;
}

th {
  background: #f0f0f0;
}

tr:nth-child(even) {
  background: #fafafa;
}

/* ======== Navigation ======== */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.nav-links a {
  text-decoration: none;
  background: #e9e9e9;
  padding: 8px 12px;
  border-radius: 5px;
  color: #333;
  transition: background 0.2s;
}

.nav-links a:hover {
  background: #d2d2d2;
}

/* ======== Inputs ======== */
input[type="number"],
input[type="text"],
select {
  width: 100px;
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: 2px solid #2196f3;
}

/* ======== Commande checkbox ======== */
.commande-checkbox {
  transform: scale(1.3);
  cursor: pointer;
  accent-color: #2196F3;
}

/* ======== Sections ======== */
.section {
  margin: 1em 0;
  border: 1px solid #ccc;
  padding: 1em;
  border-radius: 5px;
  background: #fff;
}

.section h2 {
  cursor: pointer;
  margin: 0;
}

/* ======== Boutons ======== */
button {
  padding: 8px 14px;
  font-size: 14px;
  background-color: #198754;
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 4px;
}

button:hover {
  background-color: #146c43;
}

.validate-btn {
  background: #28a745;
  color: #fff;
}

.cancel-btn {
  background: #999;
  color: #fff;
}

/* ======== États et alertes ======== */
.alert {
  background-color: #ffe6e6 !important;
}

.ok {
  background-color: #f8fff8 !important;
}

/* ======== Colonnes catégories (Index) ======== */
.col-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
}

.col {
  flex: 1;
  min-width: 420px;
  max-width: 650px;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ======== Barre de recherche ======== */
#searchInput,
.search-bar {
  margin-bottom: 1rem;
  width: 100%;
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #ccc;
}

/* ======== Responsive ======== */
@media screen and (max-width: 1024px) {
  body {
    padding: 1rem;
  }
  .col-container {
    flex-direction: column;
    align-items: stretch;
  }
}

@media screen and (max-width: 768px) {
  table {
    font-size: 14px;
  }
  input[type="number"], input[type="text"], select {
    width: 80px;
  }
}

@media screen and (max-width: 600px) {
  /* Table en blocs empilés */
  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    padding: 0.75rem;
    border-radius: 8px;
    background: #fff;
  }

  td {
    border: none;
    padding: 0.3rem 0;
  }

  td::before {
    content: attr(data-label);
    font-weight: bold;
    display: inline-block;
    width: 45%;
    max-width: 160px;
  }

  input[type="number"],
  input[type="text"] {
    width: 100%;
    box-sizing: border-box;
  }

  button, .validate-btn, .cancel-btn {
    width: 100%;
    margin-top: 5px;
  }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
  }

  .col {
    min-width: auto;
    width: 100%;
  }
}

/* ======== Couleurs pour les analyses ======== */
.risque-haut {
  background-color: #ffd4d4 !important;
}

.risque-faible {
  background-color: #e5ffe5 !important;
}
