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

/*--------------------------------------
  PAGE & CONTAINER
--------------------------------------*/
html, body {
  width: 80%;
  min-height: 100%;
  background: #fff;
}
body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: #333;
  line-height: 1.4;
}

/* Centre horizontalement et ajoute du padding */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;   /* auto à gauche/droite = centré */
  padding: 16px 0;  /* seulement verticalement */
}

/*--------------------------------------
  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; }

/*--------------------------------------
  FLASH & STATISTICS
--------------------------------------*/
.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;
}

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

/*--------------------------------------
  TABLEAU
--------------------------------------*/
.table-responsive {
  overflow-x: visible; /* on laisse le page scroller */
  margin-bottom: 16px;
  text-align: center;   /* centre la table inline-block */
}
.stock-table {
  display: inline-table; /* pour permettre text-align:center */
  width: 100%;
  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 SPÉCIALES
--------------------------------------*/
.col-quantite {
  width: 60px;
  text-align: center;
}
body.guest .col-base,
body.guest .col-actions {
  display: none;
}

/*--------------------------------------
  RESPONSIVE (petits écrans)
--------------------------------------*/
@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;
  }
}
/* ============================
   TABLEAU HISTORIQUE
=============================== */
.table-responsive {
  /* on laisse le page scroller, pas de scroll interne */
  overflow-x: visible;
  margin-bottom: 16px;
  text-align: center;
}
.historique-table {
  display: inline-table;
  width: 100%;
  border-collapse: collapse;
}
.historique-table th,
.historique-table td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  white-space: nowrap;
  text-align: left;
}
.historique-table th {
  background: #4CAF50;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
}
.historique-table tr:nth-child(even) {
  background: #f2f2f2;
}

/* Colonnes spécifiques */
.historique-table th.col-date,
.historique-table td.col-date {
  width: 100px;
  text-align: center;
}
.historique-table th.col-action,
.historique-table td.col-action {
  width: 120px;
  text-align: center;
}
.historique-table th.col-quantite,
.historique-table td.col-quantite {
  width: 60px;
  text-align: center;
}
.historique-table th.col-prix,
.historique-table td.col-prix {
  width: 80px;
  text-align: right;
}
.historique-table th.col-utilisateur,
.historique-table td.col-utilisateur {
  width: 120px;
}
.historique-table th.col-acheteur,
.historique-table td.col-acheteur {
  width: 120px;
}
.historique-table th.col-commentaire,
.historique-table td.col-commentaire {
  max-width: 250px;
  word-wrap: break-word;
}