/* ==========================================================================
   OPENDATASTREAM — THEME "APP MODERNE"
   Variables attendues : --bg, --text, --violet, --line, --radius, --shadow,
                         --brand, --muted, --easing
   ========================================================================== */

/* =========================
   🧩 STRUCTURE PAGE GLOBALE
   ========================= */
.detail-scope {
  padding: 1.25rem 0 2rem;
  background: var(--bg);
  color: var(--text);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: .75rem;
  color: var(--violet);
}

.detail-title {
  margin: 0;
}

/* ===========================
   ✍️ TEXTE REPLIABLE (INTRO)
   =========================== */
.text-wrapper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
}

.text-wrapper p {
  text-align: justify;
  line-height: 1.6;
}

.text-container {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}

.text-container.expanded {
  -webkit-line-clamp: unset;
}

.text-container::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 60px;
  background: linear-gradient(to top, #fff, transparent);
  pointer-events: none;
}

.text-container.expanded::after {
  display: none;
}

.read-more-container {
  text-align: center;
  margin-top: .75rem;
}

.read-more {
  display: inline-block;
  background: var(--violet);
  color: #fff;
  padding: .45rem 1rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10);
  transition: transform .15s var(--easing), box-shadow .15s var(--easing);
}

.read-more:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}

/* =======================================================
   📦 ACCORDÉON FICHIERS — CONTENEUR / HOVER / ACCESSIBILITÉ
   ======================================================= */
.accordion-file {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: #fff;
  overflow: hidden;
  transition: box-shadow .25s ease, border-color .25s ease, transform .12s ease;
}

.accordion-file:hover {
  border-color: var(--violet);
  box-shadow: 0 6px 22px rgba(96, 80, 220, 0.10);
}

.accordion-file:focus-within {
  outline: 2px solid #e5e7ff;
}

/* ============================
   🧭 FILE HEADER — VERSION PRO
   ============================ */
.file-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 18px 22px;
  min-height: 64px;
  background: #f9fafb;
  border: none;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background .2s ease;
}

.file-header:hover {
  background: #f3f4f6;
}

.file-header:focus-visible {
  outline: 3px solid #cfd4ff;
  outline-offset: 2px;
}

/* Bloc gauche : icône + nom */
.file-title {
  display: flex;
  align-items: center;
  gap: .75rem;
  line-height: 1.3;
  min-width: 0;
  /* pour ellipsis */
}

.file-title .ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 1.15rem;
  line-height: 1;
  transform: translateY(1px);
}

.file-title .name {
  display: inline-block;
  position: relative;
  top: 1px;
  font-weight: 700;
  font-size: 1.05rem;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bloc droite : meta poussée + chevron */
.file-meta {
  margin-left: auto;
  /* pousse à droite */
  margin-right: 8px;
  /* espace avant chevron */
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: #6b7280;
  transform: translateY(1px);
  opacity: .85;
  transition: opacity .2s ease;
}

.file-header:hover .file-meta {
  opacity: 1;
}

.file-header .chevron {
  display: inline-block;
  font-size: 1.15rem;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), opacity .2s ease;
  opacity: .65;
}

/* ======= SVG CHEVRON PREMIUM ======= */
.chevron {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


.chevron-icon {
  width: 18px;
  height: 18px;
  transition: transform .25s ease, opacity .25s ease;
  opacity: 0.7;
}




/* Icône ouverte (affichée quand .accordion-file.active) */
/* Quand ouvert → applique une rotation pour dessiner "⌃" */
.accordion-file.active .icon-closed {
  transform: rotate(-90deg); /* Tourne le chevron vers le haut */
  opacity: 1;
}


/* ===========================
   🧾 CORPS — ANIMATION OUVERTURE
   =========================== */
.accordion-file .file-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 16px;
  /* pads latéraux conservés fermés */
  transition: max-height .45s cubic-bezier(.4, 0, .2, 1), opacity .3s ease, padding-top .2s ease;
  border-top: 1px solid transparent;
  will-change: max-height, opacity;
}

.accordion-file.active .file-body {
  max-height: 2000px;
  /* assez grand pour tout contenu */
  opacity: 1;
  padding-top: 14px;
  /* espace entre header et contenus */
  border-top-color: #e7e7ea;
}

/* ===================
   🏷️ BADGES FICHIERS
   =================== */
.badge {
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: .74rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #374151;
  transition: background .2s ease, border-color .2s ease, transform .12s ease;
}

.badge:hover {
  background: #eef2ff;
  border-color: var(--violet);
  transform: translateY(-1px);
}

.badge-CSV {
  background: #eaf4ff;
  color: #0b6bff;
  border-color: #0b6bff22;
}

.badge-PDF {
  background: #ffebeb;
  color: #d62828;
  border-color: #d6282822;
}

.badge-XLSX {
  background: #eafbea;
  color: #2e7d32;
  border-color: #2e7d3222;
}

.badge-PARQUET {
  background: #fff1e8;
  color: #bf360c;
  border-color: #bf360c22;
}

.badge-IMG,
.badge-JPG,
.badge-JPEG,
.badge-PNG,
.badge-SVG {
  background: #f4eaff;
  color: #6a1b9a;
  border-color: #6a1b9a22;
}

