/* /public/style.css | ProfileFriends CSS — Alpha-V1 (REV-3)
   FIX:
   - Chat overlay inside video only (hidden by default)
   - HUD top buttons for mic/cam/chat
   - Portrait video, local draggable circle stays
   - Bottom controls never blocked (chat overlay confined to .videoWrap only)
   - ADDED: Video grid for multi-participant calls
   - ADDED: Circle mode for many participants
*/

:root{
  --bg1:#071226;
  --bg2:#241144;
  --bg3:#b88a00;

  --glass: rgba(10,12,18,.42);
  --stroke: rgba(255,255,255,.14);
  --stroke2: rgba(255,255,255,.10);

  --txt: rgba(255,255,255,.92);
  --txt2: rgba(255,255,255,.72);

  --shadow: 0 30px 90px rgba(0,0,0,.55);
  --shadow2: 0 14px 40px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
html,body{
  height:100%;
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--txt);
  overflow:hidden;
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(255,255,255,.08), transparent 55%),
    radial-gradient(900px 600px at 90% 70%, rgba(255,255,255,.05), transparent 60%),
    linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
}

.material-symbols-rounded{
  font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 24;
  line-height:1;
}

button, input, select{ font-family: inherit; color: inherit; }
button{ -webkit-tap-highlight-color: transparent; }

.stage{
  position:relative;
  width:100%;
  height:100%;
  display:flex;
  flex-direction:column;
  padding: 10px 10px 14px;
}

/* Topbar */
.topbar{
  z-index: 60;
  min-height: 58px;
  display:flex;
  align-items:center;
  gap:12px;
  padding: 10px 12px;
  border-radius: 18px;
  border:1px solid var(--stroke);
  background: var(--glass);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(16px);
}

.topbarLeft{ display:flex; align-items:center; gap:10px; }

.logoBtn{
  width: 40px; height: 40px;
  border-radius: 14px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.12);
  display:grid; place-items:center;
  cursor:pointer;
}
.logoBtn img{ width:22px; height:22px; border-radius:6px; object-fit:cover; }

.topbarRight{
  margin-left:auto;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap: wrap;
  row-gap: 8px;
}

.topBtn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 14px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.14);
  cursor:pointer;
  font-weight: 750;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: var(--shadow2);
}
.iconBtn{
  width: 42px; height: 42px;
  border-radius: 16px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.14);
  cursor:pointer;
  display:grid; place-items:center;
  box-shadow: var(--shadow2);
}
.btnText{ display:inline; }

.onlineBox{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  line-height:1.05;
  min-width: 56px;
}
.onlineLbl{ font-size: 11px; opacity: .76; font-weight: 750; }
.onlineNum{ font-size: 14px; font-weight: 900; }

/* Center */
.centerWrap{
  flex:1;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding-top: 10px;
}

