/* css/pdf-viewer.css - Responsive complet */

/* Visionneuse PDF */
.pdf-viewer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(0.5rem, 3vw, 2rem);
  padding-top: 0;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Breadcrumb - CORRECTION POUR LES CHEMINS LONGS */
.breadcrumb {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  overflow-x: auto;
  white-space: normal; /* Changé de nowrap à normal */
  word-wrap: break-word;
  word-break: break-all; /* Force le découpage des mots longs */
  line-height: 1.5;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  color: white;
  font-weight: bold;
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
}

.breadcrumb > * {
  margin: 0 0.25rem;
}

/* CADRE POUR LE TITRE */
.pdf-header-frame {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 0.75rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.pdf-header-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('../images/logo.png') center/contain no-repeat;
  opacity: 0.05;
  pointer-events: none;
}

.pdf-header-frame h1 {
  color: var(--white);
  margin-bottom: clamp(0.5rem, 1.5vw, 1rem);
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  text-align: center;
  position: relative;
  z-index: 1;
  line-height: 1.2;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Métadonnées dans le cadre - CORRECTION POUR LES CASES */
.pdf-meta-frame {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
  position: relative;
  z-index: 1;
}

.pdf-meta-frame .meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.9rem;
  min-height: 44px; /* Hauteur minimale pour les cases */
  flex-wrap: wrap; /* Permet le retour à la ligne */
  word-break: break-word; /* Découpe les mots longs */
  overflow-wrap: anywhere; /* Permet le découpage n'importe où */
}

.pdf-meta-frame .meta-item i {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0; /* Empêche l'icône de rétrécir */
}

