/* ═══════════════════════════════════════════════════════════
   Top Navigation Bar + Bottom Dock
   Ported from V2 monolith, adapted for V3 variables & movita branding
   ═══════════════════════════════════════════════════════════ */

/* -------- Toolbar (desktop) -------- */
.toolbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(60px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex; gap: 8px; align-items: center;
  padding-left: 14px; padding-right: 14px;
  z-index: 10; pointer-events: none;
  background: linear-gradient(to bottom, rgba(11,13,16,.92) 0%, rgba(11,13,16,.75) 70%, transparent 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.toolbar > * { pointer-events: auto; }

/* -------- Nav layout groups (mobile: left/center/right, desktop: inline) -------- */
.nav-left { display: contents; }
.nav-center-title { display: none; }
.nav-right { display: contents; }

/* -------- Brand -------- */
.brand {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -.02em;
  flex-shrink: 0;
  box-shadow: none;
  margin-right: 16px;
}
/* Brand split: "mo" white, "vita" gradient — Netflix-style treatment */
.brand-desktop {
  color: var(--text);
  letter-spacing: .02em;
  font-size: 18px;
}
.brand-vita {
  background: linear-gradient(90deg, var(--vita-v), var(--vita-i), var(--vita-t), var(--vita-a));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand .count-info {
  color: var(--muted); font-weight: 500; margin-left: 6px;
  -webkit-text-fill-color: var(--muted);
}
.brand-mobile { display: none; }

/* ─── LIVE dot — pulsing red indicator, aligned with lowercase "a" ─── */
.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: #ffffff;
  border-radius: 50%;
  margin-left: 2px;
  vertical-align: middle;
  position: relative;
  top: 0px;
  box-shadow: 0 0 4px rgba(255,255,255,.6);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(255,255,255,.6); }
  50%      { opacity: .4; box-shadow: 0 0 8px rgba(255,255,255,.3); }
}

/* -------- Search -------- */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-btn {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: none; border-radius: 8px;
  color: rgba(255,255,255,.5); padding: 7px 8px; cursor: pointer; font-size: 0;
  display: flex; align-items: center; justify-content: center; gap: 0; transition: background .15s, color .15s;
  width: 32px; height: 32px;
}
.search-btn:hover {
  background: rgba(255,255,255,.1);
  color: var(--text);
}
.search-flyout {
  position: absolute; top: calc(100% + 6px); left: 0;
  z-index: 65; width: 340px;
  background: linear-gradient(145deg, rgba(22,14,42,.92) 0%, rgba(10,16,32,.93) 50%, rgba(14,22,36,.92) 100%);
  backdrop-filter: blur(60px) saturate(1.8); -webkit-backdrop-filter: blur(60px) saturate(1.8);
  border: 1px solid rgba(255,255,255,.12); border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transform: translateY(-8px); transition: opacity .2s, transform .2s;
  overflow: hidden;
}
.search-flyout.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.search-flyout-head {
  display: flex; border-bottom: 1px solid rgba(255,255,255,.08); padding: 4px;
  background: rgba(255,255,255,.03);
}
.search-flyout-head button {
  flex: 1; padding: 8px; border: none; background: transparent; color: rgba(255,255,255,.4);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: color .15s, background .15s;
  border-radius: 8px;
}
.search-flyout-head button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(59,130,246,.2));
  box-shadow: 0 0 12px rgba(139,92,246,.15);
}
.search-flyout input {
  width: 100%; padding: 12px 16px; border: none; background: transparent;
  color: var(--text); font-size: 14px; outline: none;
  border-bottom: 1px solid rgba(255,255,255,.06); box-sizing: border-box;
}
.search-flyout input::placeholder { color: rgba(255,255,255,.3); }
.search-results { max-height: 280px; overflow-y: auto; }
.search-result {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  transition: background .12s;
}
.search-result:hover { background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(59,130,246,.06)); }
.search-result .sr-icon { font-size: 16px; width: 28px; text-align: center; flex-shrink: 0; opacity: .6; }
.search-result .sr-info { flex: 1; min-width: 0; }
.search-result .sr-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result .sr-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* -------- View Mode Tabs (desktop center) -------- */
.viewmode {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 4px;
  display: flex; gap: 2px;
  box-shadow: none;
}
/* Sliding highlight indicator */
.viewmode-highlight {
  position: absolute;
  top: 4px; left: 4px;
  height: calc(100% - 8px);
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(139,92,246,.38), rgba(99,102,241,.32));
  box-shadow: 0 0 16px rgba(139,92,246,.2), inset 0 0 0 1px rgba(255,255,255,.12);
  transition: left .35s cubic-bezier(.34, 1.56, .64, 1), width .3s cubic-bezier(.16, 1, .3, 1);
  pointer-events: none;
  z-index: 0;
}
.viewmode button {
  position: relative; z-index: 1;
  background: transparent; border: none; color: rgba(255,255,255,.35);
  padding: 6px 12px; border-radius: 9px; font-weight: 600; cursor: pointer;
  font-size: 12px; display: flex; align-items: center; gap: 5px;
  transition: color .2s cubic-bezier(.45, 0, .15, 1),
              transform .2s cubic-bezier(.34, 1.56, .64, 1);
}
.viewmode button:hover { color: rgba(255,255,255,.7); transform: translateY(-1px); }
.viewmode button:active { transform: scale(.92); transition-duration: .06s; }
.viewmode button.active {
  color: #fff;
  text-shadow: 0 0 10px rgba(139,92,246,.4);
}
/* Nav button SVG icons — inherit color from parent */
.viewmode button svg {
  flex-shrink: 0;
  opacity: .85;
}