/* Video Grid */
.videoGrid {
  width: 100%;
  max-width: 1200px;
  height: 100%;
  display: grid;
  gap: 16px;
  padding: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.videoGrid.circle-mode .videoTile {
  border-radius: 50%;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  position: relative;
}

.videoTile {
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.videoTile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.videoTile .tileInfo {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.videoTile .tileInfo img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.screenShareActive {
  border: 3px solid #4CAF50;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

/* Call Card */
.callCard{
  position:relative;
  width: min(880px, 100%);
  height: 86vh;
  border-radius: 26px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.12);
  box-shadow: var(--shadow);
  background: rgba(0,0,0,.12);
}
.partnerBg{
  position:absolute;
  inset:0;
  background-size: cover;
  background-position:center;
  opacity: .98;
  transform: scale(1.02);
}

.glassFrame{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding: 12px;
  background: rgba(0,0,0,.06);
}

/* Partner bar */
.partnerBar{
  z-index: 50;
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding: 10px;
  border-radius: 18px;
  border:1px solid var(--stroke2);
  background: rgba(0,0,0,.16);
  cursor:pointer;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(0,0,0,.30);
}
.pfpMiniWrap{
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow:hidden;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  display:grid; place-items:center;
}
#partnerMiniPfp{ width:100%; height:100%; object-fit:cover; display:none; }

.partnerMeta{ display:flex; flex-direction:column; gap:2px; min-width:0; text-align:left; }
.partnerName{ font-weight: 900; font-size: 15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.partnerHandle{ font-weight: 700; font-size: 12px; opacity:.78; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Video stage */
.videoStage{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:center;
  justify-content:flex-start;
}

/* Portrait video wrap */
.videoWrap{
  position:relative;
  width: min(430px, 100%);
  border-radius: 22px;
  overflow:hidden;
  border:1px solid var(--stroke2);
  background: rgba(0,0,0,.22);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}

.videoWrap.portrait{
  aspect-ratio: 9 / 16;
  max-height: 62vh;
}

#remoteVideo{
  width:100%;
  height:100%;
  object-fit:cover;
  background: rgba(0,0,0,.22);
  transform: scaleX(-1);
}

/* Local circle */
.localCircle{
  position:absolute;
  right: 16px;
  bottom: 16px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit:cover;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 18px 55px rgba(0,0,0,.55);
  background: rgba(0,0,0,.25);
  z-index: 120;
  cursor: grab;
  touch-action: none;
  user-select:none;
}
.localCircle:active{ cursor: grabbing; }

/* HUD top buttons */
.hudTop{
  position:absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  z-index: 160;
  pointer-events: none;
}
.hudBtn{
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  color: rgba(255,255,255,.92);
  display:grid;
  place-items:center;
  cursor:pointer;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
}
.hudBtn.small{
  width: 40px;
  height: 40px;
  border-radius: 14px;
}

/* Chat overlay INSIDE video only */
.chatOverlay{
  position:absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  height: 46%;
  max-height: 320px;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(10,12,18,.72);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 55px rgba(0,0,0,.50);
  z-index: 170;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.chatOverlayTop{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}
.chatOverlayTitle{ font-weight: 900; }
.chatOverlayStatus{
  font-weight: 750;
  opacity: .78;
  font-size: 12px;
  margin-left:auto;
  margin-right: 4px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 52%;
}
.chatOverlayBody{
  padding: 10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:0;
  flex:1;
}
.chatMessages{
  flex:1;
  min-height:0;
  overflow:auto;
  padding: 10px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.16);
  font-size: 13px;
  line-height: 1.35;
}

.chatRow{ display:flex; gap:10px; align-items:center; }
.chatRow input{
  flex:1;
  min-width:0;
  padding: 12px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  outline:none;
}
.sendBtn{
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  cursor:pointer;
  display:grid;
  place-items:center;
}

/* Searching overlay */
.searchOverlay{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  z-index: 140;
  pointer-events:none;
}
.searchPulse{
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.20);
  box-shadow: 0 0 0 0 rgba(255,255,255,.18);
  animation: pulse 1.35s ease-out infinite;
  background: rgba(0,0,0,.14);
}
@keyframes pulse{
  0%{ transform: scale(.92); box-shadow: 0 0 0 0 rgba(255,255,255,.18); opacity:.95; }
  70%{ transform: scale(1.15); box-shadow: 0 0 0 26px rgba(255,255,255,0); opacity:.85; }
  100%{ transform: scale(1.15); box-shadow: 0 0 0 26px rgba(255,255,255,0); opacity:0; }
}
.searchText .t1{ font-weight: 900; font-size: 16px; text-align:center; }
.searchText .t2{ font-weight: 700; font-size: 12px; opacity:.75; text-align:center; }

/* Actions + bottom controls */
.actionsRow{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
}
.iconAction{
  width: 48px; height: 48px;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.14);
  box-shadow: var(--shadow2);
  display:grid; place-items:center;
  cursor:pointer;
}

.bottomControls{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  padding-bottom: 2px;
}
.ctlBtn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 12px 14px;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.14);
  box-shadow: var(--shadow2);
  cursor:pointer;
  font-weight: 850;
}
.ctlBtn.danger{
  border-color: rgba(255,80,80,.30);
  background: rgba(120,0,0,.18);
}

/* Call Code Panel */
.callCodePanel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 90%);
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 24px;
  z-index: 3000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* Panels */
.panel{
  position: fixed;
  left: 50%;
  top: 74px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 20px));
  max-height: calc(100vh - 96px);
  overflow:auto;

  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,12,18,.62);
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
  backdrop-filter: blur(18px);
  z-index: 2000;
}
.panelHeader{
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.16);
}
.panelTitle{ font-weight: 900; font-size: 16px; }
.panelSub{ margin-top: 6px; opacity: .78; font-weight: 650; font-size: 12px; line-height: 1.35; }
.panelBody{ padding: 14px 16px 16px; display:flex; flex-direction:column; gap:12px; }

