/* ============================================================================
   TEMPLATES PAGE STYLES - PDF Builder Pro
   Style moderne inspiré de l'onglet Canvas avec préfixe pdfb-
   ============================================================================ */

/* Container principal */
.pdfb-templates-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

/* Header avec actions */
.pdfb-templates-header {
  background: #667eea;
  border-radius: 16px;
  padding: 32px 40px;
  color: white;
  margin-bottom: 32px;
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.pdfb-templates-header-left h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
  color: white;
}

.pdfb-templates-header-left p {
  margin: 0;
  font-size: 15px;
  opacity: 0.95;
  color: white;
}

.pdfb-templates-header-right .button {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  background: white;
  color: #667eea;
  border: none;
  transition: all 0.2s;
}

.pdfb-templates-header-right .button:hover {
  background: #f8fafc;
  transform: scale(1.05);
}

/* Barre de filtres */
.pdfb-templates-filters {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px 28px;
  margin-bottom: 28px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pdfb-templates-filters strong {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.pdfb-filter-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.pdfb-filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
  background: #f0f4ff;
}

.pdfb-filter-btn.pdfb-active {
  background: #667eea;
  color: white;
  border-color: transparent;
}

/* Notifications */
.pdfb-notice-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 28px;
  position: relative;
}

.pdfb-notice-warning h4 {
  margin: 0 0 12px;
  color: #856404;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdfb-notice-warning p {
  margin: 0 0 16px;
  color: #856404;
  line-height: 1.6;
}

.pdfb-notice-dismiss {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #856404;
  cursor: pointer;
  padding: 8px;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s;
}

.pdfb-notice-dismiss:hover {
  color: #533f03;
  transform: scale(1.1);
}

/* Liste de templates */
.pdfb-templates-list {
  margin-top: 28px;
}

/* Grille de templates */
.pdfb-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.pdfb-template-card {
    position: relative;
    min-height: 350px;
    padding: 20px;
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.pdfb-template-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  border-color: #667eea;
}

.pdfb-template-card.pdfb-template-card-excess {
  background: #f8f8f8;
  opacity: 0.6;
  cursor: default;
}

.pdfb-template-card.pdfb-template-card-excess:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-color: #dee2e6;
}

.pdfb-template-card-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pdfb-template-type-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.pdfb-template-card-top {
  text-align: center;
  margin: 40px 0 15px;
}

.pdfb-template-card-preview-wrap {
  text-align: center;
  color: #999999;
}

.pdfb-template-card-preview-icon {
  font-size: 2rem;
  margin-bottom: 5px;
}

.pdfb-template-card-preview-label {
  font-size: 11px;
}

.pdfb-template-card-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 12px;
  color: #666666;
  flex-grow: 1;
}

.pdfb-template-card-action-row {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.pdfb-template-card-action-row .button {
  flex: 1;
  font-size: 16px;
}

.pdfb-template-card-action-row .button-danger {
  background-color: #dc3545;
  border-color: #dc3545;
  color: #ffffff;
}

.pdfb-template-card-action-center {
  flex: 1;
  text-align: center;
}

.pdfb-template-excess-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #dc3545;
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pdfb-default-template-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.pdfb-template-preview {
  position: relative;
  width: 100%;
  padding-top: 70.7%; /* Ratio A4 */
  background: #f8fafc;
  overflow: hidden;
}

.pdfb-template-preview img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdfb-template-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  background: #667eea;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pdfb-template-badge.pdfb-pro {
  background: #f59e0b;
}

.pdfb-template-badge.pdfb-new {
  background: #10b981;
}

.pdfb-template-info {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pdfb-template-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

.pdfb-template-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #64748b;
}

.pdfb-template-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdfb-template-description {
  margin: 0 0 16px;
  font-size: 14px;
  color: #475569;
  line-height: 1.6;
  flex: 1;
}

.pdfb-template-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pdfb-template-tag {
  padding: 4px 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.pdfb-template-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.pdfb-template-actions .button {
  flex: 1;
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s;
}

.pdfb-template-actions .button-primary {
  background: #667eea;
  color: white;
  border: none;
}

.pdfb-template-actions .button-primary:hover {
  background: #5568d3;
  transform: scale(1.02);
}

.pdfb-template-actions .button-secondary {
  background: white;
  color: #667eea;
  border: 1px solid #667eea;
}

.pdfb-template-actions .button-secondary:hover {
  background: #f0f4ff;
  transform: scale(1.02);
}

/* Modal styles */
.pdfb-template-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.pdfb-template-modal-overlay.pdfb-show {
  display: flex;
}

.pdfb-template-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 90%;
  width: 1200px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal paramètres du template : plus étroit que la galerie */
#template-settings-modal .pdfb-template-modal-content {
  width: 680px;
}

