/* =============================================================================
   WIDGETS WEB — Styles pour les widgets fonctionnels version web
   Chat Twitch, caméra, input viewer, cadres SVG, bulles d'aide Streamy
   ============================================================================= */

/* ==================== Bannière Streamy : "OBS Studio doit être ouvert" ==================== */
.banniere-obs-streamy {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: 560px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(9, 14, 28, 0.98), rgba(5, 9, 18, 0.99));
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(239, 68, 68, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.7),
    0 8px 24px rgba(239, 68, 68, 0.15);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
  pointer-events: none;
}

.banniere-obs-streamy.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.banniere-streamy-img {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 12px;
  filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.3));
  animation: streamy-pulse 2s ease-in-out infinite;
}

@keyframes streamy-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.banniere-streamy-contenu {
  flex: 1;
  min-width: 0;
}

.banniere-streamy-titre {
  font-size: 16px;
  font-weight: 800;
  color: #fca5a5;
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.banniere-streamy-texte {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 14px;
}

.banniere-streamy-texte strong {
  color: #fca5a5;
  font-weight: 700;
}

.banniere-streamy-texte em {
  color: #67e8f9;
  font-style: normal;
  font-weight: 600;
}

.banniere-streamy-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.banniere-streamy-btn {
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.banniere-streamy-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  transform: translateY(-1px);
}

.banniere-streamy-btn-lien {
  background: rgba(103, 232, 249, 0.1);
  border-color: rgba(103, 232, 249, 0.3);
  color: #67e8f9;
}

.banniere-streamy-btn-lien:hover {
  background: rgba(103, 232, 249, 0.2);
  border-color: rgba(103, 232, 249, 0.5);
}

.banniere-streamy-fermer {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.banniere-streamy-fermer:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

/* ==================== Widget vide (état placeholder) ==================== */
.widget-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  padding: 16px;
}

.widget-vide-icone {
  font-size: 32px;
  opacity: 0.5;
}

.widget-vide-aide,
.widget-chat-aide {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

/* ==================== Widget chat Twitch ==================== */
.widget-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(10, 10, 15, 0.9);
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Style personnalisé (appliqué quand ChatStyle est actif) */
.widget-chat-style {
  background: rgba(10, 10, 15, 0.9);
}

.widget-chat-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 13px;
  padding: 20px;
  letter-spacing: 0.02em;
}

.widget-chat-icone {
  font-size: 36px;
  opacity: 0.55;
}

.widget-chat-canal {
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(103, 232, 249, 0.08), rgba(103, 232, 249, 0.03));
  border-bottom: 1px solid rgba(103, 232, 249, 0.18);
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.widget-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.widget-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.widget-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.widget-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Message chat (avec style personnalisable) */
.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 8px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: chat-fade-in 0.25s ease;
  border-radius: 6px;
  transition: background 0.15s ease;
}

/* Zebra striping — alternance subtile pour séparer les messages */
.chat-message-zebra:nth-child(odd) {
  background: rgba(255, 255, 255, 0.035);
}
.chat-message-zebra:nth-child(even) {
  background: rgba(0, 0, 0, 0.18);
}
.chat-message:hover {
  background: rgba(103, 232, 249, 0.08);
}

@keyframes chat-fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Avatar (photo de profil) */
.chat-avatar {
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.06);
}

