/* Styles pour le visualiseur PDF personnalisé - Version joyeuse et dynamique */
* {
  box-sizing: border-box;
}

body .pdf-viewer-app {
  display: grid;
  grid-template-columns: 130px 1fr 180px;
  gap: 0;
  padding: 0;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pdf-left, .pdf-right {
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border-right: 2px solid #e8eef5;
  padding: 16px;
  overflow-y: auto;
  box-shadow: inset -1px 0 3px rgba(0,0,0,0.05);
}

.pdf-right {
  border-right: none;
  border-left: 2px solid #e8eef5;
  box-shadow: inset 1px 0 3px rgba(0,0,0,0.05);
}

.pdf-center {
  background: linear-gradient(to bottom, #fafbfc 0%, #ffffff 20%, #ffffff 80%, #fafbfc 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.pdf-center::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4361ee, #2eccc5, #4361ee);
  animation: gradient-shift 3s ease-in-out infinite;
}

@keyframes gradient-shift {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 0;
  perspective: 1000px;
}

#pdfCanvas {
  box-shadow: 0 10px 40px rgba(67, 97, 238, 0.15);
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pdfCanvas:hover {
  box-shadow: 0 15px 60px rgba(67, 97, 238, 0.25);
  transform: translateY(-2px);
}

/* Contrôles */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2d3748;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: none;
}

.controls .btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(135deg, #4361ee 0%, #2d5cdc 100%);
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.2);
  position: relative;
  overflow: hidden;
}

.controls .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

.controls .btn:hover::before {
  left: 100%;
}

.controls .btn:hover {
  background: linear-gradient(135deg, #2d5cdc 0%, #1e3a8a 100%);
  box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
  transform: translateY(-2px);
}

.controls .btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.2);
}

/* Pager */
.pager {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px;
  background: rgba(67, 97, 238, 0.05);
  border-radius: 8px;
  border-left: 3px solid #4361ee;
}

.pager button {
  padding: 8px 10px;
  border: 2px solid #e0e7ff;
  background: #fff;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4361ee;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 36px;
}

.pager button:hover {
  background: #4361ee;
  color: #fff;
  border-color: #4361ee;
  transform: scale(1.05);
}

.pager button:active {
  transform: scale(0.98);
}

#pageNum {
  width: 50px;
  padding: 8px;
  border: 2px solid #e0e7ff;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  color: #4361ee;
  transition: all 0.2s ease;
}

#pageNum:focus {
  outline: none;
  border-color: #4361ee;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
  background: #f8faff;
}

/* Zoom */
.zoom {
  margin-top: 12px;
  /* Empiler verticalement les contrôles de zoom pour éviter la confusion */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(46, 204, 197, 0.05);
  border-radius: 8px;
  border-left: 3px solid #2eccc5;
}

.zoom button {
  /* boutons circulaires/compacts empilés */
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #c0f0ed;
  background: #fff;
  cursor: pointer;
  border-radius: 8px;
  font-size: 1rem;
  color: #2eccc5;
  transition: all 0.18s ease;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Réduire la taille des boutons de zoom (desktop) */
.zoom button, .pager button {
  padding: 4px 6px;
  font-size: 0.85rem;
  min-width: 32px;
}

/* Réduire explicitement la taille des boutons de navigation (précédent / suivant) */
#prevBtn, #nextBtn,
#m-prevBtn, #m-nextBtn {
  padding: 4px 6px !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  border-radius: 6px !important;
  font-size: 0.9rem !important;
  border: none !important;
  background: #4361ee !important; /* solid blue */
  color: white !important;
  cursor: pointer !important;
  box-shadow: 0 6px 18px rgba(67,97,238,0.18) !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
  flex: 0 0 auto !important;
}

.zoom button:hover {
  background: #2eccc5;
  color: #fff;
  border-color: #2eccc5;
  transform: scale(1.1);
}

#zoomVal {
  font-size: 0.85rem;
  font-weight: 700;
  color: #2eccc5;
  min-width: 45px;
  text-align: center;
}

/* Thumbnails */
.pdf-right h4 {
  margin: 0 0 12px 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #2d3748;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.thumbnails {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 80px);
}

.thumbnail {
  cursor: pointer;
  border: 2px solid #e8eef5;
  padding: 4px;
  background: #fff;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  position: relative;
}

.thumbnail::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(46, 204, 197, 0.1));
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.thumbnail:hover {
  border-color: #4361ee;
  box-shadow: 0 6px 20px rgba(67, 97, 238, 0.2);
  transform: translateY(-3px) scale(1.02);
}

.thumbnail:hover::before {
  opacity: 1;
}