.pdfb-template-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 36px;
  border-bottom: 1px solid #e2e8f0;
  background: #667eea;
  color: white;
}

.pdfb-template-modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: white;
}

.pdfb-template-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.pdfb-template-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.pdfb-template-modal-body {
  padding: 32px 36px;
  overflow-y: auto;
  max-height: calc(90vh - 200px);
}

.pdfb-template-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 36px;
  border-top: 1px solid #e2e8f0;
  background: #f8f9fa;
}

.pdfb-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  justify-content: center;
  align-items: center;
}

.pdfb-modal-overlay.pdfb-show {
  display: flex;
}

.pdfb-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.pdfb-modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #667eea;
  color: white;
  border-radius: 16px 16px 0 0;
}

.pdfb-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: white;
}

.pdfb-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.pdfb-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.pdfb-modal-body {
  padding: 28px 32px;
}

/* Gallery filters dans le modal */
.pdfb-gallery-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.pdfb-gallery-filter-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.pdfb-gallery-filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
  background: #f0f4ff;
}

.pdfb-gallery-filter-btn.pdfb-active {
  background: #667eea;
  color: white;
  border-color: transparent;
}

/* Gallery grid dans le modal */
.pdfb-template-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.pdfb-template-gallery-modal.pdfb-show {
  display: flex;
}

/* Responsive */
@media (max-width: 768px) {
  .pdfb-templates-header {
    padding: 24px;
  }

  .pdfb-templates-header h1 {
    font-size: 24px;
  }

  .pdfb-templates-grid {
    grid-template-columns: 1fr;
  }

  .pdfb-template-modal-content {
    width: 95%;
  }

  .pdfb-template-modal-header,
  .pdfb-template-modal-body,
  .pdfb-template-modal-footer {
    padding: 20px;
  }
}

/* Animations */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pdfb-template-card:nth-child(1) {
  animation-delay: 0.05s;
}
.pdfb-template-card:nth-child(2) {
  animation-delay: 0.1s;
}
.pdfb-template-card:nth-child(3) {
  animation-delay: 0.15s;
}
.pdfb-template-card:nth-child(4) {
  animation-delay: 0.2s;
}
.pdfb-template-card:nth-child(5) {
  animation-delay: 0.25s;
}
.pdfb-template-card:nth-child(6) {
  animation-delay: 0.3s;
}

/* ============================================================
   GALLERY MODAL — classes remplaçant les styles inline
   ============================================================ */
.pdfb-gallery-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.pdfb-gallery-modal-box {
  background: #fff;
  border-radius: 12px;
  -webkit-border-radius: 12px;
  -moz-border-radius: 12px;
  padding: 0;
  max-width: 1200px;
  width: 95%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  -webkit-box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  -moz-box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.pdfb-gallery-modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.pdfb-gallery-modal-subtitle {
  margin: 5px 0 0 0;
  opacity: 0.8;
  font-size: 14px;
  color: var(--pdf-text);
}

.pdfb-gallery-close-btn {
  background: var(--pdf-border);
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--pdf-secondary);
  padding: 8px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdfb-gallery-body {
  padding: 30px;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}

.pdfb-gallery-filters-section {
  margin-bottom: 30px;
}

.pdfb-gallery-filters-title {
  margin: 0 0 15px 0;
  color: #23282d;
  font-size: 16px;
}

.pdfb-gallery-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pdfb-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 25px;
}

.pdfb-predefined-template-card {
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
}

.pdfb-gallery-card-image {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pdfb-gallery-card-icon {
  font-size: 4rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.pdfb-gallery-type-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(255,255,255,0.9);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}

.pdfb-gallery-premium-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: #ffd700;
  color: #000;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: bold;
}

.pdfb-gallery-card-body {
  padding: 20px;
}

.pdfb-gallery-card-title {
  margin: 0 0 10px 0;
  color: #23282d;
  font-size: 18px;
}

.pdfb-gallery-card-desc {
  margin: 0 0 15px 0;
  color: #666;
  font-size: 14px;
}

.pdfb-gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.pdfb-gallery-tag {
  background: #f0f8ff;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.pdfb-gallery-load-btn {
  width: 100%;
  border-radius: 6px;
}

/* No-templates placeholder */
.pdfb-no-templates-placeholder {
  display: none;
  text-align: center;
  padding: 40px;
  color: var(--pdf-secondary);
}

.pdfb-no-templates-placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
