/* Plugin QR Generator - Styles isolés */
.qr-wrapper {
  background: rgba(24, 10, 40, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(231, 51, 75, 0.2);
  width: 100%;
  max-width: 450px;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: qr-fade-in-up 0.6s ease-out;
  margin: 20px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}

/* bandeau top */
.qr-wrapper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #e7334b, #764ba2, #667eea);
}

.qr-wrapper h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 24px 0;
  color: #f2f2f2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.qr-wrapper .qr-form {
  width: 100%;
  margin-bottom: 20px;
}

.qr-wrapper .input-group {
  position: relative;
  margin-bottom: 16px;
}

.qr-wrapper .qr-input-text {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  background: rgba(47, 26, 71, 0.8);
  border: 2px solid rgba(231, 51, 75, 0.3);
  border-radius: 12px;
  color: #f2f2f2 !important; /* Force la couleur blanche */
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
  font-family: inherit;
}

.qr-wrapper .qr-input-text:focus {
  border-color: #e7334b;
  box-shadow: 0 0 20px rgba(231, 51, 75, 0.4);
  transform: translateY(-2px);
  color: #f2f2f2 !important; /* Force la couleur même au focus */
}

.qr-wrapper .qr-input-text::placeholder {
  color: rgba(242, 242, 242, 0.5) !important;
  font-weight: 300;
}

/* Force la couleur pour tous les états */
.qr-wrapper .qr-input-text::-webkit-input-placeholder {
  color: rgba(242, 242, 242, 0.5) !important;
}
.qr-wrapper .qr-input-text::-moz-placeholder {
  color: rgba(242, 242, 242, 0.5) !important;
  opacity: 1;
}
.qr-wrapper .qr-input-text:-ms-input-placeholder {
  color: rgba(242, 242, 242, 0.5) !important;
}

.qr-wrapper .btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.qr-wrapper .qr-generate-btn {
  flex: 1;
  min-width: 140px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, #e7334b, #c42a3c);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.qr-wrapper .qr-generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(231, 51, 75, 0.4);
}

.qr-wrapper .qr-generate-btn:active {
  transform: translateY(0);
}

