body {
  font-family: 'Cairo', sans-serif;
  background: #f9fafb;
  margin: 0;
  padding: 0;
  color: #111827;
}

header {
  background: #2563eb;
  color: white;
  padding: 15px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
}

.add-btn {
  background: #2563eb;
  color: white;
  padding: 10px 18px;
  margin: 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #2563eb;
}

.close {
  cursor: pointer;
  font-size: 1.4rem;
  color: #ef4444;
}

form {
  display: grid;
  gap: 12px;
}

.input-group {
  display: flex;
  align-items: center;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 8px;
}

.input-group i {
  color: #2563eb;
  margin-right: 6px;
  font-size: 0.85rem;
}

.input-group input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.85rem;
  padding: 5px;
}

.submit-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.submit-btn:hover {
  background: #1d4ed8;
}

/* Cards Produits */
.produits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  padding: 20px;
}

.produit-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s;
}

.produit-card:hover {
  transform: translateY(-2px);
}

.produit-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: #f3f4f6;
  flex-shrink: 0;
}

.produit-info {
  flex: 1;
}

.produit-info h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #111827;
}

.produit-meta {
  font-size: 0.8rem;
  color: #374151;
}

.actions {
  margin-top: 5px;
}

.actions button {
  padding: 3px 7px;
  font-size: 0.7rem;
  border-radius: 6px;
  border: none;
  color: white;
  cursor: pointer;
  margin-right: 4px;
}

.edit-btn {
  background: #10b981;
}

.edit-btn:hover {
  background: #059669;
}

.delete-btn {
  background: #ef4444;
}

.delete-btn:hover {
  background: #dc2626;
}

.input-small input {
  width: 60px;
  min-width: 60px;
  max-width: 80px;
  text-align: center;
}

/* Bouton champs avancés */
.toggle-advanced {
  background: #e5e7eb;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
}

.advanced-fields {
  display: none;
}

/* Form Rows (2 colonnes) */
.form-row {
  display: flex;
  gap: 10px;
}

.form-row .input-group {
  flex: 1;
  min-width: 0;
}

/* QR Reader */
#qr-reader {
  width: 100%;
  max-width: 320px;
  margin: 10px auto;
  border: 2px solid #2563eb;
  border-radius: 8px;
  display: none;
}

#qr-reader__scan_region video {
  border-radius: 6px;
}

.scan-btn {
  background: #10b981;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin: 5px auto;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.3s;
}

.scan-btn:hover {
  background: #059669;
  transform: scale(1.05);
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  min-width: 250px;
  position: relative;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px;
  font-size: 14px;
  border-radius: 8px;
}

.search-box input:focus {
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  outline: none;
}

.search-box::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #888;
}

/* Statistiques Produits */
.search-stats-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 15px;
  width: 100%;
  max-width: 1250px;
  margin: 20px auto;
  padding: 0 10px;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.stats-inline {
  display: flex;
  align-items: stretch;
  flex: 3;
  gap: 10px;
  justify-content: space-between;
}

.stat-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-radius: 10px;
  padding: 10px 15px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  color: #fff;
  min-width: 140px;
  min-height: 60px;
  transition: transform 0.3s;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-card i {
  font-size: 1.5rem;
}

.stat-card h4 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: bold;
}

.stat-card p {
  margin: 0;
  font-size: 0.8rem;
}

/* DataTables */
body.table-mode {
  margin: 0;
  padding: 0;
  height: 100vh;
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.table-mode header {
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-shrink: 0;
}

body.table-mode .search-stats-row {
  flex-shrink: 0;
  padding: 10px;
}

body.table-mode #produitsGrid {
  flex: 1;
  width: 100%;
  overflow: auto;
  margin: 0;
  padding: 0;
  display: block;
}

body.table-mode .dataTables_wrapper {
  width: 100% !important;
  height: 100%;
  margin: 0;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  overflow: auto;
}

body.table-mode .dataTables_length,
body.table-mode .dataTables_filter {
  margin-bottom: 10px;
}

body.table-mode .dataTables_scroll {
  height: calc(100% - 50px); /* Adjust for length/filter/buttons height */
  overflow: auto;
}

body.table-mode .dataTables_scrollBody {
  overflow-x: auto !important;
  overflow-y: auto !important;
  height: 100% !important;
}

body.table-mode table.dataTable {
  width: 100% !important;
  min-width: 1300px;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: center;
}

body.table-mode .dataTables_scrollHeadInner,
body.table-mode .dataTables_scrollBody table {
  width: 100% !important;
  min-width: 1350px !important;
}

.dataTables_wrapper {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  background: #fff;
  padding: 10px 20px;
}

.dataTables_wrapper .dt-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.dataTables_wrapper .dataTables_filter {
  float: right !important;
  margin-bottom: 10px;
}