.pdf-meta-frame .meta-item span {
  flex: 1;
  min-width: 0; /* Permet au texte de rétrécir */
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Actions dans le cadre */
.pdf-actions-frame {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.btn {
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 44px; /* Hauteur minimale pour accessibilité */
  word-break: break-word;
  text-align: center;
}

.btn i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.btn-download {
  background: var(--accent);
  color: white;
}

.btn-download:hover {
  background: #ff0000;
  transform: translateY(-2px);
}

.btn-view {
  background: var(--secondary);
  color: white;
}

.btn-view:hover {
  background: #4a5a8a;
  transform: translateY(-2px);
}

.btn-explorer {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-explorer:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-fullscreen {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-fullscreen:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* CONTENEUR PDF.js */
.pdf-viewer-wrapper {
  background: var(--card-bg);
  border-radius: 0.75rem;
  padding: 0;
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  border: 2px solid rgba(255, 255, 255, 0.15);
  min-height: min(70vh, 600px);
  width: 100%;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* Conteneur PDF.js */
.pdfjs-container {
  width: 100%;
  height: min(70vh, 600px);
  position: relative;
  overflow: auto;
  background: linear-gradient(135deg, #071530 0%, #071530 100%);
}

/* Canvas PDF.js */
.pdfjs-canvas {
  display: block;
  margin: 20px auto;
  max-width: calc(100% - 40px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: white;
}

/* Barre de contrôles PDF.js */
.pdfjs-controls {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border-radius: 2rem;
  padding: 0.6rem 1.2rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.pdfjs-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.3rem;
}

.pdfjs-btn:hover {
  background: var(--accent);
  transform: scale(1.1);
  border-color: var(--accent);
}

.pdfjs-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.pdfjs-btn:disabled:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: none;
  border-color: rgba(255, 255, 255, 0.2);
}

.pdfjs-page-info {
  color: white;
  font-size: 0.95rem;
  min-width: 85px;
  text-align: center;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.4rem 0.8rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Indicateur de chargement */
.pdfjs-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  z-index: 10;
}

.pdfjs-loading i {
  font-size: 3.5rem;
  color: var(--accent);
  margin-bottom: 1rem;
  animation: spin 1s linear infinite;
}

.pdfjs-loading p {
  font-size: 1.1rem;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Informations SEO - CORRECTION POUR LES URLS LONGS */
.seo-info {
  background: var(--card-bg);
  border-radius: 0.75rem;
  padding: clamp(0.75rem, 2vw, 1rem);
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.seo-info h3 {
  color: var(--white);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.seo-info p {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.url-display {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.url-display code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 0.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  overflow-x: auto;
  word-break: break-all; /* Découpe les URL longues */
  overflow-wrap: break-word;
  white-space: pre-wrap; /* Garde les retours à la ligne */
  line-height: 1.4;
  min-height: 44px; /* Hauteur minimale */
  display: flex;
  align-items: center;
}

.copy-btn {
  background: var(--secondary);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  width: 100%;
  min-height: 44px;
}

.copy-btn:hover {
  background: #4a5a8a;
}

/* Navigation */
.pdf-navigation {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: clamp(0.75rem, 2vw, 1.5rem);
}

.nav-link {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  min-height: 44px;
  word-break: break-word;
  text-align: center;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* Liste des PDFs */
.pdf-list-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(0.5rem, 3vw, 2rem);
  padding-top: 0;
}

.pdf-list-container h1 {
  color: var(--white);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  word-break: break-word;
}

.subtitle {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: clamp(1rem, 3vw, 1.5rem);
  font-size: 0.95rem;
  word-break: break-word;
}

/* Sections de dossiers - CORRECTION POUR LES NOMS DE DOSSIERS LONGS */
.folder-section {
  background: var(--card-bg);
  border-radius: 0.75rem;
  padding: clamp(0.75rem, 2vw, 1rem);
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: fit-content; /* S'adapte au contenu */
}

.folder-section h3 {
  color: var(--white);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: flex-start; /* Alignement en haut pour plusieurs lignes */
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 1.1rem;
  flex-wrap: wrap; /* Permet le retour à la ligne */
  word-break: break-word; /* Découpe les noms longs */
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.folder-section h3 i {
  flex-shrink: 0;
  margin-top: 0.2rem; /* Alignement avec le texte */
}

.count {
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0.2rem; /* Alignement avec le texte */
}

/* Grille de PDFs - CORRECTION POUR LES TITRES LONGS */
.pdf-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.pdf-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  align-items: flex-start; /* Alignement en haut pour contenu variable */
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  min-height: fit-content; /* S'adapte au contenu */
  height: auto; /* Hauteur automatique */
}

.pdf-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.pdf-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(255, 59, 59, 0.1);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem; /* Alignement avec le texte */
}

.pdf-icon i {
  font-size: 1.25rem;
  color: #ff3b3b;
}

.pdf-info {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: auto;
}

/* Titre des cartes PDF - CORRECTION POUR TITRES LONGS */
.pdf-info h4 {
  color: var(--white);
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* Augmenté à 3 lignes max */
  -webkit-box-orient: vertical;
  max-height: 3.9em; /* 3 lignes * 1.3 line-height */
  min-height: 1.3em; /* Au moins une ligne */
}

/* Métadonnées des cartes PDF - CORRECTION POUR TEXTE LONG */
.pdf-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  align-items: center;
  width: 100%;
}

.pdf-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: normal;
  word-break: break-word;
  flex-shrink: 1;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 100%;
}

/* Pour les très petits écrans mobiles */
@media (max-width: 480px) {
  .pdf-meta {
    gap: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
  
  .pdf-meta span {
    max-width: calc(50% - 0.4rem);
  }
  
  .pdf-card {
    padding: 0.6rem;
    gap: 0.6rem;
  }
  
  .pdf-icon {
    width: 2.2rem;
    height: 2.2rem;
  }
  
  .pdf-icon i {
    font-size: 1.1rem;
  }
  
  .pdf-info h4 {
    font-size: 0.9rem;
    -webkit-line-clamp: 3;
    max-height: 3.6em;
  }
  
  .breadcrumb {
    font-size: 0.85rem;
    line-height: 1.4;
  }
  
  .folder-section h3 {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  
  .count {
    align-self: flex-start;
  }
  
  .pdf-meta-frame .meta-item {
    font-size: 0.85rem;
    min-height: 40px;
  }
  
  .btn, .nav-link {
    font-size: 0.85rem;
    min-height: 40px;
  }
}

/* Pour les écrans extrêmement étroits */
@media (max-width: 360px) {
  .pdf-meta {
    justify-content: space-between;
  }
  
  .pdf-meta span {
    flex-basis: 100%;
    max-width: 100%;
  }
  
  .pdf-card {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
  
  .pdf-icon {
    align-self: flex-start;
  }
  
  .pdf-info {
    width: 100%;
  }
  
  .pdf-info h4 {
    margin-bottom: 0.4rem;
    -webkit-line-clamp: 4;
    max-height: 5.2em;
  }
  
  .pdf-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

/* État vide */
.empty-list {
  text-align: center;
  padding: clamp(2rem, 8vh, 4rem) clamp(1rem, 4vw, 2rem);
  color: rgba(255, 255, 255, 0.6);
}

.empty-list i {
  font-size: clamp(2.5rem, 10vw, 3rem);
  margin-bottom: 1rem;
  color: rgba(255, 255, 255, 0.3);
}

.empty-list h2 {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

/* Erreur */
.pdf-error {
  max-width: 800px;
  margin: clamp(3rem, 15vh, 6rem) auto;
  padding: clamp(1rem, 4vw, 2rem);
  text-align: center;
  background: var(--card-bg);
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pdf-error h1 {
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.5rem;
}

.pdf-error p {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

/* RESPONSIVE POUR PDF.js */
@media (max-width: 768px) {
  .pdf-viewer-wrapper {
    min-height: 60vh;
    border-width: 1px;
  }
  
  .pdfjs-container {
    height: 60vh;
  }
  
  .pdfjs-controls {
    bottom: 0.5rem;
    padding: 0.5rem 1rem;
  }
  
  .pdfjs-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
  }
  
  .pdfjs-page-info {
    font-size: 0.85rem;
    min-width: 75px;
    padding: 0.3rem 0.6rem;
  }
  
  .pdfjs-canvas {
    margin: 15px auto;
    max-width: calc(100% - 30px);
    border-width: 1px;
  }
}

/* Orientation paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .pdf-viewer-wrapper {
    min-height: 75vh;
  }
  
  .pdfjs-container {
    height: 75vh;
  }
  
  .pdfjs-canvas {
    margin: 10px auto;
    max-width: calc(100% - 20px);
  }
}

/* RESPONSIVE - Tablette */
@media (min-width: 768px) {
  .pdf-actions-frame {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn {
    width: auto;
    padding: 0.75rem 1.5rem;
  }
  
  .url-display {
    flex-direction: row;
    align-items: stretch; /* Étire les éléments verticalement */
  }
  
  .url-display code {
    flex: 1;
    min-height: auto;
  }
  
  .copy-btn {
    width: auto;
    padding: 0.75rem 1.5rem;
    min-height: auto;
  }
  
  .pdf-navigation {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .pdf-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 1rem;
  }
  
  .pdf-meta-frame {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }
  
  .pdf-meta-frame .meta-item {
    flex: 0 1 auto;
    min-width: 200px; /* Largeur minimale pour desktop */
  }
  
  .pdf-meta {
    gap: 0.6rem 1.2rem;
  }
  
  .pdf-info h4 {
    -webkit-line-clamp: 3;
    max-height: 3.9em;
  }
}

/* RESPONSIVE - Desktop */
@media (min-width: 1024px) {
  .pdf-actions-frame {
    gap: 0.75rem;
  }
  
  .pdf-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
  }
  
  .pdf-card {
    padding: 1rem;
    gap: 1rem;
  }
  
  .pdf-icon {
    width: 3rem;
    height: 3rem;
  }
  
  .pdf-icon i {
    font-size: 1.5rem;
  }
  
  .pdf-info h4 {
    font-size: 1rem;
    -webkit-line-clamp: 3;
    max-height: 3.9em;
  }
  
  .pdf-meta {
    font-size: 0.85rem;
    gap: 0.75rem 1.5rem;
  }
  
  .pdf-viewer-wrapper {
    border-width: 3px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
  }
  
  .pdfjs-controls {
    padding: 0.7rem 1.4rem;
    gap: 0.9rem;
  }
  
  .pdfjs-btn {
    width: 3rem;
    height: 3rem;
    font-size: 1.4rem;
  }
}

/* Desktop large */
@media (min-width: 1400px) {
  .pdfjs-container {
    height: min(75vh, 700px);
  }
  
  .pdf-viewer-wrapper {
    min-height: min(75vh, 700px);
  }
  
  .pdf-info h4 {
    -webkit-line-clamp: 3;
    max-height: 3.9em;
  }
}