/**
 * 2024 Change Vivienne
 *
 * Module pour afficher les produits en tableau
 *
 * @author    Simon Taeib
 * @copyright 2024 Change Vivienne
 * @license   Commercial license
 */

.product-table-container {
  margin-bottom: 2rem;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
}

.product-table th {
  background-color: #f5f5f5;
  padding: 10px;
  font-weight: bold;
  text-align: center;
}

.product-table td {
  padding: 10px;
  vertical-align: middle;
  border: 1px solid #ddd;
}

.product-row:hover {
  background-color: #f9f9f9;
}

/* Colonne image */
.product-image {
  width: 80px;
  text-align: center;
}

.product-image img {
  max-width: 70px;
  max-height: 70px;
  object-fit: contain;
}

/* Colonne nom du produit */
.product-name {
  font-weight: 500;
}

.product-link {
  color: #333;
  text-decoration: none;
}

.product-link:hover {
  color: #2fb5d2;
  text-decoration: underline;
}

/* Styles pour les boutons et contrôles */
.product-sell .sell-controls,
.product-buy .buy-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.qty-btn {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
}

.qty-btn:hover {
  background: #f0f0f0;
}

.qty-btn.plus {
  color: #28a745;
}

.qty-btn.minus {
  color: #dc3545;
}

.rp-qty-box {
  width: 50px;
  height: 30px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 3px;
}

/* Boutons d'achat/vente */
.product-buy .price-btn {
  background: #fff;
  color: #dc3545;
  border: 1px solid #dc3545;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.product-buy .price-btn:hover {
  background-color: #dc3545;
  color: #fff;
}

.product-sell .price-btn {
  background: #fff;
  color: #28a745;
  border: 1px solid #28a745;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.product-sell .price-btn:hover {
  background-color: #28a745;
  color: #fff;
}

/* Loader pour les boutons */
.price-btn.rp-processing {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.price-btn.rp-processing::after {
  content: "";
  display: inline-block;
  margin-left: 0.5rem;
  width: 1em;
  height: 1em;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: rp-spin 0.6s linear infinite;
}

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

/* ===== MOBILE : Card layout avec wrap achat/vente ===== */
@media (max-width: 767px) {
  /* Supprimer le scroll */
  .product-table-container .table-responsive {
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  .product-table {
    display: block !important;
    overflow: visible !important;
  }

  /* Cacher l'en-tête */
  .product-table thead {
    display: none !important;
  }

  .product-table tbody {
    display: block;
  }

  /* Chaque ligne = une carte */
  .product-table tr.product-row {
    display: grid !important;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    row-gap: 0;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    margin-bottom: 14px;
    padding: 12px 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }

  .product-table td {
    border: none !important;
    display: block !important;
  }

  /* Image (gauche de la ligne produit) */
  .product-table td.product-image {
    grid-column: 1;
    grid-row: 1;
    width: 60px;
    padding: 4px !important;
  }

  .product-table td.product-image img {
    max-width: 55px;
    max-height: 55px;
  }

  /* Nom produit (droite de l'image) */
  .product-table td.product-name,
  .product-table td:nth-child(2):not(.product-buy):not(.product-sell) {
    grid-column: 2;
    grid-row: 1;
    display: flex !important;
    align-items: center;
    padding: 4px !important;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0 !important;
    margin-bottom: 6px;
    padding-bottom: 10px !important;
  }

  /* Achat (colonne gauche sous le produit) */
  .product-table td.product-buy,
  .product-table td:nth-child(3) {
    grid-column: 1 / 2;
    grid-row: 2;
    text-align: center;
    background: rgba(220, 53, 69, 0.05);
    border-radius: 6px;
    padding: 10px 6px !important;
  }

  .product-table td.product-buy::before,
  .product-table td:nth-child(3)::before {
    content: 'Achat';
    display: block;
    font-weight: 700;
    color: #dc3545;
    font-size: 0.75em;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
  }

  /* Vente (colonne droite sous le produit) */
  .product-table td.product-sell,
  .product-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    text-align: center;
    background: rgba(40, 167, 69, 0.05);
    border-radius: 6px;
    padding: 10px 6px !important;
  }

  .product-table td.product-sell::before,
  .product-table td:nth-child(4)::before {
    content: 'Vente';
    display: block;
    font-weight: 700;
    color: #28a745;
    font-size: 0.75em;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
  }

  /* Contrôles compacts */
  .product-sell .sell-controls,
  .product-buy .buy-controls {
    flex-direction: column;
    gap: 6px;
    align-items: center;
  }

  .rp-qty-box {
    width: 42px;
    height: 34px;
    font-size: 0.85rem;
  }

  .qty-btn {
    width: 30px;
    height: 30px;
  }

  .price-btn {
    padding: 4px 10px;
    font-size: 0.85rem;
    height: 34px;
    width: auto;
  }
}

/* Très petit écran */
@media (max-width: 400px) {
  .product-table td.product-image {
    width: 45px;
  }

  .product-table td.product-image img {
    max-width: 40px;
    max-height: 40px;
  }
} 