/* Contenu du message (badges + pseudo + texte) */
.chat-contenu {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Badges (emoji) */
.chat-badge {
  margin-right: 3px;
  font-size: 0.9em;
  vertical-align: middle;
}

/* Timestamp */
.chat-timestamp {
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.72em;
  margin-right: 5px;
  font-variant-numeric: tabular-nums;
}

.chat-pseudo {
  font-weight: 700;
  flex-shrink: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  margin-right: 3px;
}

.chat-separateur {
  margin-right: 4px;
  opacity: 0.55;
}

.chat-texte {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Emotes (images inline) */
.chat-emote {
  display: inline-block;
  height: 1.6em;
  width: auto;
  vertical-align: middle;
  margin: 0 1px;
}

/* ==================== Panel Chat Style (carte flottante) ==================== */
.panel-chat-style {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-chat-style .style-groupe {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-chat-style .style-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

.panel-chat-style .style-valeur {
  font-size: 12px;
  color: #67e8f9;
  font-weight: 700;
}

.panel-chat-style input[type="range"] {
  width: 100%;
  accent-color: #67e8f9;
}

.panel-chat-style input[type="color"] {
  width: 40px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.panel-chat-style select {
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.panel-chat-style select option {
  background: #1a1a2e;
  color: #fff;
}

.panel-chat-style .style-couleur-ligne {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-chat-style .style-couleur-ligne input[type="range"] {
  flex: 1;
}

/* Presets de fond — grille de boutons avec aperçu du gradient */
.panel-chat-style .style-presets-fond {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.panel-chat-style .preset-fond-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 7px 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  color: inherit;
  font-family: inherit;
}

.panel-chat-style .preset-fond-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.panel-chat-style .preset-fond-btn.active {
  border-color: #67e8f9;
  background: rgba(103, 232, 249, 0.1);
  box-shadow: 0 0 0 1px rgba(103, 232, 249, 0.3);
}

.panel-chat-style .preset-fond-apercu {
  width: 100%;
  height: 28px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.panel-chat-style .preset-fond-nom {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  letter-spacing: 0.01em;
}

.panel-chat-style .style-boutons {
  display: flex;
  gap: 6px;
}

.panel-chat-style .style-boutons .dashboard-btn {
  flex: 1;
}

.panel-chat-style .style-toggles {
  gap: 8px;
}

.panel-chat-style .style-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.panel-chat-style .style-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #67e8f9;
  cursor: pointer;
}

.panel-chat-style .style-apercu-titre {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-chat-style .style-apercu {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

/* ==================== Widget input viewer (iframe GamePadViewer) ====================
   L'iframe est rendue à une résolution native fixe (1000x600, équivalent du
   "browser source" d'OBS Studio) puis mise à l'échelle via transform: scale
   pour rentrer entièrement dans le widget (comportement object-fit: contain).
   → La manette entière reste visible peu importe la taille du widget, et le
   resize reste fluide (le scale est recalculé en direct pendant le drag).
   La variable --gp-scale est positionnée par Widgets._appliquerScaleInputViewer.
   Défaut = 1 (visible à taille native, clippé par overflow:hidden) si le JS
   n'a pas encore tourné → on ne perd jamais l'affichage. */
.widget-input-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.widget-input-iframe {
  width: 1000px;
  height: 600px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  transform: scale(var(--gp-scale, 1));
  transform-origin: center center;
  will-change: transform;
}
.widget-input-canvas {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  background: transparent;
  display: block;
}

/* ==================== Widget caméra ==================== */
.widget-camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* ==================== Widget média (image/vidéo) — mode rempli par défaut ====================
   Les img/vidéo du widget média remplissent tout le widget (object-fit: cover).
   L'alignement (transformations.alignement) peut surcharger via un style inline
   sur l'élément (object-fit: contain / fill / cover). Par défaut = cover (rempli). */
.widget-body > img,
.widget-body > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

/* ==================== Cadre SVG (overlay widget) ==================== */
.widget-cadre-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

/* ==================== Bulles d'aide Streamy (tooltips) ==================== */
.streamy-aide-bulle {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 340px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(9, 14, 28, 0.98), rgba(5, 9, 18, 0.99));
  border: 1px solid rgba(103, 232, 249, 0.3);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(103, 232, 249, 0.08),
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 4px 16px rgba(34, 211, 238, 0.12);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.streamy-aide-bulle.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.streamy-aide-mascotte {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  filter: drop-shadow(0 0 8px rgba(103, 232, 249, 0.3));
}

.streamy-aide-texte {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  padding-top: 4px;
}

/* ==================== Modale : liste caméras ==================== */
.camera-liste {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.camera-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-rapide);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
}

.camera-item:hover {
  background: rgba(103, 232, 249, 0.08);
  border-color: rgba(103, 232, 249, 0.3);
  transform: translateY(-1px);
}

.camera-icone {
  font-size: 22px;
}

.camera-nom {
  font-size: 13px;
  font-weight: 600;
}

/* ==================== Modale : scènes SOS Web ==================== */
.scene-carte {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-rapide);
}

.scene-carte:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.scene-carte.active {
  border-color: rgba(103, 232, 249, 0.5);
  background: rgba(103, 232, 249, 0.08);
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.15);
}

.scene-nom {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.scene-widgets {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.scene-statut {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #67e8f9;
}

.scene-supprimer {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 5px;
  color: #f87171;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-rapide);
}

.scene-supprimer:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

/* ==================== Sélecteur cadre (dans widget-options) ==================== */
.info-select {
  width: 100%;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.info-select:focus {
  outline: none;
  border-color: rgba(103, 232, 249, 0.5);
}

.info-select option {
  background: #1a1a2e;
  color: var(--text-primary);
}

/* ==================== Messages modale (succès/erreur) ==================== */
.message-succes {
  padding: 10px 14px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 8px;
  color: #4ade80;
  font-size: 13px;
}