.qr-wrapper .qr-generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.qr-wrapper .clear-btn {
  padding: 16px;
  background: rgba(47, 26, 71, 0.8);
  color: #f2f2f2;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.qr-wrapper .clear-btn:hover {
  background: rgba(67, 36, 91, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

.qr-wrapper .qr-result {
  margin-top: 24px;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-wrapper .qr-result.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.qr-wrapper .qr-code-canvas {
  margin: 16px 0;
  border-radius: 16px;
  border: 2px solid rgba(231, 51, 75, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
  background: white; /* Fond blanc pour le QR code */
  padding: 12px; /* Espace blanc autour du QR code */
  /* Forcer le ratio carré sur tous les appareils */
  width: 360px;
  height: 360px;
  max-width: calc(
    100vw - 120px
  ); /* Marge pour le padding du wrapper + canvas padding */
  max-height: calc(100vw - 120px);
  object-fit: contain; /* Maintenir le ratio sans déformation */
}

.qr-wrapper .qr-code-canvas:hover {
  transform: scale(1.02);
}

.qr-wrapper .qr-download-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 14px;
  box-sizing: border-box;
  width: calc(100% - 32px); /* Marge généreuse de 16px de chaque côté */
  max-width: calc(100% - 32px);
  justify-content: center;
  margin: 0 16px; /* 16px de marge de chaque côté */
}

.qr-wrapper .qr-download-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
  color: white;
}

.qr-wrapper .download-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  align-items: center;
  margin: 0; /* Pas de marge externe */
  padding: 0; /* Pas de padding externe */
}

.qr-wrapper .format-selector {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: rgba(47, 26, 71, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.qr-wrapper .format-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(67, 36, 91, 0.4);
  border: 2px solid transparent;
  min-width: 80px;
  text-align: center;
}

.qr-wrapper .format-option:hover {
  background: rgba(67, 36, 91, 0.6);
  border-color: rgba(231, 51, 75, 0.3);
}

.qr-wrapper .format-option input[type="radio"] {
  display: none;
}

.qr-wrapper .format-option input[type="radio"]:checked + .format-label {
  color: #e7334b;
  font-weight: 600;
}

.qr-wrapper .format-option input[type="radio"]:checked ~ small {
  color: rgba(242, 242, 242, 0.8);
}

.qr-wrapper .format-option:has(input:checked) {
  background: rgba(231, 51, 75, 0.2);
  border-color: #e7334b;
  box-shadow: 0 0 12px rgba(231, 51, 75, 0.3);
}

.qr-wrapper .format-label {
  font-size: 16px;
  font-weight: 500;
  color: #f2f2f2;
  margin-bottom: 4px;
  transition: all 0.3s ease;
}

.qr-wrapper .format-option small {
  font-size: 12px;
  color: rgba(242, 242, 242, 0.6);
  line-height: 1.2;
  transition: all 0.3s ease;
}

.qr-wrapper .loading {
  display: none;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: qr-spin 1s ease-in-out infinite;
  margin: 0 auto;
}

.qr-wrapper .loading.active {
  display: block;
}

.qr-wrapper .error-message {
  color: #ff6b6b;
  font-size: 14px;
  margin-top: 8px;
  display: none;
  font-weight: 500;
  text-align: left;
}

.qr-wrapper .error-message.active {
  display: block;
}

.qr-wrapper .security-info {
  margin: 20px 0 0 0; /* Pas de marge latérale dans le CSS de base */
  padding: 14px;
  background: rgba(47, 26, 71, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  /* Approche différente pour éviter les débordements */
  width: auto; /* Largeur automatique */
  max-width: none; /* Pas de max-width */
  margin-left: 16px !important; /* Force avec important */
  margin-right: 16px !important; /* Force avec important */
  box-sizing: border-box !important; /* Force le box-sizing */
}

.qr-wrapper .security-info h3 {
  color: #667eea;
  font-size: 16px;
  margin: 0 0 8px 0;
  font-weight: 600;
}

.qr-wrapper .security-info p {
  color: rgba(242, 242, 242, 0.7);
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
}

/* === Effet repliable du contenu === */
.qr-collapsible {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s ease, opacity 0.35s ease;
  will-change: max-height, opacity;
}

/* Etat ouvert (opacity transite, max-height géré en JS) */
.qr-wrapper.open .qr-collapsible {
  opacity: 1;
}

/* Optionnel: style de wrapper "fermé" (petite respiration) */
.qr-wrapper.folded {
  padding-bottom: 12px;
}

/* Animations */
@keyframes qr-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes qr-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design Amélioré */

/* Tablettes */
@media (max-width: 768px) {
  .qr-wrapper {
    padding: 28px 24px;
    margin: 15px auto;
    max-width: calc(100vw - 30px);
    border-radius: 20px;
  }

  .qr-wrapper h2 {
    font-size: 26px;
    margin-bottom: 20px;
  }

  .qr-wrapper .qr-input-text {
    padding: 14px 18px;
    font-size: 16px;
  }

  .qr-wrapper .btn-group {
    gap: 10px;
  }

  .qr-wrapper .qr-generate-btn {
    padding: 14px 20px;
    font-size: 15px;
    min-width: 120px;
  }

  .qr-wrapper .clear-btn {
    padding: 14px;
    font-size: 13px;
  }

  .qr-wrapper .security-info {
    padding: 14px;
  }

  .qr-wrapper .qr-code-canvas {
    /* Tablettes - QR code adapté */
    width: 320px;
    height: 320px;
    max-width: calc(100vw - 100px);
    max-height: calc(100vw - 100px);
  }
}

/* Smartphones */
@media (max-width: 480px) {
  .qr-wrapper {
    padding: 24px 20px;
    margin: 10px auto;
    max-width: calc(100vw - 20px);
    border-radius: 18px;
  }

  .qr-wrapper h2 {
    font-size: 24px;
    margin-bottom: 18px;
  }

  .qr-wrapper .qr-input-text {
    padding: 14px 16px;
    font-size: 16px; /* Important pour éviter le zoom sur iOS */
    border-radius: 10px;
  }

  .qr-wrapper .btn-group {
    flex-direction: column;
    gap: 8px;
  }

  .qr-wrapper .qr-generate-btn {
    min-width: auto;
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
  }

  .qr-wrapper .clear-btn {
    width: 100%;
    padding: 14px;
    font-size: 14px;
  }

  .qr-wrapper .format-selector {
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin: 0; /* Pas de marge qui pourrait faire déborder */
  }

  .qr-wrapper .format-option {
    flex-direction: row;
    gap: 8px;
    justify-content: flex-start;
    min-width: auto;
    width: 100%;
    max-width: 100%; /* Empêche le débordement */
    text-align: left;
    padding: 10px 12px;
    box-sizing: border-box; /* Inclut padding dans la largeur */
  }

  .qr-wrapper .format-option small {
    margin-left: auto;
    text-align: right;
  }

  .qr-wrapper .qr-download-link {
    padding: 12px 16px;
    font-size: 13px;
    width: calc(100% - 40px); /* Marge généreuse de 20px de chaque côté */
    margin: 0 20px; /* 20px de marge de chaque côté sur mobile */
  }

  .qr-wrapper .security-info {
    padding: 12px;
    margin-top: 16px;
    width: 90%;
    max-width: 100%; /* Empêche le débordement */
    box-sizing: border-box;
  }

  .qr-wrapper .security-info h3 {
    font-size: 15px;
    margin-bottom: 6px;
  }

  .qr-wrapper .security-info p {
    font-size: 13px;
    line-height: 1.3;
  }

  .qr-wrapper .qr-code-canvas {
    margin: 16px 0; /* Margin vertical augmenté sur mobile */
    border-radius: 12px;
    /* Responsive carré parfait sur mobile */
    width: 280px;
    height: 280px;
    max-width: calc(90vw - 80px); /* Ajusté pour mobile */
    max-height: calc(90vw - 80px);
  }
}

/* Très petits écrans */
@media (max-width: 360px) {
  .qr-wrapper {
    padding: 20px 16px;
    margin: 8px auto;
    max-width: calc(100vw - 16px);
  }

  .qr-wrapper h2 {
    font-size: 22px;
    margin-bottom: 16px;
  }

  .qr-wrapper .qr-input-text {
    padding: 12px 14px;
  }

  .qr-wrapper .qr-generate-btn {
    padding: 14px 18px;
  }

  .qr-wrapper .clear-btn {
    padding: 12px;
  }

  .qr-wrapper .security-info {
    padding: 10px;
    margin: 16px 0 0 0; /* Reset des marges */
    margin-left: 20px !important; /* Force la marge gauche */
    margin-right: 20px !important; /* Force la marge droite */
    width: auto !important; /* Largeur automatique */
    max-width: none !important; /* Pas de contrainte de largeur */
    box-sizing: border-box !important;
  }

  .qr-wrapper .qr-code-canvas {
    /* Très petits écrans - QR code encore plus compact mais carré */
    margin: 14px 0; /* Margin un peu réduit mais présent */
    width: 240px;
    height: 240px;
    max-width: calc(100vw - 60px);
    max-height: calc(100vw - 60px);
  }
}

/* Mode paysage mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .qr-wrapper {
    margin: 5px auto;
    padding: 16px;
  }

  .qr-wrapper h2 {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .qr-wrapper .security-info {
    margin-top: 12px;
    padding: 10px;
  }
}

/* Mode sombre du système */
@media (prefers-color-scheme: dark) {
  .qr-wrapper .qr-input-text {
    color: #f2f2f2 !important;
  }

  .qr-wrapper .qr-input-text::placeholder {
    color: rgba(242, 242, 242, 0.5) !important;
  }
}