/* -------- Spacer -------- */
.spacer { flex: 1; }

/* -------- Bell / Notifications -------- */
/* -------- Galactic Button -------- */
.galactic-btn {
  background: none;
  border: none; border-radius: 8px;
  padding: 6px 8px; cursor: pointer;
  font-size: 16px; line-height: 1;
  transition: all .2s ease;
  box-shadow: none;
  color: rgba(255,255,255,.5);
}
.galactic-btn:hover {
  color: var(--text);
  transform: scale(1.1);
}

.bell-wrap { position: relative; }
.bell-btn {
  position: relative;
  background: none;
  border: none; border-radius: 8px;
  color: rgba(255,255,255,.5); padding: 6px 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s;
  box-shadow: none;
}
.bell-btn:hover {
  color: var(--text);
}
.bell-dot {
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  display: none;
  animation: pulse-dot 2s ease-in-out infinite;
}
.bell-dot.active { display: block; }

/* -------- Bell Flyout (Notifications panel) -------- */
.bell-flyout {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-height: 420px;
  background: linear-gradient(160deg, rgba(22,14,42,.92) 0%, rgba(10,16,32,.93) 50%, rgba(14,22,36,.92) 100%);
  backdrop-filter: blur(60px) saturate(1.8); -webkit-backdrop-filter: blur(60px) saturate(1.8);
  border: 1px solid rgba(255,255,255,.12); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08);
  overflow: hidden; z-index: 55;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transform: translateY(-8px);
  transition: opacity .2s, transform .2s;
}
.bell-flyout.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.bell-head {
  padding: 12px 14px; font-weight: 800; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center;
}
.bell-head small { font-weight: 500; color: var(--muted); font-size: 11px; }
.bell-list { overflow-y: auto; padding: 4px 0; max-height: 360px; }
.bell-list .bell-empty {
  padding: 24px 14px; text-align: center;
  color: var(--muted); font-size: 12px;
}
.bell-item {
  padding: 10px 14px; display: flex; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 12px; transition: background .12s;
}
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: rgba(139,92,246,.06); }
.bell-item.unread { background: rgba(124,156,255,.06); }
.bell-item .bi-av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--text);
}
.bell-item .bi-body { flex: 1; min-width: 0; line-height: 1.35; }
.bell-item .bi-body b { color: var(--text); }
.bell-item .bi-body .bi-text {
  color: var(--muted); display: block; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bell-item .bi-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }

/* -------- Me / Avatar -------- */
.me {
  position: relative; cursor: pointer;
  background: none;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: flex; align-items: center; gap: 8px;
  box-shadow: none;
}
.me .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
  overflow: hidden;
}
.me .av img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

/* -------- Avatar Dropdown -------- */
.me-dropdown {
  display: none;
  position: absolute; top: 100%; right: 0;
  margin-top: 4px;
  background: linear-gradient(155deg, rgba(22,14,42,.92) 0%, rgba(10,16,32,.93) 50%, rgba(14,22,36,.92) 100%);
  backdrop-filter: blur(60px) saturate(1.8); -webkit-backdrop-filter: blur(60px) saturate(1.8);
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  padding: 4px; min-width: 140px; z-index: 60;
  box-shadow: 0 12px 36px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
}
.me-dropdown.open { display: block; }
.me-dropdown button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--text);
  padding: 8px 12px; font-size: 13px; font-weight: 500; border-radius: 8px; cursor: pointer;
}
.me-dropdown button:hover {
  background: linear-gradient(135deg, rgba(139,92,246,.1), rgba(59,130,246,.08));
}

