/* ============================================================
   📄 facture.css — Version 2025 harmonisée
   Design moderne + cartes uniformes + DataTable + modales
   ============================================================ */

/* ==================== 🎨 Thème principal ==================== */
:root {
  --primary: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #facc15;
  --bg: #f3f4f6;
  --card: rgba(255, 255, 255, 0.95);
  --text: #111827;
  --border: rgba(0, 0, 0, 0.08);
}

/* ==================== 🧭 GLOBAL ==================== */
body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
}

header {
  background: var(--primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 1.2rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

header button {
  background: #fff;
  color: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

header button:hover {
  background: #f3f4f6;
}

/* ==================== 💠 STAT CARDS ==================== */
/* ==================== 🪟 MODALE (Détail facture, Client, Produit) ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 25px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  position: relative;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 6px;
}

.modal-header h2 {
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
}

.modal-header .close {
  font-size: 22px;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}
.modal-header .close:hover {
  color: var(--danger);
}

/* ==================== 🧾 INPUTS DANS POPUP ==================== */
.input-group {
  display: flex;
  align-items: center;
  background: #f3f4f6;
  border-radius: 8px;
  margin: 8px 0;
  padding: 6px 10px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.input-group i {
  color: var(--primary);
  margin-right: 8px;
  font-size: 15px;
}
.input-group input, .input-group select {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 14px;
  outline: none;
  color: #111;
}

/* ==================== 🧮 TABLE DÉTAIL PRODUITS ==================== */
/* ==================== 🧮 TABLE DÉTAIL PRODUITS ==================== */
#detailTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

#detailTable th {
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 13px;
  text-align: center;
  padding: 6px;
}

#detailTable td {
  border: 1px solid #e5e7eb;
  text-align: center;
  padding: 6px;
  font-size: 13px;
}

/* === Taille réduite pour les petits champs === */
#detailTable input.qte,
#detailTable input.unite,
#detailTable input.tva {
  width: 1.2cm;
  min-width: 0.9cm;
  max-width: 2cm;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 2px;
  font-size: 12px;
  background: #f9fafb;
}

/* === Autres champs inchangés === */
#detailTable input.pu {
  width: 2cm;
}
#detailTable input {
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 3px;
  font-size: 13px;
}

/* === Effet focus moderne === */
#detailTable input:focus {
  outline: 2px solid var(--primary);
  background: #eef2ff;
}

/* ==================== 🔎 Recherche Popup ==================== */
.popup-search {
  width: 90%;
  margin: 10px auto;
  display: block;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
}

.popup-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 5px rgba(37,99,235,0.3);
}

/* ==================== 🧾 Cartes Popup Modernes ==================== */


/* ==================== 🧩 POPUP CLIENTS & PRODUITS ==================== */
/* ==================== 🧍 POPUPS CLIENTS & PRODUITS ==================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  animation: popup-appear 0.3s ease;
}

@keyframes popup-appear {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.close {
  font-size: 24px;
  cursor: pointer;
  color: #333;
  transition: color 0.2s;
}
.close:hover { color: var(--danger); }

/* === Barre de recherche === */
.popup-search {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  margin-bottom: 15px;
  outline: none;
  transition: 0.2s;
}
.popup-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 4px rgba(37, 99, 235, 0.3);
}

/* === Liste des cartes === */
.popup-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  justify-content: center;
  padding-bottom: 10px;
}

.popup-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.popup-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.popup-card img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}
.popup-card b {
  font-size: 14px;
  color: #111;
}
.popup-card small {
  color: #666;
  font-size: 12px;
}

/* ==================== 📱 Responsive Mobile ==================== */
@media (max-width: 600px) {
  .modal-content {
    width: 95%;
    height: 90vh;
    padding: 15px;
  }

  .popup-list {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }

  .popup-card {
    padding: 8px;
    border-radius: 8px;
  }

  .popup-card img {
    width: 60px;
    height: 60px;
  }

  .popup-search {
    font-size: 14px;
    padding: 8px 10px;
  }

  .modal-header h3 {
    font-size: 1rem;
  }
}

/* ==================== 🔘 BOUTONS POPUP ==================== */
.modal-content button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  margin: 6px 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
.modal-content button:hover {
  background: #1d4ed8;
}

/* ==================== 📱 RESPONSIVE POPUPS ==================== */
@media (max-width: 768px) {
  .popup-card {
    width: 45%;
  }
  #detailTable input {
    width: 60px;
  }
}


/* ==================== 🎯 DASHBOARD CARDS MODERNES ==================== */
/* ==================== 💎 DASHBOARD STAT CARDS UNIFORMES ==================== */
.stats-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 20px auto;
  max-width: 1100px;
}

