/* ============================================================
   VClass WebRTC — Styles Salle Virtuelle v2.0
   Design System : --primary #667eea / --secondary #764ba2
   ============================================================ */

:root {
  --vc-primary:    #667eea;
  --vc-secondary:  #764ba2;
  --vc-grad:       linear-gradient(135deg, #667eea, #764ba2);
  --vc-success:    #10b981;
  --vc-danger:     #ef4444;
  --vc-warn:       #f59e0b;
  --vc-dark:       #0f172a;
  --vc-dark2:      #1e293b;
  --vc-dark3:      #334155;
  --vc-text:       #f1f5f9;
  --vc-muted:      #94a3b8;
  --vc-border:     rgba(255,255,255,0.08);
  --vc-radius:     12px;
  --vc-shadow:     0 8px 32px rgba(0,0,0,0.4);
  --vc-bar-h:      72px;
  --vc-panel-w:    320px;
  --vc-tile-bg:    #1e293b;
}

/* ============================================================
   ROOM WRAPPER
   ============================================================ */
.vclass-room-v2 {
  position: fixed;
  inset: 0;
  background: var(--vc-dark);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--vc-text);
  z-index: 9999;
  overflow: hidden;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.vc-topbar {
  height: 56px;
  background: var(--vc-dark2);
  border-bottom: 1px solid var(--vc-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}

.vc-topbar-logo {
  font-weight: 800;
  font-size: 18px;
  background: var(--vc-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.vc-topbar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--vc-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vc-topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--vc-muted);
}

.vc-live-badge {
  background: var(--vc-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.vc-timer {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--vc-text);
}

.vc-part-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--vc-dark3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
}

/* ============================================================
   BODY — VIDEO + SIDEPANELS
   ============================================================ */
.vc-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   VIDEO GRID
   ============================================================ */
.vc-video-grid {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 10px;
  background: var(--vc-dark);
  overflow: hidden;
  align-content: center;
  justify-content: center;
}

/* Layouts adaptatifs */
.vc-video-grid.layout-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.vc-video-grid.layout-2 {
  grid-template-columns: 1fr 1fr;
}
.vc-video-grid.layout-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.vc-video-grid.layout-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.vc-video-grid.layout-many {
  grid-template-columns: repeat(4, 1fr);
}

/* ============================================================
   VIDEO TILE
   ============================================================ */
.vc-video-tile {
  position: relative;
  background: var(--vc-tile-bg);
  border-radius: var(--vc-radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 0;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.vc-video-tile.speaking {
  border-color: var(--vc-success);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.3);
}

.vc-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Tile sans vidéo */
.vc-video-tile.no-video video { display: none; }
.vc-video-tile.no-video .vc-avatar-placeholder { display: flex; }

.vc-avatar-placeholder {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--vc-dark3);
}

.vc-avatar-initial {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--vc-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
}

/* Info overlay */
.vc-tile-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 12px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  align-items: center;
  gap: 6px;
}

.vc-tile-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vc-tile-mute {
  font-size: 16px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vc-tile-hand {
  font-size: 16px;
  animation: bounce-hand 0.6s infinite alternate;
}

@keyframes bounce-hand {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); }
}

/* Local tile badge */
.vc-local-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--vc-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 2;
}

/* ============================================================
   BARRE DE CONTRÔLE
   ============================================================ */
.vc-controls {
  height: var(--vc-bar-h);
  background: var(--vc-dark2);
  border-top: 1px solid var(--vc-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}

.vc-ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vc-ctrl-sep {
  width: 1px;
  height: 36px;
  background: var(--vc-border);
  margin: 0 6px;
}

/* Bouton contrôle */
.vc-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--vc-dark3);
  border: 1px solid var(--vc-border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--vc-text);
  font-size: 12px;
  transition: all 0.15s;
  min-width: 64px;
  position: relative;
}

.vc-ctrl-btn:hover {
  background: var(--vc-dark);
  border-color: var(--vc-primary);
  transform: translateY(-1px);
}

.vc-ctrl-btn .vc-icon {
  font-size: 20px;
  line-height: 1;
}

.vc-ctrl-btn .vc-btn-label {
  font-size: 10px;
  color: var(--vc-muted);
  white-space: nowrap;
}

.vc-ctrl-btn.active-mute {
  background: rgba(239,68,68,0.2);
  border-color: var(--vc-danger);
}

.vc-ctrl-btn.active {
  background: rgba(102,126,234,0.2);
  border-color: var(--vc-primary);
}

.vc-ctrl-btn.recording {
  background: rgba(239,68,68,0.15);
  border-color: var(--vc-danger);
}