/* -------- Sign-in CTA (desktop) -------- */
.nav-cta {
  background: var(--accent); color: var(--bg);
  border-radius: var(--radius-sm); padding: 8px 18px;
  font-weight: 700; font-size: 13px;
  transition: filter var(--transition);
}
.nav-cta:hover { filter: brightness(1.15); }

/* -------- Sign-in link (mobile-friendly, used when not logged in) -------- */
.nav-signin-link {
  color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  opacity: .7; transition: opacity .2s;
  text-decoration: none;
}
.nav-signin-link:hover { opacity: 1; }

/* -------- Prominent Sign-in button (gradient, used when not logged in) -------- */
.nav-signin-btn {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: #fff; font-size: 13px; font-weight: 700;
  padding: 7px 18px; border-radius: 100px; border: none;
  cursor: pointer; white-space: nowrap;
  letter-spacing: .02em;
  transition: filter .2s, transform .15s;
  box-shadow: 0 2px 10px rgba(124,58,237,.35);
}
.nav-signin-btn:hover { filter: brightness(1.15); transform: scale(1.04); }
.nav-signin-btn:active { transform: scale(.97); }

/* -------- Mobile bottom dock (hidden on desktop) -------- */
.mobile-dock { display: none; }

/* ═══════════════════════════════════════════════════════════
   Mobile Responsive (max-width: 760px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* --- Top bar: frosted glass with three-section layout --- */
  .toolbar {
    top: 0; left: 0; right: 0;
    height: 52px;
    padding: 0 12px;
    gap: 0; flex-wrap: nowrap;
    background: rgba(11,13,16,.65);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border-bottom: 1px solid rgba(255,255,255,.08);
  }

  /* --- Three-section layout: left / center / right --- */
  .nav-left {
    display: flex; align-items: center; gap: 4px;
    flex: 1; min-width: 0;
  }
  .nav-center-title {
    display: block;
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px; font-weight: 700; color: var(--text);
    letter-spacing: -.01em;
    white-space: nowrap;
    pointer-events: none;
  }
  .nav-right {
    display: flex; align-items: center; gap: 4px;
    flex: 1; min-width: 0;
    justify-content: flex-end;
  }

  /* Brand = movita logo on mobile (not page title anymore) */
  .brand {
    padding: 0; font-size: 17px; font-weight: 900; border: none; background: none;
    margin-right: 0; letter-spacing: -.01em;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
    flex-shrink: 0;
  }
  .brand .count-info { display: none; }
  .brand-desktop { display: none; }
  .brand-mobile {
    display: inline;
    color: var(--text);
  }
  .brand-mobile .brand-vita {
    background: linear-gradient(90deg, var(--vita-v), var(--vita-i), var(--vita-t), var(--vita-a));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  /* Hide desktop viewmode tabs on mobile — dock replaces them */
  .viewmode { display: none !important; }

  /* Hide galactic button on mobile */
  .galactic-btn { display: none !important; }

  /* Hide chat/messages button on mobile */
  .msg-toggle-btn { display: none !important; }

  /* Hide desktop spacer on mobile */
  .spacer { display: none; }

  /* Search: icon-only on mobile, inside nav-left */
  .search-btn {
    font-size: 0; padding: 6px; gap: 0;
    border: none; background: none; min-width: auto;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
    color: rgba(255,255,255,.5);
  }
  .search-btn:hover { color: var(--text); background: none; }
  .search-btn svg { width: 18px; height: 18px; }
  .search-flyout {
    position: fixed !important; top: 52px !important; left: 50% !important; right: auto !important;
    transform: translateX(-50%) translateY(-8px) !important;
    width: calc(100vw - 32px) !important; max-width: 380px;
    -webkit-backdrop-filter: blur(50px) saturate(1.8) !important;
    backdrop-filter: blur(50px) saturate(1.8) !important;
  }
  .search-flyout.open { transform: translateX(-50%) translateY(0) !important; }

  /* Bell: inside nav-right */
  .bell-btn {
    width: 32px; height: 32px; font-size: 13px;
    border: none; background: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .bell-flyout {
    position: fixed !important; top: 52px !important; right: 8px !important;
    width: calc(100vw - 16px) !important; max-width: 360px;
  }

  /* Me/avatar: inside nav-right, fixed size to prevent clipping */
  .me {
    position: relative;
    padding: 0; border: none; background: none;
    z-index: 11;
    margin-left: 0;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
    flex-shrink: 0;
  }
  .me .av {
    width: 30px; height: 30px; font-size: 11px; cursor: pointer;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,.15);
  }
  .me-dropdown { left: auto; right: 0; }

  /* Sign-in link: simple text, no oversized button */
  .nav-cta { display: none; }
  .nav-signin-link {
    font-size: 12px; font-weight: 600;
    color: rgba(255,255,255,.6);
    padding: 4px 0;
  }
  .nav-signin-btn {
    font-size: 12px; padding: 6px 14px;
  }

  /* --- Bottom dock (Instagram-style) --- */
  .mobile-dock {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 50px;
    background: rgba(0,0,0,.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.06);
    z-index: 12;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .dock-tabs {
    display: flex; justify-content: space-evenly; align-items: center;
    width: 100%; max-width: 380px; padding: 0 8px;
  }
  .dock-tabs button {
    background: none; border: none; color: rgba(255,255,255,.4);
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 4px 0;
    flex: 1; min-width: 0;
    cursor: pointer;
    transition: color .2s cubic-bezier(.45, 0, .15, 1),
                transform .25s cubic-bezier(.34, 1.56, .64, 1);
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .dock-tabs button svg {
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1),
                filter .2s;
  }
  .dock-tabs button .dock-label {
    font-size: 8px; font-weight: 600;
    line-height: 1;
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), opacity .15s;
  }
  .dock-tabs button.active {
    color: #fff;
  }
  .dock-tabs button:active {
    transform: scale(0.85);
    transition-duration: .08s;
  }

  /* Give content room for top bar (+ PWA safe area) and bottom dock */
  #app {
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px));
  }
}

