/* ============================================
   NIVEAU 12 — LES TABLEAUX
   Styles spécifiques au chapitre des tableaux
   ============================================ */

/* ---------- DÉMO TABLEAUX ---------- */
.demo-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background-color: var(--couleur-blanc);
  border-radius: var(--rayon);
  overflow: hidden;
  box-shadow: var(--ombre);
}

.demo-table th,
.demo-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--couleur-bordure);
}

.demo-table th {
  background-color: var(--couleur-primaire);
  color: var(--couleur-blanc);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.demo-table caption {
  caption-side: top;
  padding: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--couleur-texte);
  text-align: left;
  background-color: #f8fafc;
  border-bottom: 2px solid var(--couleur-bordure);
}

/* ---------- BORDER SEPARATE ---------- */
.table-separate {
  border-collapse: separate;
  border-spacing: 8px;
}

.table-separate th {
  background-color: var(--couleur-secondaire);
  color: var(--couleur-blanc);
}

.table-separate td {
  background-color: #f8fafc;
  border: 1px solid var(--couleur-bordure);
  border-radius: 6px;
}

/* ---------- TABLE FIXED LAYOUT ---------- */
.table-fixed {
  table-layout: fixed;
  width: 100%;
}

.table-fixed col.col-narrow {
  width: 120px;
}

.table-fixed col.col-wide {
  width: auto;
}

.table-fixed col.col-medium {
  width: 200px;
}

/* ---------- VERTICAL ALIGN ---------- */
.table-valign th,
.table-valign td {
  height: 80px;
}

.table-valign .valign-top { vertical-align: top; }
.table-valign .valign-middle { vertical-align: middle; }
.table-valign .valign-bottom { vertical-align: bottom; }

/* ---------- ZEBRA STRIPING ---------- */
.table-zebra th {
  background-color: #334155;
  color: var(--couleur-blanc);
}

.table-zebra tbody tr:nth-child(even) {
  background-color: #f1f5f9;
}

.table-zebra tbody tr:nth-child(odd) {
  background-color: var(--couleur-blanc);
}

.table-zebra tbody tr:hover {
  background-color: #e0f2fe;
}

/* ---------- STICKY HEADER ---------- */
.table-scroll-wrapper {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  margin-bottom: 1.5rem;
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  background-color: var(--couleur-primaire);
  color: var(--couleur-blanc);
  z-index: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ---------- RESPONSIVE TABLE ---------- */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  border-radius: var(--rayon);
  border: 1px solid var(--couleur-bordure);
}

.table-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.table-block .block-header {
  display: none;
}

@media (max-width: 600px) {
  .table-block table,
  .table-block thead,
  .table-block tbody,
  .table-block tr,
  .table-block th,
  .table-block td {
    display: block;
  }

  .table-block thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .table-block tr {
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    margin-bottom: 0.75rem;
    overflow: hidden;
  }

  .table-block td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--couleur-bordure);
    text-align: right;
  }

  .table-block td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    color: var(--couleur-texte-clair);
  }

  .table-block td:last-child {
    border-bottom: none;
  }
}

/* ---------- TABLE MODERNE ---------- */
.table-modern {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  border-radius: var(--rayon);
  overflow: hidden;
  box-shadow: var(--ombre-lg);
}

.table-modern th {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: var(--couleur-blanc);
  padding: 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-modern td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.table-modern tbody tr {
  transition: background-color var(--transition);
}

.table-modern tbody tr:hover {
  background-color: #f1f5f9;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- TABLE SORT ---------- */
.table-sort th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 2rem;
}

.table-sort th .sort-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  opacity: 0.4;
}

.table-sort th.sorted-asc .sort-icon::after {
  content: "▲";
  opacity: 1;
  color: var(--couleur-blanc);
}

.table-sort th.sorted-desc .sort-icon::after {
  content: "▼";
  opacity: 1;
  color: var(--couleur-blanc);
}

.table-sort th:not(.sorted-asc):not(.sorted-desc) .sort-icon::after {
  content: "⇅";
}

/* ---------- TABLE STATUT ---------- */
.statut-badge {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.statut-actif {
  background-color: #dcfce7;
  color: #166534;
}

.statut-inactif {
  background-color: #fee2e2;
  color: #991b1b;
}

.statut-en-attente {
  background-color: #fef9c3;
  color: #854d0e;
}

.statut-premium {
  background-color: #ede9fe;
  color: #5b21b6;
}

/* ---------- TABLE PRICING ---------- */
.table-pricing {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table-pricing th,
.table-pricing td {
  padding: 1.25rem 1rem;
  text-align: center;
  vertical-align: middle;
}

.table-pricing th {
  background-color: #f8fafc;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  border-bottom: 2px solid var(--couleur-bordure);
}

.table-pricing .pricing-header {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: var(--couleur-blanc);
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--rayon) var(--rayon) 0 0;
}

.table-pricing .pricing-header.recommended {
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
}

.table-pricing .pricing-price {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--couleur-texte);
  padding: 1rem;
}

.table-pricing .check::before {
  content: "✓";
  color: var(--couleur-succes);
  font-weight: 700;
}

.table-pricing .cross::before {
  content: "✗";
  color: var(--couleur-erreur);
  font-weight: 700;
}

/* ---------- CALENDAR TABLE ---------- */
.table-calendar {
  border-collapse: separate;
  border-spacing: 2px;
}

.table-calendar th {
  background-color: var(--couleur-primaire);
  color: var(--couleur-blanc);
  text-align: center;
  padding: 0.5rem;
}

.table-calendar td {
  text-align: center;
  padding: 0.5rem;
  background-color: #f8fafc;
  border-radius: 4px;
  min-width: 40px;
  cursor: pointer;
  transition: all var(--transition);
}

.table-calendar td:hover {
  background-color: #dbeafe;
}

.table-calendar td.today {
  background-color: var(--couleur-primaire);
  color: var(--couleur-blanc);
  font-weight: 700;
}

.table-calendar td.other-month {
  opacity: 0.3;
}

/* ---------- TABLE DATA TABLE ---------- */
.table-data {
  width: 100%;
  border-collapse: collapse;
}

.table-data th {
  background-color: #f1f5f9;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--couleur-texte-clair);
  border-bottom: 2px solid var(--couleur-bordure);
  padding: 0.75rem 1rem;
}

.table-data td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.table-data tbody tr {
  transition: background-color var(--transition);
}

.table-data tbody tr:hover {
  background-color: #f8fafc;
}

.table-data .cell-id {
  font-family: var(--police-code);
  font-size: 0.85rem;
  color: var(--couleur-texte-clair);
}

.table-data .cell-name {
  font-weight: 600;
  color: var(--couleur-texte);
}

.table-data .cell-email {
  color: var(--couleur-texte-clair);
  font-size: 0.9rem;
}

/* ---------- AVATAR DANS TABLE ---------- */
.table-avatar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.table-avatar .avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
  color: var(--couleur-blanc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}