.stat-card {
  width: 230px;
  height: 120px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  border: 1px solid #e5e7eb;
  text-align: center;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
}

/* === Icône === */
.stat-icon {
  font-size: 26px;
  color: #fff;
  border-radius: 10px;
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

/* === Titre === */
.stat-title {
  font-size: 13px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  font-weight: 600;
}

/* === Valeur principale === */
.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #111;
  line-height: 1.1;
}

/* === Valeur secondaire (montant) === */
.stat-subvalue {
  font-size: 14px;
  color: #333;
  font-weight: 600;
  margin-top: 2px;
}

/* === Couleurs des icônes === */
.stat-ca .stat-icon {
  background: linear-gradient(135deg, #16a34a, #22c55e); /* Vert */
}
.stat-tva .stat-icon {
  background: linear-gradient(135deg, #2563eb, #3b82f6); /* Bleu */
}
.stat-payees .stat-icon {
  background: linear-gradient(135deg, #0d9488, #14b8a6); /* Turquoise */
}
.stat-nonpayees .stat-icon {
  background: linear-gradient(135deg, #dc2626, #ef4444); /* Rouge */
}

/* === Mode compact pour mobile === */
@media (max-width: 768px) {
  .stats-container {
    flex-direction: column;
    align-items: center;
  }
  .stat-card {
    width: 90%;
    max-width: 300px;
    height: 110px;
  }
  .stat-title {
    font-size: 12px;
  }
  .stat-value {
    font-size: 22px;
  }
}


/* === Adaptation mobile === */


/* ==================== 🔎 FILTRES ==================== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  background: var(--card);
  border-radius: 10px;
  padding: 10px;
  margin: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.filters label {
  font-weight: 600;
  color: #374151;
}

.filters input,
.filters button {
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
}

.filters button {
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.filters button:hover {
  background: #1d4ed8;
}

/* ==================== 📋 TABLE FACTURES ==================== */
#factureTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  background: var(--card);
}

#factureTable thead {
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: white;
}

#factureTable th, #factureTable td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid #e5e7eb;
}

#factureTable tbody tr:hover {
  background: rgba(37, 99, 235, 0.08);
}

/* === États colorés === */
.etat-paye { background: #d1fae5 !important; }
.etat-partiel { background: #fef9c3 !important; }
.etat-nonpaye { background: #fee2e2 !important; }

/* === Boutons actions === */
.actions button {
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  margin: 0 3px;
  cursor: pointer;
  font-size: 14px;
  color: #fff;
  transition: opacity 0.2s;
}
.edit-btn { background: #3b82f6; }
.delete-btn { background: #ef4444; }
.print-btn { background: #10b981; }
.actions button:hover { opacity: 0.8; }

/* ==================== 🧾 MODALS ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 20px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--primary);
  font-weight: 700;
}
.close {
  font-size: 22px;
  cursor: pointer;
}

/* ==================== 🧩 TABLE DÉTAIL PRODUITS ==================== */
#detailTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: var(--card);
  border-radius: 10px;
}
#detailTable th, #detailTable td {
  border: 1px solid #ddd;
  font-size: 13px;
  text-align: center;
}
#detailTable input {
  width: 70px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 3px;
}

/* ==================== 🔢 TOTALS ==================== */
.total-box {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  background: rgba(243,244,246,0.9);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}

/* ==================== 🧍 POPUPS ==================== */
.popup-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.popup-card {
  background: rgba(255,255,255,0.9);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform .2s;
  width: 130px;
}
.popup-card:hover {
  transform: scale(1.05);
}
.popup-card img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}
/* ==================== 🔍 BARRE DE FILTRE CLIENT ==================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 15px 0;
  background: #f3f4f6;
  padding: 10px;
  border-radius: 8px;
}

.filter-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}

.filter-bar button {
  background: var(--primary, #2563eb);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}

.filter-bar button:hover {
  background: #1e40af;
}

#clearClientFilter {
  background: #e11d48;
}
#clearClientFilter:hover {
  background: #be123c;
}

/* ==================== POPUP CLIENT (FILTRAGE) ==================== */
#clientFilterPopup .modal-content {
  width: 90%;
  max-width: 600px;
}

/* ==================== 📱 RESPONSIVE ==================== */
@media (max-width: 768px) {
  table { font-size: 12px; }
  th, td { padding: 5px; }
  .modal-content { width: 95%; padding: 10px; }
  .stat-card {
    width: 150px;
    height: 100px;
  }
  .stat-value {
    font-size: 22px;
  }
}
