/* =========================================================
   GENERAL PAGE STYLE
   ========================================================= */
body {
  margin: 0;
  background: black;
  overflow: hidden;
  color: white;
  font-family: sans-serif;
}

/* =========================================================
   VIDEOS
   ========================================================= */

/* Remote video: takes the whole screen by default */
#remoteVideo {
  position: absolute;
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: black;
  z-index: 1;
  touch-action: none; /* touch gestures are handled in JS */
}

/* Local video: small overlay at the bottom right */
#localVideo {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 20vw;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 3px solid white;
  z-index: 2;
  touch-action: none;
}

/* When swapped (double-tap), the small and large videos are inverted */
body.videosSwapped #remoteVideo {
  width: 20vw;
  height: auto;
  bottom: 20px;
  right: 20px;
  top: auto;
  left: auto;
  border-radius: 12px;
  border: 3px solid white;
  object-fit: contain;
  z-index: 2;
}

body.videosSwapped #localVideo {
  width: 100vw;
  height: 100vh;
  bottom: auto;
  right: auto;
  top: 0;
  left: 0;
  border: none;
  border-radius: 0;
  object-fit: contain;
  z-index: 1;
}

/* =========================================================
   BUTTONS (common "glassmorphism" style)
   ========================================================= */
button {
  border: none;
  padding: 13px 22px;
  font-size: 17px;
  font-weight: 600;
  color: white;
  border-radius: 14px;
  cursor: pointer;
  box-shadow:
    0 4px 10px rgba(0,0,0,.35),
    inset 0 1px 1px rgba(255,255,255,.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .15s, filter .15s;
  position: relative;
  z-index: 10;
}

/* Small "click" effect on all buttons */
button:active {
  transform: scale(.94);
  filter: brightness(.85);
}

/* --- "Start camera" button (currently unused but kept) --- */
#startCamBtn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: linear-gradient(180deg,#34c759,#20a843);
}

/* --- Call button --- */
#callButton {
  position: absolute;
  top: 20px;
  left: 20px;
  display: none; /* shown only once the name and the device are validated */
  background: linear-gradient(180deg,#34c759,#20a843);
  color: white;
}

/* --- Hang up button --- */
#hangupButton {
  position: absolute;
  top: 90px;
  left: 20px;
  background: linear-gradient(180deg,#ff453a,#d9271d);
  display: none;
}

/* --- Switch camera button --- */
#switchCameraButton {
  position: absolute;
  top: 160px;
  left: 20px;
  width: auto;
  min-width: 58px;
  height: auto;
  padding: 13px 20px;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg,#0a84ff,#0066cc);
  font-size: 17px;
  white-space: nowrap;
}

/* --- "Waiting..." button (centered, not clickable) --- */
#waitingButton {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  padding: 18px 30px;
  font-size: 22px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(180deg,#ff9f0a,#e87800);
  display: none;
  cursor: default;
}

#waitingButton:active {
  transform: translate(-50%,-50%); /* cancels the click effect here */
}

/* =========================================================
   OVERLAY: CALLER NAME
   ========================================================= */
#nameOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#nameBox {
  background: rgba(30,30,30,0.9);
  padding: 30px 35px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.1);
  width: 280px;
}

#nameBox h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 600;
}

#callerNameInput {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 12px;
  border: none;
  outline: none;
  margin-bottom: 18px;
  background: rgba(255,255,255,.1);
  color: white;
  text-align: center;
}

#callerNameInput::placeholder {
  color: rgba(255,255,255,.5);
}

#confirmNameBtn {
  background: linear-gradient(180deg, #0a84ff, #0060df);
  color: #fff;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(10,132,255,0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

#confirmNameBtn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 6px rgba(10,132,255,0.3);
}

#confirmNameBtn:hover {
  background: linear-gradient(180deg, #0070e0, #0055c8);
}

/* =========================================================
   ERROR MODAL
   ========================================================= */
#errorModal {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: none; /* becomes "flex" via JS when shown */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#errorBox {
  background: rgba(50,30,30,0.95);
  padding: 40px 35px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.7);
  border: 2px solid rgba(255,69,58,0.3);
  width: 320px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}

#errorBox h2 {
  margin: 0 0 15px 0;
  font-size: 24px;
  font-weight: 700;
  color: #ff453a;
}

#errorBox p {
  margin: 0 0 25px 0;
  font-size: 16px;
  color: rgba(255,255,255,.8);
  line-height: 1.5;
}

#errorCode {
  background: rgba(255,69,58,0.1);
  padding: 12px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 13px;
  color: #ff9500;
  margin: 15px 0;
  word-break: break-all;
}

#closeErrorBtn {
  background: linear-gradient(180deg, #ff453a, #d9271d);
  color: #fff;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
}

#closeErrorBtn:active {
  transform: scale(0.96);
}

#errorIcon {
  font-size: 48px;
  margin-bottom: 15px;
}

/* =========================================================
   OVERLAY: DEVICE (Raspberry) CHECK
   ========================================================= */
#deviceOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: none; /* becomes "flex" via JS */
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#deviceBox {
  background: rgba(30,30,30,0.9);
  padding: 30px 35px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.1);
  width: 320px;
}

#deviceBox h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 600;
  color: #ff9500;
}

#deviceIdDisplay {
  background: rgba(255,255,255,.1);
  padding: 14px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 14px;
  word-break: break-all;
  margin-bottom: 20px;
  color: #0a84ff;
  font-weight: 600;
  white-space: pre-line; /* keeps the line breaks coming from JS */
}

.deviceHint {
  font-size: 13px;
  color: rgba(255,255,255,.7);
  margin: 0;
}

.deviceHint code {
  color: #0a84ff;
}

/* =========================================================
   LOG AREA (debug)
   ========================================================= */
#log {
  position: absolute;
  top: 220px;
  left: 20px;
  width: 300px;
  height: 200px;
  overflow: auto;
  background: rgba(0,0,0,0.6);
  padding: 10px;
  font-size: 13px;
  z-index: 10;
  border-radius: 12px;
}

/* =========================================================
   "BLINK" ANIMATION (used on the waiting button)
   ========================================================= */
.blink {
  animation: blink 0.5s infinite;
}

@keyframes blink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75%      { opacity: 0; }
}