.dataTables_wrapper .dataTables_filter input {
  border-radius: 8px;
  border: 1px solid #ccc;
  padding: 6px 10px;
  font-size: 14px;
  transition: 0.3s;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 4px rgba(37, 99, 235, 0.3);
  outline: none;
}

.dataTables_wrapper .dataTables_paginate,
.dataTables_wrapper .dataTables_info {
  margin-top: 10px !important;
  font-size: 13px;
}

table.dataTable {
  width: 100% !important;
  min-width: 1350px !important;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: center;
  background: white;
}

table.dataTable tbody tr:hover {
  background: #f1f5ff !important;
  transition: 0.2s;
}

table.dataTable thead th {
  background: linear-gradient(90deg, #2563eb, #1e40af);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 10px;
}

table.dataTable tbody td {
  padding: 8px 6px;
  border-bottom: 1px solid #f1f5f9;
}

table.dataTable tbody tr:nth-child(even) {
  background: #f9fafb;
}

table.dataTable tfoot th {
  background: #f8fafc !important;
  font-weight: bold;
  color: #1e293b;
  padding: 10px;
  border-top: 2px solid #e2e8f0;
}

.btn-export {
  background: #2563eb !important;
  color: #fff !important;
  border: none !important;
  border-radius: 6px !important;
  padding: 7px 14px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  transition: 0.2s;
}

.btn-export:hover {
  background: #1e40af !important;
  transform: scale(1.03);
}

/* Barcode Section */
#barcodeSection {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#barcodeSection .modal-content {
  background: #fff;
  padding: 20px 30px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  min-width: 300px;
  max-width: 600px;
  text-align: center;
  animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#barcodeSection .close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 22px;
  color: #444;
  cursor: pointer;
}

/* Barcode Table */
#barcodeTable {
  width: 100%;
  border-collapse: collapse;
  font-family: "Cairo", sans-serif;
  font-size: 14px;
  margin-top: 10px;
}

#barcodeTable th {
  background: #2563eb;
  color: #fff;
  text-align: center;
  padding: 8px;
}

#barcodeTable td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #ddd;
}

#barcodeTable tr:nth-child(even) {
  background: #f3f4f6;
}

#barcodeTable tr:hover {
  background: #e0f2fe;
}

/* Boutons personnalisés */
.btn-action {
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  color: white;
  transition: 0.3s;
}

.btn-edit {
  background-color: #3b82f6;
}

.btn-edit:hover {
  background-color: #1d4ed8;
}

.btn-delete {
  background-color: #ef4444;
}

.btn-delete:hover {
  background-color: #b91c1c;
}

.editable {
  background: #fff;
  border-radius: 4px;
}

.editable:focus {
  outline: 2px solid #60a5fa;
  background-color: #eef6ff;
}

.btn-filter {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: 0.2s;
  font-size: 14px;
}

.btn-filter:hover {
  background: #e5e7eb;
}

.btn-filter.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Bouton Code-barres */
.btn-barcode {
  background: #10b981;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
}

.btn-barcode:hover {
  background: #059669;
}

.btn-add {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  margin-left: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-add:hover {
  background: #1d4ed8;
}

/* Couleurs */
.bg-blue {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.bg-green {
  background: linear-gradient(135deg, #059669, #047857);
}

.bg-orange {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.bg-purple {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-row {
    flex-wrap: wrap;
    justify-content: center;
  }
  .stat-card {
    flex: 1 1 45%;
  }
  table.dataTable {
    min-width: 1000px !important;
  }
}

@media (max-width: 992px) {
  .search-stats-row {
    flex-wrap: wrap;
  }
  .search-box {
    flex: 1 1 100%;
    margin-bottom: 10px;
  }
  .stats-inline {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }
  .stat-card {
    flex: 1 1 48%;
  }
}

@media (max-width: 768px) {
  .dataTables_wrapper {
    width: 98%;
    padding: 10px;
  }
  .dataTables_wrapper .dt-buttons {
    justify-content: center;
    flex-wrap: wrap;
  }
  .dataTables_filter {
    float: none !important;
    text-align: center;
  }
  body.table-mode #produitsGrid {
    height: auto;
  }
}

@media (max-width: 600px) {
  .modal-content {
    max-width: 95%;
    padding: 15px;
  }
  .search-box {
    max-width: 100%;
    padding: 0 8px;
  }
  .search-box input {
    font-size: 13px;
    padding: 7px 10px 7px 30px;
    height: 32px;
  }
  .form-row {
    flex-direction: row;
  }
  .form-row .input-group input {
    font-size: 0.8rem;
    padding: 4px;
  }
  .input-group i {
    font-size: 0.75rem;
  }
  .stat-card {
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  .stat-card {
    flex: 1 1 100%;
  }
}
/* ====== QTE BOX IN DATATABLE ====== */
.qty-box {
  padding: 3px 8px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  font-size: 13px;
  display: inline-block;
  min-width: 40px;
  text-align: center;
}

.qty-green {
  background: #10b981; /* vert */
}
.qty-yellow {
  background: #f59e0b; /* orange */
}
.qty-red {
  background: #ef4444; /* rouge */
}
/* ======= ACTION BUTTONS TABLE ======= */
.edit-btn, .delete-btn, .btn-barcode {
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s ease-in-out;
}

/* Modifier */
.edit-btn {
  background: #2563eb;
  color: white;
}
.edit-btn:hover {
  background: #1e40af;
}

/* Supprimer */
.delete-btn {
  background: #dc2626;
  color: white;
}
.delete-btn:hover {
  background: #b91c1c;
}

/* Barcode button */
.btn-barcode {
  background: #6b7280;
  color: white;
}
.btn-barcode:hover {
  background: #4b5563;
}
.produit-meta i {
  color: #1f3c88;
  font-size: 15px;
  margin-right: 4px;
}
.produit-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  transition: 0.2s ease-in-out;
}
.produit-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.12);
}
.stock-badge {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  color: white;
}

/* ====== QTE BADGE (TABLE + CARDS) ====== */
/* Badge QTE */
/* ===== BADGE QTE STYLE (Identique au style du carte facture) ===== */
/* === QTE SAME STYLE AS .card .total-box === */
.qte-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}

