/* DialogCRM Video Meet — Жемчужная палитра (Pearl Light Theme) */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f6 50%, #f1f5f9 100%);
  color: #1e293b;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.logo {
  font-weight: 700;
  font-size: 19px;
  color: #0284c7;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.3px;
}

.logo-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.room-info {
  font-size: 13.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-badge {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

#main-stage {
  flex: 1;
  display: flex;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: #f1f5f9;
}

/* Screen Share Zoom Layout: Полноэкранный показ и плавающие камеры наверху */
#screen-share-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #090d16;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  overflow: hidden;
}

#screen-share-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #090d16;
}

.screen-share-label {
  position: absolute;
  top: 14px;
  left: 16px;
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* When Screen Share is active: камеры участников выстраиваются в ряд наверху (как в Zoom) */
#video-grid.in-screenshare {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 0;
  width: auto;
  max-width: 90vw;
  height: auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  z-index: 25;
  pointer-events: none;
}

#video-grid.in-screenshare .video-card {
  pointer-events: auto;
  width: 200px;
  height: 125px;
  min-height: 0;
  max-height: 130px;
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 1px 3px rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#video-grid.in-screenshare .video-card:hover {
  transform: scale(1.05);
  border-color: #38bdf8;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.75);
}

#video-grid.in-screenshare .waiting-card {
  display: none !important;
}

#video-grid.in-screenshare .avatar-circle {
  width: 48px;
  height: 48px;
  font-size: 17px;
}

#video-grid.in-screenshare .avatar-status {
  display: none;
}

#video-grid.in-screenshare .participant-name {
  padding: 3px 8px;
  font-size: 11px;
  bottom: 6px;
  left: 6px;
}

#video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  padding: 20px 20px 100px 20px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
}

.video-card {
  position: relative;
  background: #0f172a;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border: 1px solid #e2e8f0;
  width: 100%;
  height: 100%;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0f172a;
}

.video-card .participant-name {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  color: #0f172a;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

/* Participant Avatar / Video Placeholder */
.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  background: #0f172a;
}

.avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.35);
  letter-spacing: -0.5px;
  user-select: none;
}

.avatar-status {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
}

/* Waiting for participant card */
.waiting-card {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 440px;
  width: 100%;
  height: 100%;
  max-height: 80vh;
  margin: auto;
  box-sizing: border-box;
}

.waiting-pulse-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waiting-pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  animation: waiting-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  opacity: 0.75;
}

@keyframes waiting-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 0.1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.waiting-icon-box {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0284c7;
}

.waiting-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.waiting-subtitle {
  font-size: 13.5px;
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.45;
  max-width: 320px;
}

.waiting-btn {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 11px 22px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.waiting-btn:hover {
  background: #0369a1;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

/* Floating Controls Dock */
#controls-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  padding: 8px 14px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
  z-index: 20;
}

.dock-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  user-select: none;
}

.dock-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.dock-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.dock-btn.off {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.dock-btn.danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  padding: 8px 20px;
}

.dock-btn.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Modals & Overlays */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.screen-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 36px 40px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  letter-spacing: -0.4px;
}

.screen-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 24px;
  line-height: 1.5;
}

.legal-notice {
  font-size: 12px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 20px;
  line-height: 1.45;
  text-align: left;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 13px 28px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

/* Background Selector Drawer */
#bg-drawer {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
  width: 380px;
  max-width: 90vw;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.bg-thumb {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s;
}

.bg-thumb:hover {
  border-color: #0284c7;
}

.bg-thumb.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.bg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-thumb-none {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
}

.bg-thumb-blur {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #0369a1;
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  cursor: pointer;
  transition: all 0.15s ease;
}

.bg-thumb-blur svg {
  stroke: #0284c7;
}

.bg-thumb-blur:hover {
  background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
}

.bg-custom-btn {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #0284c7;
  cursor: pointer;
  transition: background 0.15s;
}

.bg-custom-btn:hover {
  background: #f0f9ff;
  border-color: #0284c7;
}

/* Devices Modal */
#devices-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
  display: none;
  flex-direction: column;
  gap: 16px;
  z-index: 50;
  width: 400px;
  max-width: 90vw;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
}

.form-group select {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13.5px;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
}

.form-group select:focus {
  border-color: #0284c7;
  background: #ffffff;
}

/* In-App Browser Warning Banner */
.inapp-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  padding: 10px 16px;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: space-between;
}

/* Peekaboo Stars & Mascot */
.rating-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4.5rem;
}

.character-box {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5.25rem;
  overflow: hidden;
}

.character-svg {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 80px;
  height: 80px;
  transform: translateX(-50%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-btn {
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-btn:hover {
  transform: scale(1.15) rotate(4deg);
}

.star-btn:active {
  transform: scale(0.85);
}

/* Mobile Responsive: Zero-scroll fit & compact touch dock (iPhone, Android) */
@media (max-width: 640px) {
  header {
    padding: 6px 12px;
  }
  .logo {
    font-size: 15px;
    gap: 6px;
  }
  .room-info {
    font-size: 11px;
    gap: 4px;
  }
  .room-badge {
    font-size: 10.5px;
    padding: 2px 5px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #main-stage {
    height: calc(100dvh - 44px);
    overflow: hidden; /* No scrolling needed on mobile! */
    display: flex;
    flex-direction: column;
  }

  #video-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 8px 64px 8px; /* Leave room for bottom dock */
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  .video-card {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    width: 100%;
    border-radius: 12px;
  }

  .waiting-card {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    padding: 14px 10px;
    border-radius: 12px;
  }

  .waiting-pulse-wrap {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
  }

  .waiting-icon-box {
    width: 42px;
    height: 42px;
  }

  .waiting-title {
    font-size: 15px;
    margin-bottom: 4px;
  }

  .waiting-subtitle {
    font-size: 12px;
    margin-bottom: 12px;
    max-width: 260px;
  }

  .waiting-btn {
    padding: 9px 16px;
    font-size: 12px;
  }

  #video-grid.in-screenshare {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    padding: 0;
    width: auto;
    max-width: calc(100% - 12px);
    height: auto;
    z-index: 25;
  }

  #video-grid.in-screenshare .video-card {
    width: 120px;
    height: 75px;
    min-height: 0;
    max-height: 75px;
    flex: 0 0 auto;
    border-radius: 8px;
  }

  .screen-share-label {
    top: auto;
    bottom: 60px;
    left: 8px;
    font-size: 11px;
    padding: 3px 8px;
  }

  #controls-dock {
    position: absolute;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 16px);
    max-width: 380px;
    padding: 5px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    border-radius: 20px;
    z-index: 30;
  }

  .dock-btn {
    flex: 1;
    padding: 8px 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    min-width: 36px;
  }

  .dock-btn .label {
    display: none !important;
  }

  .dock-btn.danger {
    flex: 1.3;
    padding: 8px 6px;
  }

  .dock-btn.danger .label {
    display: inline !important;
    font-size: 11px;
    margin-left: 2px;
  }

  .dock-btn svg {
    width: 17px;
    height: 17px;
  }

  #bg-drawer {
    bottom: 64px;
    width: 95vw;
    max-width: 360px;
    padding: 12px;
  }

  .bg-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #video-grid.in-screenshare .video-card {
    width: 90px;
    height: 54px;
    max-height: 54px;
  }
  #controls-dock {
    padding: 3px 6px;
    bottom: 4px;
  }
}