.fieldRow{ display:flex; flex-direction:column; gap:8px; }
.fieldRow label{ font-size: 12px; opacity: .82; font-weight: 750; }
.fieldRow input, .fieldRow select{
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  outline:none;
}
.rowBtns{ display:flex; gap:10px; }
.panelBtn{
  flex:1;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  cursor:pointer;
  font-weight: 850;
}
.panelBtn.small{ width: fit-content; align-self:flex-start; }
.authMsg{ min-height: 18px; font-size: 12px; opacity: .85; color: rgba(255,200,200,.95); }

/* My preview card */
.myPreviewCard{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.14);
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
}
.myPreviewPfp{
  width: 58px; height: 58px;
  border-radius: 50%;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  display:grid; place-items:center;
}
#myPfpPreview{ width:100%; height:100%; object-fit:cover; }
.myPreviewRight{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.myPreviewName{ font-weight: 900; font-size: 15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.myPreviewHandle{ font-weight: 800; font-size: 12px; opacity:.78; }
.myPreviewGender{ font-weight: 750; font-size: 12px; opacity:.70; }

/* Partner profile overlay */
.overlay{
  position:fixed;
  inset:0;
  z-index: 2100;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding: 12px;
}
.sheet{
  width: min(520px, 100%);
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,12,18,.72);
  box-shadow: 0 30px 90px rgba(0,0,0,.60);
  overflow:hidden;
  position:relative;
}
.sheetBg{ position:absolute; inset:0; opacity:.22; background-size: cover; background-position:center; }
.sheetTop{
  position:relative;
  z-index:2;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.16);
}
.sheetTitle{ font-weight: 900; }
.sheetBody{ position:relative; z-index:2; padding: 16px; display:flex; flex-direction:column; gap:14px; }
.heroRow{ display:flex; gap:12px; align-items:center; }
.heroPfp{
  width: 62px; height: 62px;
  border-radius: 50%;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  overflow:hidden;
  display:grid; place-items:center;
}
#profileHeroImg{ width:100%; height:100%; object-fit:cover; }
.heroName{ font-weight: 900; font-size: 18px; }
.heroHandle{ font-weight: 750; opacity:.78; font-size: 13px; }
.bioBox{
  padding: 12px;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.14);
  font-size: 13px;
  line-height: 1.35;
}
.bgPreview{
  height: 120px;
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.12);
  background-size: cover;
  background-position: center;
}

/* Responsive */
@media (max-width: 520px){
  .btnText{ display:none; }
  .videoWrap{ width: 100%; }
  .videoWrap.portrait{ max-height: 56vh; }
  .localCircle{ width: 86px; height: 86px; }
  .chatOverlay{ height: 52%; }
  .videoGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
  }
  .videoGrid.circle-mode .videoTile {
    width: 120px;
    height: 120px;
  }
}

@media (min-width: 768px) {
  .videoGrid {
    grid-template-columns: repeat(3, 1fr);
  }
  .videoGrid.has-4-or-more {
    grid-template-columns: repeat(4, 1fr);
  }
  .videoGrid.has-6-or-more.circle-mode {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Add these styles to your existing style.css */

/* Screen share active state */
.hudBtn.active {
  border-color: #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

.hudBtn.active span {
  color: #4CAF50;
}

/* Camera flip active state */
#cameraFlipIcon.active {
  color: #4CAF50;
}

/* Screen share icon active state */
#screenShareIcon.active {
  color: #4CAF50;
}

/* Mobile responsive fixes */
@media (max-width: 520px) {
  .hudTop {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  
  .hudBtn {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }
  
  .hudBtn.small {
    width: 36px;
    height: 36px;
  }
}

/* Screen share border */
.screenShareActive {
  border: 2px solid #4CAF50 !important;
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.5) !important;
}

/* Fix for video elements on mobile */
video {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
}


/* Add to your existing style.css */

/* Active states for buttons */
.hudBtn.active {
  border-color: #4CAF50 !important;
  background: rgba(76, 175, 80, 0.1) !important;
}

.hudBtn.active span {
  color: #4CAF50 !important;
}

#screenShareIcon.active {
  color: #4CAF50 !important;
}

#cameraFlipIcon.active {
  color: #4CAF50 !important;
}

/* Screen share border */
.screenShareActive {
  border: 2px solid #4CAF50 !important;
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.5) !important;
}

/* Video container fixes */
video {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
}

/* Partner video when screen sharing */
.partnerScreenSharing #remoteVideo {
  transform: scaleX(1) !important;
}

/* Screen share indicator */
.screenShareIndicator {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #4CAF50;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  z-index: 100;
  display: none;
}

.screenShareIndicator.active {
  display: block;
}