/**
 * WIDGET EXPERT SSIAP - Styles
 * Harmonisé avec les couleurs du logo Prépa-SSIAP
 * Bleu #2B5A9E, Rouge #C41E3A, Or #D4AF37
 */

/* === CONTENEUR PRINCIPAL === */
#ssiap-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* === BOUTON FLOTTANT === */
#ssiap-widget-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  /* Dégradé rouge SSIAP harmonisé */
  background: linear-gradient(135deg, #C41E3A 0%, #A01830 100%);
  border: 3px solid rgba(212, 175, 55, 0.3);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Animation pulsation */
#ssiap-widget-btn::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
  animation: pulse 2s ease-in-out infinite;
  z-index: -1;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.2);
    opacity: 0;
  }
}

#ssiap-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(196, 30, 58, 0.6);
  border-color: rgba(212, 175, 55, 0.6);
}

#ssiap-widget-btn:active {
  transform: scale(0.95);
}

/* === ICÔNE FLAMME === */
#ssiap-widget-btn .flame-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
  animation: flameFlicker 1.5s ease-in-out infinite;
}

@keyframes flameFlicker {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.05) rotate(-2deg);
  }
  50% {
    transform: scale(0.95) rotate(2deg);
  }
  75% {
    transform: scale(1.05) rotate(-1deg);
  }
}

/* === TOOLTIP "EXPERT SSIAP" === */
#ssiap-widget-btn::after {
  content: 'Expert SSIAP 🎓';
  position: absolute;
  right: 75px;
  background: linear-gradient(135deg, #2B5A9E 0%, #1A3A5C 100%);
  color: white;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(212, 175, 55, 0.5);
}

#ssiap-widget-btn:hover::after {
  opacity: 1;
  visibility: visible;
  right: 70px;
}

/* === BADGE NOTIFICATION (Optionnel) === */
#ssiap-widget-btn .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #D4AF37;
  color: #1A3A5C;
  font-size: 10px;
  font-weight: bold;
  padding: 4px 7px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 2px solid white;
}

/* === FENÊTRE DU CHAT === */
#ssiap-chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 400px;
  height: 600px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid;
  border-image: linear-gradient(135deg, #C41E3A 0%, #D4AF37 50%, #2B5A9E 100%) 1;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#ssiap-chat-window.active {
  display: flex;
}

/* === EN-TÊTE DU CHAT === */
#ssiap-chat-header {
  /* Dégradé harmonisé Rouge-Or-Bleu */
  background: linear-gradient(135deg, #C41E3A 0%, #D4AF37 50%, #2B5A9E 100%);
  color: white;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#ssiap-chat-header .header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

#ssiap-chat-header .header-title > span {
  font-size: 24px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

#ssiap-chat-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#ssiap-chat-header p {
  margin: 3px 0 0 0;
  font-size: 12px;
  opacity: 0.95;
  font-weight: 500;
}

/* === BOUTON FERMER === */
#ssiap-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-weight: bold;
}

#ssiap-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* === CORPS DU CHAT (IFRAME) === */
#ssiap-chat-body {
  flex: 1;
  position: relative;
  background: white;
  background-image: url('../images/logo-prepa-ssiap.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 60%;
  background-blend-mode: multiply;
}

/* Overlay pour effet filigrane */
#ssiap-chat-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0.7;
  pointer-events: none;
  z-index: 1;
}

#ssiap-chat-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

/* === LOADER === */
#ssiap-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #2B5A9E;
  z-index: 10;
  background: rgba(255, 255, 255, 0.95);
  padding: 30px 40px;
  border-radius: 15px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
}

#ssiap-loader .spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #C41E3A;
  border-right: 4px solid #D4AF37;
  border-bottom: 4px solid #2B5A9E;
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  margin: 0 auto 15px;
}

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

#ssiap-loader p {
  font-size: 14px;
  font-weight: 600;
  color: #1A3A5C;
  margin: 0;
}

/* === RESPONSIVE MOBILE === */
@media (max-width: 768px) {
  #ssiap-chat-window {
    width: calc(100% - 30px);
    height: calc(100vh - 120px);
    right: 15px;
    bottom: 85px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  #ssiap-widget-btn {
    width: 56px;
    height: 56px;
    bottom: 15px;
    right: 15px;
  }
  
  #ssiap-widget-btn .flame-icon {
    font-size: 26px;
  }
  
  #ssiap-widget-btn::after {
    display: none; /* Masquer le tooltip sur mobile */
  }
  
  #ssiap-chat-window {
    width: calc(100% - 20px);
    height: calc(100vh - 100px);
    right: 10px;
    bottom: 80px;
    border-radius: 12px;
  }
  
  #ssiap-chat-header {
    padding: 14px 16px;
  }
  
  #ssiap-chat-header h3 {
    font-size: 15px;
  }
  
  #ssiap-chat-header p {
    font-size: 11px;
  }
}

/* === MASQUAGE SUR PAGES QUIZ === */
body.quiz-page #ssiap-widget-container,
body.quiz-page #ssiap-chat-window,
[data-page="quiz"] #ssiap-widget-container,
[data-page="quiz"] #ssiap-chat-window {
  display: none !important;
}

/* === ACCESSIBILITÉ === */
#ssiap-widget-btn:focus,
#ssiap-close-btn:focus {
  outline: 3px solid #D4AF37;
  outline-offset: 2px;
}

/* === ANIMATION D'ENTRÉE === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#ssiap-widget-container {
  animation: fadeIn 0.5s ease 0.5s both;
}
