/**
 * ============================================
 * VIDEO-OVERLAY.CSS - Stili Videochiamata
 * ============================================
 * 
 * INSTALLAZIONE:
 * Aggiungi nell'<head> del tuo index.html:
 * <link rel="stylesheet" href="css/video-overlay.css">
 */

/* ============================================
   VARIABILI CSS
   ============================================ */
:root {
  --vc-primary: #4f46e5;
  --vc-primary-hover: #4338ca;
  --vc-danger: #ef4444;
  --vc-danger-hover: #dc2626;
  --vc-success: #22c55e;
  --vc-bg-dark: #0f0f0f;
  --vc-bg-overlay: rgba(0, 0, 0, 0.95);
  --vc-text: #ffffff;
  --vc-text-muted: #a1a1aa;
  --vc-border: rgba(255, 255, 255, 0.1);
  --vc-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --vc-radius: 16px;
  --vc-radius-sm: 12px;
  --vc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   PULSANTE VIDEO (nella tua PWA)
   ============================================ */
.video-call-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--vc-primary) 0%, #7c3aed 100%);
  color: var(--vc-text);
  border: none;
  border-radius: var(--vc-radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--vc-transition);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.video-call-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.5);
}

.video-call-btn:active {
  transform: translateY(0);
}

.video-call-btn svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   OVERLAY VIDEOCHIAMATA
   ============================================ */
.video-call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--vc-bg-overlay);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease;
}

.video-call-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================
   CONTAINER PRINCIPALE
   ============================================ */
.video-call-container {
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 700px;
  background: var(--vc-bg-dark);
  border-radius: var(--vc-radius);
  border: 1px solid var(--vc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--vc-shadow);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ============================================
   HEADER
   ============================================ */
.video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--vc-border);
}

.video-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--vc-text);
}

.call-status {
  font-size: 13px;
  color: var(--vc-text-muted);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================
   AREA VIDEO
   ============================================ */
.video-wrapper {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 0;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

#localVideo {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 140px;
  height: 105px;
  object-fit: cover;
  border-radius: var(--vc-radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
  transition: var(--vc-transition);
}

#localVideo:hover {
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Placeholder quando non c'è video remoto */
#remoteVideo:not([src]):empty::before,
#remoteVideo[src=""]::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

/* ============================================
   CONTROLLI
   ============================================ */
.video-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--vc-border);
}

.control-btn {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--vc-text);
  cursor: pointer;
  transition: var(--vc-transition);
}

.control-btn svg {
  width: 24px;
  height: 24px;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

.control-btn:active {
  transform: scale(0.95);
}

/* Pulsante Mute attivo */
.control-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--vc-danger);
}

/* Pulsante Termina chiamata */
.control-btn.hang-up {
  background: var(--vc-danger);
  border-color: var(--vc-danger);
}

.control-btn.hang-up:hover {
  background: var(--vc-danger-hover);
  transform: scale(1.1);
}

/* ============================================
   RESPONSIVE - SMARTPHONE
   ============================================ */
@media (max-width: 640px) {
  .video-call-overlay {
    padding: 0;
  }
  
  .video-call-container {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  
  .video-header {
    padding: 12px 16px;
  }
  
  .video-header h3 {
    font-size: 15px;
  }
  
  #localVideo {
    width: 100px;
    height: 75px;
    bottom: 12px;
    right: 12px;
  }
  
  .video-controls {
    padding: 16px;
    gap: 12px;
  }
  
  .control-btn {
    width: 52px;
    height: 52px;
  }
  
  .control-btn svg {
    width: 22px;
    height: 22px;
  }
}

/* ============================================
   LANDSCAPE MODE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .video-call-container {
    max-height: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .video-header {
    width: 100%;
    padding: 8px 16px;
  }
  
  .video-wrapper {
    flex: 1;
    min-width: 0;
  }
  
  .video-controls {
    width: auto;
    flex-direction: column;
    padding: 12px;
    border-top: none;
    border-left: 1px solid var(--vc-border);
  }
  
  .control-btn {
    width: 48px;
    height: 48px;
  }
  
  #localVideo {
    width: 120px;
    height: 90px;
  }
}

/* ============================================
   ANIMAZIONI AGGIUNTIVE
   ============================================ */

/* Stato connessione verde quando connesso */
.call-status.connected {
  color: var(--vc-success);
  background: rgba(34, 197, 94, 0.1);
  animation: none;
}

/* Effetto ring quando in attesa */
.video-wrapper.waiting::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  border: 3px solid var(--vc-primary);
  border-radius: 50%;
  animation: ring 1.5s ease-out infinite;
}

@keyframes ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
