/* =========================================================================
   LucyChat - WebRTC Calling, Audio/Video & Camera (calling.css)
   ========================================================================= */

/* Calls Sidebar & Dashboard */
.calls-sidebar {
  width: 380px;
  min-width: 320px;
  max-width: 440px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.calls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  padding: 8px 16px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
}

.calls-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.calls-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 14px 16px 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calls-section-link {
  font-size: 0.78rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  font-weight: 600;
}

.calls-favorites-list {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
}

.calls-fav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.calls-fav-item:hover {
  background: var(--bg-secondary);
}

.calls-fav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}

.calls-fav-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #374151;
  flex-shrink: 0;
}

.calls-fav-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calls-fav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calls-action-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.calls-action-circle-btn:hover {
  background: rgba(134, 150, 160, 0.2);
  color: var(--accent);
  transform: scale(1.08);
}

.calls-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px 8px;
}

.call-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.call-log-row:hover {
  background: var(--bg-secondary);
}

.call-log-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.call-log-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #374151;
  flex-shrink: 0;
}

.call-log-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.call-log-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-log-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.call-log-status.missed {
  color: var(--offline-red);
  font-weight: 600;
}

.call-log-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.calls-main-dashboard {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-primary);
  padding: 48px 24px 24px 24px;
  position: relative;
}

.calls-dash-cards-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 32px;
  max-width: 480px;
  width: 100%;
}

.calls-dash-row {
  display: flex;
  gap: 36px;
  justify-content: center;
  width: 100%;
}

.calls-dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
}

.calls-dash-card-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--text-muted);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.calls-dash-card:hover .calls-dash-card-icon {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.calls-dash-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
}

.calls-dash-e2ee-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 12px;
  user-select: none;
}

/* Calling Overlay Fullscreen */
.call-overlay-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0b141a;
  z-index: 8000 !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.call-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(11, 20, 26, 0.85) 0%, rgba(11, 20, 26, 0) 100%);
  z-index: 10;
}

.call-mini-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.call-top-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s ease;
}

.call-top-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.call-stage {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111b21;
}

.remote-video-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111b21;
}

.call-audio-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.call-avatar-pulse-container {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.call-avatar-pulse-container.large {
  width: 150px;
  height: 150px;
}

.call-pulse-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  z-index: 3;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.call-pulse-avatar.large {
  width: 130px;
  height: 130px;
}

.pulse-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: callPulseAnim 2.2s infinite ease-out;
  pointer-events: none;
}

.pulse-ring.ring-1 { width: 100%; height: 100%; animation-delay: 0s; }
.pulse-ring.ring-2 { width: 100%; height: 100%; animation-delay: 0.7s; }
.pulse-ring.ring-3 { width: 100%; height: 100%; animation-delay: 1.4s; }

@keyframes callPulseAnim {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

.audio-wave-bars {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
}

.wave-bar {
  width: 5px;
  background: var(--accent);
  border-radius: 3px;
  animation: waveBarAnim 1.2s infinite ease-in-out;
}

.wave-bar:nth-child(1) { height: 16px; animation-delay: 0.1s; }
.wave-bar:nth-child(2) { height: 28px; animation-delay: 0.3s; }
.wave-bar:nth-child(3) { height: 36px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 24px; animation-delay: 0.4s; }
.wave-bar:nth-child(5) { height: 14px; animation-delay: 0.15s; }

@keyframes waveBarAnim {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

.call-pip-container {
  position: absolute;
  bottom: 100px;
  right: 24px;
  width: 180px;
  height: 120px;
  background: #202c33;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: grab;
  z-index: 20;
}

.local-video-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.local-video-muted-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111b21;
  color: #8696a0;
  font-size: 0.75rem;
  font-weight: 500;
}

.call-bottom-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(32, 44, 51, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 30;
}

.call-circle-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #2a3942;
  color: #ffffff;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.call-circle-btn:hover {
  background: #374953;
  transform: translateY(-2px);
}

.call-circle-btn.btn-state-active {
  background: #00a884 !important;
  color: #ffffff !important;
  box-shadow: 0 0 16px rgba(0, 168, 132, 0.5) !important;
}

.call-circle-btn.btn-state-muted {
  background: #dc2626 !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(220, 38, 38, 0.5) !important;
}

.call-circle-btn.btn-state-cam-off {
  background: #2a3942;
  color: #94a3b8;
}

.call-circle-btn.btn-hangup {
  background: #ea4335 !important;
  color: #ffffff !important;
}

.call-circle-btn.btn-accept {
  background: #25d366 !important;
  color: #ffffff !important;
}

.call-device-popup {
  position: absolute;
  bottom: 95px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: #202c33;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 35;
}

.call-incoming-card,
.call-outgoing-card {
  background: #202c33 !important;
  color: #e9edef !important;
  text-align: center;
  padding: 32px 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* Minimiertes Floating PiP Overlay */
.call-overlay-fullscreen.call-overlay-minimized {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  bottom: 24px !important;
  right: 24px !important;
  width: 360px !important;
  height: 240px !important;
  border-radius: 16px !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75), 0 0 0 1.5px rgba(0, 168, 132, 0.45) !important;
  z-index: 4000 !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  overflow: hidden !important;
}

.call-overlay-minimized .call-top-bar {
  height: 44px;
  padding: 0 12px;
  cursor: grab;
}

.call-overlay-minimized #btnMinimizeCallOverlay,
.call-overlay-minimized #btnOpenChatDuringCall,
.call-overlay-minimized #btnToggleCallFullscreen {
  display: none !important;
}

.call-overlay-minimized #btnRestoreCallOverlay {
  display: inline-flex !important;
}

.call-overlay-minimized .call-circle-btn {
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

.call-overlay-minimized .call-bottom-bar {
  bottom: 8px;
  padding: 4px 10px;
  gap: 8px;
}

/* Kamera Snapshot Modal */
.camera-snap-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10030;
  backdrop-filter: blur(4px);
}

.camera-snap-card {
  background: #111b21;
  color: #e9edef;
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  border: 1px solid #222d34;
}

.camera-snap-viewport {
  width: 100%;
  height: 360px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-snap-video,
.camera-snap-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-camera-shutter {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.15s;
}

.btn-camera-shutter:hover {
  transform: scale(1.08);
}

/* QR Scanner */
.qr-scanner-viewfinder {
  position: relative;
  width: 100%;
  height: 280px;
  background: #000000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-scanner-viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px 2px var(--accent);
  animation: qrScanAnim 2.5s infinite ease-in-out;
  pointer-events: none;
}

@keyframes qrScanAnim {
  0% { top: 12%; }
  50% { top: 86%; }
  100% { top: 12%; }
}

.qr-corners {
  position: absolute;
  inset: 20px;
  pointer-events: none;
}

.qr-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
}

.qr-corner.top-left { top: 0; left: 0; border-width: 3px 0 0 3px; border-top-left-radius: 6px; }
.qr-corner.top-right { top: 0; right: 0; border-width: 3px 3px 0 0; border-top-right-radius: 6px; }
.qr-corner.bottom-left { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-bottom-left-radius: 6px; }
.qr-corner.bottom-right { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-bottom-right-radius: 6px; }