.recording-dot {
  animation: rec-pulse 1s infinite;
  color: var(--vc-danger);
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Bouton quitter */
.vc-ctrl-btn.leave {
  background: var(--vc-danger);
  border-color: var(--vc-danger);
  color: #fff;
  min-width: 100px;
}

.vc-ctrl-btn.leave:hover {
  background: #dc2626;
  transform: none;
}

.vc-ctrl-btn.leave .vc-btn-label { color: rgba(255,255,255,0.8); }

/* Badge chat */
.vc-chat-badge-wrap {
  position: absolute;
  top: 4px;
  right: 4px;
}

#vc-chat-badge {
  display: none;
  background: var(--vc-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   SIDE PANELS — Participants & Chat
   ============================================================ */
.vc-side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--vc-panel-w);
  background: var(--vc-dark2);
  border-left: 1px solid var(--vc-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 20;
}

.vc-side-panel.visible { transform: translateX(0); }

.vc-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--vc-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.vc-panel-header h3 {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--vc-text);
}

.vc-panel-close {
  background: none;
  border: none;
  color: var(--vc-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s;
}

.vc-panel-close:hover { color: var(--vc-text); }

/* Participants list */
#vc-participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.vc-part-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.vc-part-item:hover { background: var(--vc-dark3); }

.vc-part-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--vc-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.vc-part-info {
  flex: 1;
  min-width: 0;
}

.vc-part-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--vc-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vc-part-info strong em {
  font-style: normal;
  font-size: 11px;
  color: var(--vc-muted);
  font-weight: 400;
}

.vc-part-role {
  font-size: 11px;
  color: var(--vc-muted);
}

.vc-part-role.host { color: var(--vc-warn); }

.vc-part-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vc-btn-icon {
  background: none;
  border: 1px solid var(--vc-border);
  border-radius: 6px;
  color: var(--vc-muted);
  font-size: 13px;
  padding: 3px 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.vc-btn-icon:hover { background: var(--vc-dark3); color: var(--vc-text); }
.vc-btn-icon.danger:hover { background: rgba(239,68,68,0.2); border-color: var(--vc-danger); color: var(--vc-danger); }

/* ============================================================
   CHAT PANEL
   ============================================================ */
#vc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vc-chat-msg {
  max-width: 85%;
  align-self: flex-start;
}

.vc-chat-msg.own {
  align-self: flex-end;
}

.vc-chat-author {
  font-size: 11px;
  color: var(--vc-primary);
  font-weight: 600;
  margin-bottom: 3px;
  padding-left: 4px;
}

.vc-chat-bubble {
  background: var(--vc-dark3);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.vc-chat-msg.own .vc-chat-bubble {
  background: var(--vc-primary);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}

.vc-chat-time {
  font-size: 10px;
  color: var(--vc-muted);
  margin-top: 3px;
  padding: 0 4px;
  text-align: right;
}

.vc-chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--vc-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#vc-chat-input {
  flex: 1;
  background: var(--vc-dark3);
  border: 1px solid var(--vc-border);
  border-radius: 10px;
  color: var(--vc-text);
  font-size: 13px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  max-height: 100px;
  transition: border-color 0.2s;
  font-family: inherit;
}

#vc-chat-input:focus { border-color: var(--vc-primary); }
#vc-chat-input::placeholder { color: var(--vc-muted); }

#vc-chat-send {
  background: var(--vc-primary);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 18px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#vc-chat-send:hover { background: #5a6fd6; transform: scale(1.05); }

/* ============================================================
   TABLEAU BLANC
   ============================================================ */
#vc-whiteboard-panel {
  position: absolute;
  inset: 0;
  background: var(--vc-dark);
  z-index: 30;
  display: none;
  flex-direction: column;
}

#vc-whiteboard-panel.visible { display: flex; }

.vc-wb-toolbar {
  height: 52px;
  background: var(--vc-dark2);
  border-bottom: 1px solid var(--vc-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.vc-wb-toolbar label {
  font-size: 13px;
  color: var(--vc-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

#vc-wb-color {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
  background: none;
}

#vc-wb-size {
  width: 80px;
}

#vc-wb-clear {
  background: var(--vc-dark3);
  border: 1px solid var(--vc-border);
  border-radius: 8px;
  color: var(--vc-text);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

#vc-wb-clear:hover { background: rgba(239,68,68,0.2); border-color: var(--vc-danger); }

#vc-whiteboard {
  flex: 1;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

/* ============================================================
   NOTIFICATION TOAST
   ============================================================ */
#vc-notif {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--vc-dark2);
  border: 1px solid var(--vc-border);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--vc-text);
  box-shadow: var(--vc-shadow);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

#vc-notif.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   MODAL
   ============================================================ */
#vc-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.vc-modal-box {
  background: var(--vc-dark2);
  border: 1px solid var(--vc-border);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  text-align: center;
}