/* ================
   🧭 TABS PREMIUM
   ================ */
.tabs {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #efefef;
  /* séparation subtile sous header */
  margin-bottom: 1rem;
}

.tab {
  padding: .6rem .95rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
  transition: transform .12s var(--easing), background .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.tab:hover {
  background: #f7f7ff;
  transform: translateY(-1px);
}

.tab.active {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .10);
}

.tab:focus-visible {
  outline: 3px solid #cfd4ff;
  outline-offset: 2px;
}

.tab-content {
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1.5rem;
  animation: fadeIn .25s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ===================================
   📥 TÉLÉCHARGEMENT (bouton pilule)
   =================================== */
.downloads {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.pill-btn.dl {
  background: var(--violet);
  color: #fff;
  border-radius: 999px;
  padding: .55rem 1.05rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10);
  transition: transform .15s var(--easing), box-shadow .15s var(--easing), background .2s var(--easing);
}

.pill-btn.dl:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .12);
}

/* ==============================
   💬 COMMENTAIRES — & RÉPONSES
   ============================== */
.comments {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.comments h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .8rem;
  color: var(--text);
}

.comments h3.muted {
  color: var(--muted);
  font-style: italic;
}

.thread {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-item {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: .65rem 0;
}

.comment-item:last-child {
  border-bottom: 0;
}

.comment-meta {
  font-size: .92rem;
  color: var(--muted);
  margin-bottom: .2rem;
}

.comment-author {
  color: var(--brand);
  font-weight: 800;
}

.comment-date {
  opacity: .9;
}

.discussion {
  background: #fdfdfd;
  border: 1px solid var(--line);
  border-left: 4px solid var(--violet);
  border-radius: var(--radius);
  padding: 1rem 1rem .5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
  transition: box-shadow .2s ease, border-color .2s ease;
}

.discussion:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  border-left-color: var(--violet);
}

.discussion+.discussion {
  position: relative;
  margin-top: 24px;
  padding-top: 24px;
}

.discussion+.discussion::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, #ddd, transparent);
  opacity: .6;
}

/* Réponses à plat (sans indentation) */
.reply-flat {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 6px;
  transition: background .2s ease;
}

.reply-flat:hover {
  background: #f3f3f3;
}

.reply-meta {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.reply-meta .reply-label {
  color: var(--text);
  font-weight: 600;
}

.reply-button {
  text-align: right;
  margin-top: .5rem;
}

/* Boutons */
.btn-send-comment {
  background: var(--violet);
  color: #fff;
  border-radius: var(--radius);
  border: none;
  padding: .55rem 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10);
  transition: transform .15s var(--easing), box-shadow .15s var(--easing), background .2s var(--easing);
}

.btn-send-comment:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .12);
}

.btn-send-comment.secondary {
  background: #ef4444;
  color: #fff;
}

.btn-send-comment.secondary:hover {
  background: #dc2626;
}

/* Lien "Répondre" — style bouton */
.reply-button .btn-link {
  background-color: var(--violet);
  color: #fff;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: .85rem;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  transition: background .2s ease, transform .12s ease;
  text-decoration: none;
}

.reply-button .btn-link:hover {
  background-color: #4b4bfa;
  transform: translateY(-2px);
}

.reply-button .btn-link:active {
  transform: scale(.98);
}

.reply-button .btn-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(80, 102, 255, .25);
}

/* Formulaire commentaire */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: .6rem;
  animation: fadeSlideIn .3s ease forwards;
  opacity: 0;
  transform: translateY(-4px);
}

.comment-form:not(.is-hidden) {
  opacity: 1;
}

.comment-form textarea,
.comment-form input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .75rem;
  min-height: 86px;
}

.comment-form .buttons {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

/* ======================
   🧠 API COPY BUTTON
   ====================== */
.api-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.api-wrapper code {
  background: #f4f4f4;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: .9rem;
  border: 1px solid #ddd;
}

.btn-copy {
  background: var(--violet);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: .8rem;
  cursor: pointer;
  transition: .2s ease;
}

.btn-copy:hover {
  opacity: .9;
}

.api-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #222;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: .3s ease;
  font-size: .85rem;
  z-index: 9999;
}

.api-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================
   ✨ ANIMATIONS & UTILITAIRES
   ========================== */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.muted {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

/* ==========================
   📄 INTÉGRATION DU PDF
   ========================= */
.pdf-wrapper {
  width: 100%;
  height: 620px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .05) inset;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==========================
   🔎 DATATABLES (léger skin)
   ========================== */
table.dataTable thead th {
  border-bottom: 1px solid #e5e7eb !important;
}

table.dataTable.no-footer {
  border-bottom: 1px solid #e5e7eb !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--violet) !important;
  color: #fff !important;
  border-radius: var(--radius) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius) !important;
}

/* ==========================
   📱 RWD TWEAKS
   ========================== */
@media (max-width: 720px) {
  .file-header {
    padding: 14px 16px;
  }

  .file-title .name {
    max-width: 60vw;
  }

  .file-meta {
    gap: .35rem;
    font-size: .8rem;
  }

  .tab {
    padding: .5rem .8rem;
    border-radius: var(--radius);
  }

  .pdf-wrapper {
    height: 520px;
  }
}