.thumbnail img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* Message */
.message {
  margin-top: 12px;
  color: #4361ee;
  font-size: 0.85rem;
  font-weight: 600;
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* animation pour la barre mobile */
@keyframes slideUpFadeIn {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 1024px) {
  body .pdf-viewer-app {
    grid-template-columns: 100px 1fr 150px;
    gap: 0;
  }
  
  .pdf-left, .pdf-right {
    padding: 12px;
  }

  .controls .btn {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
}

@media (max-width: 768px) {
  body .pdf-viewer-app {
    grid-template-columns: 60px 1fr;
  }
  
  .pdf-right {
    display: none;
  }
  
  .pdf-left {
    padding: 10px 8px;
    border-right: 2px solid #e8eef5;
  }
  
  .controls {
    gap: 8px;
  }
  
  .controls .btn {
    padding: 6px 8px;
    font-size: 0.7rem;
    border-radius: 6px;
  }
  
  .pager, .zoom {
    padding: 8px;
    gap: 4px;
  }
  
  .pager button, .zoom button {
    padding: 6px 8px;
    font-size: 0.8rem;
    min-width: 30px;
  }
  
  #pageNum {
    width: 45px;
    padding: 6px;
    font-size: 0.8rem;
  }
  
  #zoomVal {
    font-size: 0.75rem;
    min-width: 40px;
  }
  
  .canvas-wrap {
    padding: 12px 0;
  }
  
  #pdfCanvas {
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.15);
  }
}

@media (max-width: 480px) {
  body .pdf-viewer-app {
    grid-template-columns: 1fr;
  }
  
  .pdf-left {
    display: none;
  }
  
  .pdf-center {
    padding: 8px;
  }
  
  .canvas-wrap {
    padding: 8px 0;
  }
  
  #pdfCanvas {
    max-width: 100%;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
  }
}

/* Scrollbar styling */
.thumbnails::-webkit-scrollbar,
.pdf-left::-webkit-scrollbar,
.pdf-right::-webkit-scrollbar,
.pdf-center::-webkit-scrollbar {
  width: 6px;
}

.thumbnails::-webkit-scrollbar-track,
.pdf-left::-webkit-scrollbar-track,
.pdf-right::-webkit-scrollbar-track,
.pdf-center::-webkit-scrollbar-track {
  background: transparent;
}

.thumbnails::-webkit-scrollbar-thumb,
.pdf-left::-webkit-scrollbar-thumb,
.pdf-right::-webkit-scrollbar-thumb,
.pdf-center::-webkit-scrollbar-thumb {
  background: rgba(67, 97, 238, 0.3);
  border-radius: 3px;
}

.thumbnails::-webkit-scrollbar-thumb:hover,
.pdf-left::-webkit-scrollbar-thumb:hover,
.pdf-right::-webkit-scrollbar-thumb:hover,
.pdf-center::-webkit-scrollbar-thumb:hover {
  background: rgba(67, 97, 238, 0.5);
}

/* Mobile controls (fixed bottom bar) */
.mobile-controls {
  display: none;
}

@media (max-width: 768px) {
  .mobile-controls {
    display: flex;
    position: fixed;
    left: 6px;
    right: 6px;
    bottom: 12px;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    z-index: 12000;
    background: linear-gradient(90deg, rgba(255,255,255,0.95), rgba(250,250,255,0.9));
    padding: 6px 6px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(33, 47, 89, 0.12);
    /* appear animation */
    animation: slideUpFadeIn 260ms ease-out both;
  }

  .mobile-controls button {
    padding: 6px 8px;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 0;
    background: linear-gradient(135deg, #4361ee 0%, #2eccc5 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(67,97,238,0.18);
  }

  .mobile-controls .m-pager {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.9);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid #eef6ff;
  }

  .mobile-controls input[type="number"] {
    width: 56px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #e6eefc;
    font-weight: 700;
    color: #4361ee;
    text-align: center;
  }

  /* Mobile prev/next buttons - simplified and compact */
  #m-prevBtn, #m-nextBtn {
    padding: 6px 8px !important;
    width: auto !important;
    height: auto !important;
    min-width: 38px !important;
    border-radius: 6px !important;
    font-size: 0.95rem !important;
    border: none !important;
    background: linear-gradient(135deg, #4361ee 0%, #2eccc5 100%) !important;
    color: white !important;
    cursor: pointer !important;
    box-shadow: 0 6px 18px rgba(67,97,238,0.18) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    flex: 0 0 auto !important;
    /* make them stick to extremes */
    margin-left: 2px !important;
    margin-right: 2px !important;
  }

  #m-prevBtn:hover, #m-nextBtn:hover {
    background: #2d5cdc !important; /* darker blue on hover */
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(67,97,238,0.25) !important;
  }

  #m-prevBtn:active, #m-nextBtn:active {
    transform: translateY(0) !important;
    box-shadow: 0 4px 12px rgba(67,97,238,0.15) !important;
  }

  /* Share button mobile styling */
  #m-shareBtn {
    padding: 6px 8px !important;
    width: auto !important;
    height: auto !important;
    min-width: 38px !important;
    border-radius: 6px !important;
    border: none !important;
    background: linear-gradient(135deg, #4361ee 0%, #2eccc5 100%) !important;
    color: white !important;
    cursor: pointer !important;
    font-size: 0.95rem !important;
    box-shadow: 0 6px 18px rgba(67,97,238,0.18) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
  }

  #m-shareBtn:hover {
    background: linear-gradient(135deg, #2d5cdc 0%, #1e9b8a 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(67,97,238,0.25) !important;
  }

  #m-shareBtn:active {
    transform: translateY(0) !important;
    box-shadow: 0 4px 12px rgba(67,97,238,0.15) !important;
  }

  /* Desktop share button styling */
  #shareBtn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #4361ee 0%, #2eccc5 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #shareBtn:hover {
    background: linear-gradient(135deg, #2d5cdc 0%, #1e9b8a 100%);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
    transform: translateY(-2px);
  }

  #shareBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.2);
  }
}