.vc-modal-box p { font-size: 15px; margin-bottom: 20px; color: var(--vc-text); }

#vc-modal-btn {
  background: var(--vc-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 28px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
}

/* ============================================================
   STATUS LOG
   ============================================================ */
#vc-status-log {
  position: fixed;
  bottom: 80px;
  left: 16px;
  width: 280px;
  max-height: 120px;
  overflow-y: auto;
  z-index: 50;
  pointer-events: none;
}

.vc-log-entry {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.5);
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 2px;
  backdrop-filter: blur(4px);
}

/* ============================================================
   SALLE D'ATTENTE (inchangé)
   ============================================================ */
.waiting-room {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wr-content {
  text-align: center;
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  max-width: 500px;
}

.wr-icon { font-size: 64px; margin-bottom: 20px; }

.countdown {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
}

.cd-block { text-align: center; }

.cd-num {
  display: block;
  font-size: 48px;
  font-weight: 800;
  background: var(--vc-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cd-lbl { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; }
.cd-sep { font-size: 40px; font-weight: 800; color: #667eea; line-height: 1.2; }

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 768px) {
  :root { --vc-panel-w: 100vw; --vc-bar-h: 80px; }

  .vc-topbar-title { font-size: 13px; }

  .vc-controls {
    gap: 4px;
    padding: 0 8px;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .vc-ctrl-btn {
    min-width: 52px;
    padding: 6px 8px;
    flex-shrink: 0;
  }

  .vc-ctrl-btn .vc-btn-label { display: none; }
  .vc-ctrl-btn .vc-icon { font-size: 22px; }

  .vc-video-grid.layout-2,
  .vc-video-grid.layout-4,
  .vc-video-grid.layout-6,
  .vc-video-grid.layout-many {
    grid-template-columns: 1fr 1fr;
  }

  .vc-ctrl-sep { display: none; }
}

@media (max-width: 480px) {
  .vc-video-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */
.vc-side-panel ::-webkit-scrollbar { width: 4px; }
.vc-side-panel ::-webkit-scrollbar-track { background: transparent; }
.vc-side-panel ::-webkit-scrollbar-thumb {
  background: var(--vc-dark3);
  border-radius: 2px;
}

/* ============================================================
   WebRTC v2.0 — Correctifs et sélecteurs complémentaires
   ============================================================ */

/* Local tile — hérite de .vc-video-tile, styles spécifiques */
#vc-local-tile {
  position: relative;
}

/* Local video element */
#vc-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1); /* miroir naturel pour la caméra locale */
}

/* Participants panel count sync */
#vc-part-count-panel {
  font-weight: 700;
}

/* Chat badge */
#vc-chat-badge {
  background: var(--vc-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Parts list empty state */
#vc-participants-list:empty::after {
  content: 'Aucun participant pour l\'instant…';
  display: block;
  text-align: center;
  color: var(--vc-muted);
  font-size: 13px;
  padding: 24px;
}

/* Chat messages empty state */
#vc-chat-messages:empty::after {
  content: 'Aucun message encore — commencez la conversation !';
  display: block;
  text-align: center;
  color: var(--vc-muted);
  font-size: 13px;
  padding: 24px;
  font-style: italic;
}

/* Whiteboard close button */
#vc-wb-close {
  margin-left: auto;
  background: var(--vc-dark3);
  border: none;
  color: var(--vc-muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
#vc-wb-close:hover { color: var(--vc-text); background: var(--vc-dark); }

/* Mute / hand icons in local tile */
#vc-local-mute {
  font-size: 16px;
  background: rgba(0,0,0,.5);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Active speaking border animation */
@keyframes speaking-pulse {
  0%   { box-shadow: 0 0 0 2px rgba(16,185,129,0.4); }
  50%  { box-shadow: 0 0 0 4px rgba(16,185,129,0.6); }
  100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.4); }
}
.vc-video-tile.speaking {
  animation: speaking-pulse 1.2s infinite;
}

/* Tile remote — hover controls (future extensibility) */
.vc-video-tile.remote-tile:hover .vc-tile-info {
  background: linear-gradient(transparent, rgba(0,0,0,.85));
}

/* Spinner animation for refresh button */
.spinning {
  animation: spin .5s linear;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   Fix autoplay — bouton de déblocage son
   ============================================================ */
.vc-unblock-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(102, 126, 234, 0.92);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 10;
  backdrop-filter: blur(4px);
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.vc-unblock-btn:hover {
  background: rgba(102, 126, 234, 1);
  transform: translate(-50%, -50%) scale(1.05);
}
