/* app.css — fixed layout and mobile behaviour (updated) */

/* Reset & fonts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial;
}
:root {
  --bg: #0b1220; /* match navbar dark tone */
  --panel: rgba(255,255,255,0.03);
  --accent: #45f3ff;
  --muted: #9eb3b5;
  --nav-height: 72px;
  /* dynamic viewport unit (set by JS) */
  --vh: 1vh;
}

/* full-viewport app */
html, body, #app {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: #fff;
  overflow-x: hidden;
}

/* overlay for install enforcement */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4,6,8,0.9);
  z-index: 9999;
}
.overlay.hidden { display: none; }
.overlay .overlay-inner {
  text-align: center;
  padding: 28px;
  border-radius: 12px;
  max-width: 420px;
  color: #fff;
}

/* ===== LOGIN SCREEN ===== */
/* fixed, covers entire viewport and sits above everything */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 5000;
  min-height: calc(var(--vh) * 100); /* friendly fallback to dynamic vh */
}

/* login card */
.box {
  width: 360px;
  max-width: 92vw;
  background: linear-gradient(180deg, #10151e 0%, #161b24 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.title h1 {
  color: var(--accent);
  font-size: 1.6rem;
  margin-bottom: 10px;
  text-align: center;
}
.input-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.input-box label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
}
.input-box input[type="text"],
.input-box input[type="password"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.input-box input[type="submit"].Login {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #071018;
  cursor: pointer;
}

/* prevent background scroll while login active */
body.login-active {
  overflow: hidden;
  height: calc(var(--vh) * 100);
}

/* hidden helper */
.hidden { display: none !important; }

/* ===== MAIN APP ===== */
#main-app {
  display: flex;
  flex-direction: column;
  min-height: calc(var(--vh) * 100);
  overflow: hidden;
}
#view-area {
  padding-bottom: var(--nav-height);
  flex: 1;
  overflow: hidden;
  box-sizing: border-box;
  display: block;
}
.tab {
  display: none;
  padding: 12px;
  min-height: calc(var(--vh) * 100 - var(--nav-height));
  box-sizing: border-box;
}
.tab.active { display: block; }

/* Meet iframe */
#meetFrame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
  background: #000;
}

/* Cam tab */
#tab-cam .tab-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
  justify-content: center;
  align-items: center;
  padding: 12px;
}
#localVideo {
  width: 100%;
  height: 100%;
  max-height: calc(var(--vh) * 100 - var(--nav-height) - 80px);
  object-fit: cover;
  border-radius: 12px;
  background: #000;
}

/* ===== BOTTOM NAV ===== */
/* hidden by default until login; .visible class shows it */
#bottom-nav {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 64px;
  display: none; /* hidden until login */
  gap: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  align-items: center;
  z-index: 40;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
}
#bottom-nav.visible { display: flex; }

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: #cdd6da;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { opacity: 0.95; width: 22px; height: 22px; }
.tab-btn.active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
}

/* remove default yellow/blue focus rings in mobile browsers,
   but keep a visible focus for keyboard users via :focus-visible.
   If you prefer no visible focus at all, remove the :focus-visible block. */
.tab-btn:focus { outline: none; box-shadow: none; }
.tab-btn:focus-visible {
  outline: 2px solid rgba(69,243,255,0.12);
  outline-offset: 2px;
}

/* draggable preview */
#draggable-preview {
  position: fixed;
  width: 140px;
  height: 180px;
  right: 12px;
  bottom: 92px;
  z-index: 9999;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  background: #000;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
#draggable-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* helpers */
.login-error {
  color: #ffb4b4;
  margin-top: 8px;
  font-size: 0.9rem;
  text-align: center;
}
.tab-title {
  font-weight: 600;
  color: #dfe7e9;
  margin-bottom: 8px;
}

/* === FIX: Ensure Meet tab iframe fills space responsively === */
#tab-meet {
  display: flex;
  flex-direction: column;
  height: calc(var(--vh) * 100 - var(--nav-height));
  overflow: hidden;
  padding: 0; /* override default tab padding */
}

#tab-meet .tab-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#tab-meet iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* === Ensure Control and Insight iframes behave like Meet === */
#tab-control,
#tab-insight {
  display: flex;
  flex-direction: column;
  height: calc(var(--vh) * 100 - var(--nav-height));
  overflow: hidden;
  padding: 0; /* remove default tab padding */
}

#tab-control iframe,
#tab-insight iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* responsive */
@media (max-width: 720px) {
  .box { border-radius: 14px; padding: 16px; }
  #bottom-nav { left: 6px; right: 6px; bottom: 6px; height: 68px; }
  #draggable-preview { width: 120px; height: 160px; bottom: 86px; }
}

/* === Fix Meet iframe layout shrink === */
#main-app,
.tab {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* === FINAL OVERRIDE: full viewport responsive layout fix === */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #000;
}

/* App container fills screen */
#app,
#main-app,
#view-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

/* Each tab should fully occupy available height */
.tab {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Title row (optional) */
.tab-title {
  flex: 0 0 auto;
  padding: 4px 8px;
  background: #0b1220;
  color: #fff;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Main body fills remaining height */
.tab-body {
  flex: 1 1 auto;
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Force iframes to fill .tab-body */
.tab-body iframe,
#meetFrame,
#controlFrame,
#insightFrame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

/* Local video also fills its tab */
#localVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Optional: bottom nav, if exists */
#bottom-nav {
  flex: 0 0 auto;
}

/* Ensure visible tab fully fills viewport */
.tab.active, .tab.visible {
  display: flex !important;
  height: 100% !important;
}