/* ═══════════════════════════════════════════════════════════
   Medium / Narrow-desktop (between mobile dock and full desktop)
   Expandable search: icon-only by default, slides open on click.
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 960px) {
  /* Collapse search to icon-only by default */
  .search-btn {
    min-width: auto;
    font-size: 0;       /* hides the "Search" text */
    padding: 6px 8px;
    gap: 0;
    transition: min-width .3s cubic-bezier(.4,0,.2,1),
                padding .3s cubic-bezier(.4,0,.2,1),
                font-size .3s cubic-bezier(.4,0,.2,1),
                background .15s, border-color .15s;
    overflow: hidden;
    white-space: nowrap;
  }

  /* When expanded via JS (.search-expanded), restore full width */
  .search-wrap.search-expanded .search-btn {
    min-width: 220px;
    font-size: 12px;
    padding: 6px 10px;
    gap: 5px;
  }

  /* Keep the flyout properly positioned when expanded */
  .search-flyout {
    width: 340px;
    max-width: calc(100vw - 32px);
  }
}


/* Desktop: show brand-desktop, hide brand-mobile & center title */
@media (min-width: 769px) {
  .brand-desktop { display: inline; }
  .brand-mobile { display: none; }
  .nav-center-title { display: none; }
}

/* -------- Sign Out Modal -------- */
.signout-overlay {
  position: fixed; inset: 0;
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .25s ease;
}
.signout-overlay.visible { opacity: 1; }
.signout-card {
  background: rgba(28,22,38,.92);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 32px 28px 24px;
  max-width: 320px;
  width: 90vw;
  text-align: center;
  transform: scale(.92);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.signout-overlay.visible .signout-card { transform: scale(1); }
.signout-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,107,157,.12);
  color: var(--accent);
  margin-bottom: 16px;
}
.signout-title {
  font-size: 18px; font-weight: 700;
  color: var(--text); margin: 0 0 6px;
}
.signout-text {
  font-size: 13px; color: var(--muted);
  margin: 0 0 24px; line-height: 1.4;
}
.signout-actions {
  display: flex; gap: 10px;
}
.signout-btn {
  flex: 1; padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background .15s, transform .1s;
}
.signout-btn:active { transform: scale(.96); }
.signout-cancel {
  background: rgba(255,255,255,.08);
  color: var(--text);
}
.signout-cancel:hover { background: rgba(255,255,255,.14); }
.signout-confirm {
  background: rgba(255,107,157,.18);
  color: var(--accent);
}
.signout-confirm:hover { background: rgba(255,107,157,.3); }
