/* ============================================
   CHEKINA SARL - CSS POUR TABLEAUX (tables-styles.css)
   Styles dédiés aux tableaux de concessions, production, etc.
   ============================================ */

/* ========== CONTENEUR DE TABLEAU ========== */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--border-radius-lg, 12px);
  box-shadow: var(--shadow-sm, 0 2px 4px rgba(0,0,0,0.08));
  background: var(--white, #ffffff);
  -webkit-overflow-scrolling: touch;
}

/* ========== TABLEAU GÉNÉRIQUE ========== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-family: var(--font-primary, 'Roboto', sans-serif);
}

/* ========== EN-TÊTE ========== */
table thead {
  background: var(--gradient-primary, linear-gradient(135deg, #0f0f1f 0%, #1a1a3e 100%));
  color: var(--white, #ffffff);
}
table thead th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ========== CORPS DU TABLEAU ========== */
table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--light-gray, #ecf0f1);
  color: var(--text-color, #2c3e50);
  vertical-align: middle;
}

/* ========== LIGNES ALTERNÉES ========== */
table tbody tr:nth-child(odd) {
  background: var(--white, #ffffff);
}
table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* ========== SURVOL DES LIGNES ========== */
table tbody tr:hover {
  background: rgba(233, 69, 96, 0.05) !important;
  transition: background 0.2s ease;
}

/* ========== DERNIÈRE LIGNE (totaux) ========== */
table tbody tr:last-child td {
  border-bottom: none;
}
table tbody tr.total-row,
table tbody tr:last-child {
  background: #f0f0f0 !important;
  font-weight: 700;
}
table tbody tr.total-row td,
table tbody tr:last-child td {
  border-top: 2px solid var(--accent-color, #e94560);
}

/* ========== TABLEAU DES CONCESSIONS ========== */
.concessions-table {
  margin-top: 1.5rem;
}
.concessions-table thead th {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-width: 90px;
}
.concessions-table tbody td:first-child {
  font-weight: 600;
  color: var(--accent-color, #e94560);
}
.concessions-table tbody td:nth-child(4) {
  text-align: center;
}

/* ========== TABLEAU DE PRODUCTION ========== */
.production-table {
  margin-top: 1.5rem;
  font-size: 13px;
}
.production-table thead th {
  background: linear-gradient(135deg, #e94560 0%, #ff6b9d 100%);
  white-space: nowrap;
  padding: 0.75rem;
  min-width: 70px;
  text-align: center;
}
.production-table thead th:first-child,
.production-table thead th:nth-child(2),
.production-table thead th:nth-child(3),
.production-table thead th:nth-child(4),
.production-table thead th:nth-child(5) {
  text-align: left;
}
.production-table tbody td {
  padding: 0.75rem;
  text-align: center;
}
.production-table tbody td:first-child {
  font-weight: 600;
  text-align: left;
}
.production-table tbody td:nth-child(2),
.production-table tbody td:nth-child(3),
.production-table tbody td:nth-child(4),
.production-table tbody td:nth-child(5) {
  text-align: left;
}
.production-table tbody td:last-child {
  font-weight: 600;
}

/* ========== TABLEAU DES COÛTS / INVESTISSEMENTS ========== */
.cost-table td:last-child {
  font-weight: 600;
  color: var(--accent-color, #e94560);
  text-align: right;
}
.cost-table tr:last-child td {
  font-weight: 700;
  font-size: 1.05em;
  border-top: 2px solid var(--accent-color, #e94560);
}
.cost-table tr:last-child td:last-child {
  color: var(--accent-color, #e94560);
  font-size: 1.1em;
}

/* ========== TABLEAU DES FLUX DE TRÉSORERIE ========== */
.cashflow-table {
  font-size: 12px;
}
.cashflow-table thead th {
  text-align: center;
  font-size: 11px;
  padding: 0.6rem 0.5rem;
}
.cashflow-table tbody td {
  text-align: right;
  padding: 0.6rem 0.5rem;
}
.cashflow-table tbody td:first-child {
  text-align: center;
  font-weight: 600;
}
.cashflow-table tbody td:nth-child(2) {
  text-align: center;
}

/* ========== TABLEAUX AVEC BORDURES LÉGÈRES ========== */
.table-bordered table {
  border: 1px solid var(--light-gray, #ecf0f1);
}
.table-bordered table thead th {
  border-bottom: 2px solid var(--accent-color, #e94560);
}
.table-bordered table tbody td {
  border-right: 1px solid var(--light-gray, #ecf0f1);
}
.table-bordered table tbody td:last-child {
  border-right: none;
}

/* ========== TABLEAUX COMPACTS ========== */
.table-compact table thead th {
  padding: 0.5rem 0.6rem;
  font-size: 12px;
}
.table-compact table tbody td {
  padding: 0.4rem 0.6rem;
  font-size: 13px;
}

/* ========== ANIMATION D'APPARITION ========== */
table tbody tr {
  animation: fadeInUp 0.5s ease-out forwards;
  opacity: 0;
}
table tbody tr:nth-child(1) { animation-delay: 0.05s; }
table tbody tr:nth-child(2) { animation-delay: 0.10s; }
table tbody tr:nth-child(3) { animation-delay: 0.15s; }
table tbody tr:nth-child(4) { animation-delay: 0.20s; }
table tbody tr:nth-child(5) { animation-delay: 0.25s; }
table tbody tr:nth-child(6) { animation-delay: 0.30s; }
table tbody tr:nth-child(7) { animation-delay: 0.35s; }
table tbody tr:nth-child(8) { animation-delay: 0.40s; }
table tbody tr:nth-child(9) { animation-delay: 0.45s; }
table tbody tr:nth-child(10) { animation-delay: 0.50s; }
table tbody tr:nth-child(11) { animation-delay: 0.55s; }
table tbody tr:nth-child(12) { animation-delay: 0.60s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== RESPONSIVE - TABLEAUX SUR MOBILE ========== */
@media (max-width: 768px) {
  .table-wrapper {
    margin: 1rem 0;
    border-radius: var(--border-radius-md, 8px);
  }
  table {
    font-size: 12px;
  }
  table thead th {
    padding: 0.6rem 0.5rem;
    font-size: 11px;
  }
  table tbody td {
    padding: 0.6rem 0.5rem;
  }
  .production-table {
    font-size: 11px;
  }
  .production-table thead th {
    padding: 0.4rem 0.3rem;
    min-width: 55px;
    font-size: 10px;
  }
  .production-table tbody td {
    padding: 0.4rem 0.3rem;
  }
  .cashflow-table {
    font-size: 10px;
  }
}

@media (max-width: 600px) {
  /* Transformation des tableaux en cartes sur mobile */
  table thead {
    display: none;
  }
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }
  table tr {
    margin-bottom: 1.2rem;
    border: 1px solid var(--light-gray, #ecf0f1);
    border-radius: var(--border-radius-md, 8px);
    background: var(--white, #ffffff);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-sm, 0 2px 4px rgba(0,0,0,0.06));
  }
  table td {
    text-align: right;
    padding: 0.5rem 1rem;
    position: relative;
    padding-left: 50%;
    border: none;
    border-bottom: 1px solid var(--light-gray, #ecf0f1);
    font-size: 13px;
    background: transparent;
  }
  table td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    font-weight: 700;
    text-align: left;
    color: var(--accent-color, #e94560);
    width: 45%;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  table td:last-child {
    border-bottom: none;
  }
  table tbody tr:hover {
    background: var(--white, #ffffff) !important;
  }
  table tbody tr:nth-child(even) {
    background: var(--white, #ffffff);
  }

  /* Ajout des data-label pour chaque colonne */
  .concessions-table tbody td:nth-child(1)::before { content: "N°"; }
  .concessions-table tbody td:nth-child(2)::before { content: "Permis"; }
  .concessions-table tbody td:nth-child(3)::before { content: "Localisation"; }
  .concessions-table tbody td:nth-child(4)::before { content: "Carrés"; }
  .concessions-table tbody td:nth-child(5)::before { content: "Minéraux"; }

  .production-table tbody td:nth-child(1)::before { content: "N°"; }
  .production-table tbody td:nth-child(2)::before { content: "Localisation"; }
  .production-table tbody td:nth-child(3)::before { content: "Permis"; }
  .production-table tbody td:nth-child(4)::before { content: "Carrés"; }
  .production-table tbody td:nth-child(5)::before { content: "Minéraux"; }
  .production-table tbody td:nth-child(6)::before { content: "10 m"; }
  .production-table tbody td:nth-child(7)::before { content: "20 m"; }
  .production-table tbody td:nth-child(8)::before { content: "40 m"; }

  .cost-table tbody td:nth-child(1)::before { content: "Phase"; }
  .cost-table tbody td:nth-child(2)::before { content: "Montant (USD)"; }

  .cashflow-table tbody td:nth-child(1)::before { content: "Année"; }
  .cashflow-table tbody td:nth-child(2)::before { content: "Minerai (t)"; }
  .cashflow-table tbody td:nth-child(3)::before { content: "Revenus (USD)"; }
  .cashflow-table tbody td:nth-child(4)::before { content: "EBITDA (USD)"; }
  .cashflow-table tbody td:nth-child(5)::before { content: "FCF (USD)"; }
}

/* ========== RESPONSIVE - TRÈS PETIT ÉCRAN ========== */
@media (max-width: 360px) {
  table tr {
    padding: 0.3rem 0;
  }
  table td {
    padding: 0.4rem 0.7rem;
    font-size: 12px;
    padding-left: 45%;
  }
  table td::before {
    font-size: 10px;
    left: 0.7rem;
  }
}

/* ========== IMPRESSION ========== */
@media print {
  .table-wrapper {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
  table {
    font-size: 11pt;
    border-collapse: collapse;
  }
  table thead {
    background: #333 !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  table thead th {
    background: #333 !important;
    color: white !important;
  }
  table tbody tr:nth-child(even) {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  table tbody tr.total-row,
  table tbody tr:last-child {
    background: #e0e0e0 !important;
  }
  table td::before {
    display: none !important;
  }
  table tbody td {
    text-align: left !important;
    padding-left: 0.5rem !important;
  }
  .table-wrapper {
    overflow: visible !important;
  }
}
