/* ------------------------
   RESET MINIMAL
------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ------------------------
   TYPÉGRAPHIE & PAGE
------------------------- */
body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #fff;
  color: #333;
  line-height: 1.4;
  margin: 0;
  padding: 0;
}
.container {
  width: 90%;
  max-width: center;
  margin: 16px auto;
  padding: 16px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ------------------------
   HEADER & BADGE
------------------------- */
.header-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.header-top h1 {
  font-size: 1.8rem;
  color: #4CAF50;
  flex: 1 1 auto;
}
.username {
  padding: 4px 8px;
  border-radius: 6px;
  color: #fff;
  font-weight: bold;
  flex: 0 0 auto;
}
.username-admin { background: #e74c3c; }
.username-user  { background: #3498db; }

/* ------------------------
   MESSAGE FLASH & STATS
------------------------- */
.flash {
  background: #e0ffe0;
  border-left: 4px solid #4CAF50;
  padding: 8px;
  margin-bottom: 16px;
  border-radius: 6px;
}
.header-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.header-info div {
  background: #f2f2f2;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: bold;
  flex: 1 1 auto;
}

/* ------------------------
   ACTIONS & BOUTONS
------------------------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.btn {
  padding: 8px 14px;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary {
  background: #4CAF50;
}
.btn-primary:hover {
  background: #45a049;
}
.btn-danger {
  background: #f44336;
}
.btn-danger:hover {
  background: #c0392b;
}
.btn.small {
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* ------------------------
   CHAMP DE RECHERCHE
------------------------- */
.search-input {
  width: 100%;
  padding: 8px;
  margin-bottom: 16px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

/* ------------------------
   TABLEAU PRINCIPAL
------------------------- */
.table-responsive {
  overflow-x: visible; 
  margin-bottom: 16px;
  text-align: center;   /* pour centrer la table inline-block */
}
.stock-table {
  display: inline-table;
  width: 80%;
  border-collapse: collapse;
}
.stock-table th,
.stock-table td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  white-space: nowrap;
}
.stock-table th {
  background: #4CAF50;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
}
.stock-table tr:nth-child(even) {
  background: #f2f2f2;
}

/* Colonnes fixes */
.col-quantite {
  width: 60px;
  text-align: center;
}
body.guest .col-base,
body.guest .col-actions {
  display: none;
}

/* ------------------------
   INDICATEUR DE TRI
------------------------- */
.stock-table th.asc::after,
.stock-table th.desc::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
}
.stock-table th.asc::after {
  border-bottom-color: #fff;
  margin-top: -2px;
}
.stock-table th.desc::after {
  border-top-color: #fff;
  margin-top: -8px;
}
.stock-table th {
  position: relative;
  padding-right: 24px; /* espace pour le chevron */
}

/* ------------------------
   RESPONSIVE (écran ≤768px)
------------------------- */
@media (max-width: 768px) {
  .header-top,
  .header-info,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .stock-table th,
  .stock-table td {
    padding: 4px 6px;
    font-size: 0.85rem;
  }
}