/* أيقونة QTE */
.qte-icon {
    color: #1d4ed8;
    font-size: 16px;
}

/* كلمة QTE */
.qte-label {
    font-size: 13px;
    font-weight: 600;
    color: #1e3a8a;
}

/* صندوق الكمية */
.qte-box {
    background: #f0f9ff;
    border: 1px solid #93c5fd;
    border-radius: 8px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #1d4ed8;
    font-size: 13px;
}
.qte-box i {
    font-size: 15px;
    color: #1d4ed8;
}

   
.card-rupture {
    background: #ffe5e5 !important;   /* Rouge clair */
    border: 1px solid #ef4444 !important;
}

.card-stock {
    background: #e6ffed !important;   /* Vert clair */
    border: 1px solid #10b981 !important;
}



/* icon */

/* ------------------------- */
/* 🔵 HEADER MODERNE         */
/* ------------------------- */
.app-header-modern {
    background: #0d6efd;
    padding: 20px 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    color: white;
    margin-bottom: 15px;
}

.header-inner {
    max-width: 1100px;
    margin: auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 30px;
}

.header-left h2 {
    font-size: 24px;
    font-weight: 700;
}

/* Toggle */
.toggle-label-modern input {
    display: none;
}

.toggle-icon {
    font-size: 22px;
    cursor: pointer;
}

/* Button Ajouter */
.add-btn-modern {
    background: white;
    color: #0d6efd;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.add-btn-modern:hover {
    background: #e9f1ff;
}

/* ------------------------- */
/* 🔍 SEARCH + SCAN          */
/* ------------------------- */
.search-section-modern {
    max-width: 1100px;
    margin: auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.search-container-modern {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 10px 15px;
    border: 1px solid #d8dee9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-container-modern input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 15px;
}

.search-icon-modern {
    color: #6b7280;
}

.btn-scan-modern {
    background: #22c55e;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-scan-modern:hover {
    background: #16a34a;
}

/* ------------------------- */
/* 🔘 FILTERS                */
/* ------------------------- */
.filters-modern {
    max-width: 1100px;
    margin: 15px auto;
    padding: 0 15px;
    display: flex;
    gap: 10px;
}

.btn-filter-modern {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
}

.btn-filter-modern.active,
.btn-filter-modern:hover {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* ------------------------- */
/* 📊 STATS                 */
/* ------------------------- */
.stats-modern {
    max-width: 1100px;
    margin: 10px auto 20px;
    padding: 0 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 15px;
}

.stat-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.stat-box i { font-size: 30px; }

.stat-box.blue { background: linear-gradient(45deg,#2563eb,#1d4ed8); }
.stat-box.green { background: linear-gradient(45deg,#059669,#047857); }
.stat-box.orange { background: linear-gradient(45deg,#d97706,#b45309); }
.stat-box.purple { background: linear-gradient(45deg,#7e22ce,#6d28d9); }
.produit-card h4 {
  font-size: 15px;
  font-weight: 700;
  color: #0d47a1;

  /* منع تجاوز العرض */
  width: 100%;
  white-space: normal;
  word-wrap: break-word;

  /* عرض أقصى */
  max-width: 100%;

  /* قص بعد 2 سطر فقط */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2; 
  -webkit-box-orient: vertical;
}

/* ------------------------- */
/* 📱 RESPONSIVE            */
/* ------------------------- */
@media(max-width:700px) {
    .header-inner { flex-direction: column; gap: 12px; }
    .search-section-modern { flex-direction: column; }
    .btn-scan-modern { width: 100%; justify-content: center; }
    .filters-modern { flex-wrap: wrap; }
}

