/* ==========================================================================
   Connect Plus — app.css (UPDATED)
   Key rule:
   - The PAGE never scrolls (body overflow hidden)
   - Only these scroll:
     1) .content-inner-scroll (main content)
     2) .cp-sidebar__nav (sidebar menu area)
   ========================================================================== */

/* ====== Reset-ish ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: auto !important; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: rgba(0, 0, 0, .92);
  color: #f5f5f7;

  /* IMPORTANT: page does NOT scroll */
  overflow: hidden;
}

/* Prevent content scroll when opening mobile sidebar */
body.cp-sidebar-open { overflow: hidden; }

/* ====== Layout Shell ====== */
.cp-shell{
  height: 100vh;
  height: 100dvh;
  width: 100%;
  display: flex;
  overflow: hidden;
}

/* ====== Sidebar (base desktop) ====== */
.cp-sidebar{
  width: 250px;
  flex: 0 0 250px;
  height: 100%;
  overflow: hidden;
}

.cp-sidebar__inner{
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Brand */
.cp-sidebar__brand{
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img{ display: block; }
.brand .plus{ height: 20px; cursor: pointer; }
.brand .connect{ height: 30px; width: auto; }

/* Sidebar nav is a SCROLL AREA */
.cp-sidebar__nav{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  padding: 10px;
  display: grid;
  gap: 6px;

  scrollbar-width: none;
}

/* ====== NAV (component styles) ====== */
.cp-nav-title{
  font-size:14px;
  letter-spacing:.12em;
  text-transform:uppercase;
  opacity:.7;
  margin:0 0 10px;
}
.cp-nav{ display:flex; flex-direction:column; gap:0px; }
.cp-nav a{
  display:flex;align-items:center;gap:10px;
  padding:5px 5px;border-radius:12px;
  color:#fff;text-decoration:none;
  border:1px solid transparent;
  opacity:.92;
  min-height:42px;
}
.cp-nav a:hover{
  background:rgba(255,255,255,.08);
  border-color:rgba(255,255,255,.10);
}
.cp-nav a.is-active{ background:rgba(255,255,255,.14); }
.cp-nav__icon{
  width:35px;height:35px;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
}
.cp-nav__icon img{ width:25px;height:25px;object-fit:contain;display:block; }
.cp-nav__icon svg{ width:25px;height:25px;display:block; }
.cp-nav__text{
  font-size:16px;font-weight:400;line-height:1.1; font-style: italic;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
@media (max-width: 720px){
.cp-nav-title{
  font-size:20px;
  letter-spacing:.12em;
  text-transform:uppercase;
  opacity:.7;
  margin:0 0 10px;
}
.cp-nav{ display:flex; flex-direction:column; gap:0px; }
.cp-nav a{
  display:flex;align-items:center;gap:10px;
  padding:5px 5px;border-radius:12px;
  color:#fff;text-decoration:none;
  border:1px solid transparent;
  opacity:.92;
  min-height:42px;
}
.cp-nav a:hover{
  background:rgba(255,255,255,.08);
  border-color:rgba(255,255,255,.10);
}
.cp-nav a.is-active{ background:rgba(255,255,255,.14); }
.cp-nav__icon{
  width:50px;height:50px;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
}
.cp-nav__icon img{ width:25px;height:25px;object-fit:contain;display:block; }
.cp-nav__icon svg{ width:25px;height:25px;display:block; }
.cp-nav__text{
  font-size:20px;font-weight:400;line-height:1.1; font-style: italic;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
}

/* ====== Sidebar Bottom ====== */
.cp-sidebar__bottom{
  margin-top: auto;
  padding: 5px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.cp-sb-profile{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items: center;
}

.cp-sb-dp{
  width:60px;
  height:60px;
  border-radius:50px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:center;
}
.cp-sb-dp img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.cp-sb-dp-fallback{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  font-size:18px;
  color:#fff;
}

.cp-sb-username{
  color:#fff;
  font-weight:600;
  font-size:14px;
  line-height:1.1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.cp-sb-actions{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:15px;
  margin-top: 2px;
}

.cp-sb-action{
  text-decoration:none;
  color:#fff;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
}

.cp-sb-action__btn{
  border-radius:14px;
  background: rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  padding:5px;
}
.cp-sb-action__btn img{
  width:22px;
  height:22px;
  object-fit:contain;
  display:block;
}

.cp-sb-action:hover .cp-sb-action__btn{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.14);
}

.cp-sb-action__label{
  font-size:12px;
  font-weight: 600;
  letter-spacing:.02em;
  text-align:center;
  white-space:nowrap;
}

.cp-sb-action button.cp-sb-action__btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.10);
}

/* ====== Main (fixed height) ====== */
.cp-main{
  flex: 1 1 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 auto;
}

/* cp-content is NOT scrollable. Inner is. */
.cp-content{
  min-height: 0;
  overflow: hidden;
  color: #f5f5f7;
}

/* The ONLY scroll container for main content */
.content-inner-scroll{
  height: 100%;
    scrollbar-width: none;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px;
}

/* ====== Header/Footer (mobile only visible) ====== */
.cp-header,
.cp-footer{ display: none; }

/* ====== Backdrop (mobile only) ====== */
.cp-backdrop{
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 40;
}

/* ==========================================================================
   DESKTOP (>= 992px)
   - No page scroll
   - Sidebar + main fill full height
   - main scroll is only .content-inner-scroll
   ========================================================================== */
@media (min-width: 992px){
  .cp-header, .cp-footer{ display: none !important; }

  .cp-sidebar{
    position: relative;
    transform: none;
    width: 250px;
    flex: 0 0 250px;
    height: 100%;
    background: transparent;
  }

  .cp-backdrop{ display: none !important; }

  .content-inner-scroll{
    padding: 0 10px;
  }
}

/* ==========================================================================
   MOBILE (<= 991.98px)
   - Header + footer visible (NOT overlaying content)
   - Only content-inner-scroll scrolls
   - Off-canvas sidebar
   ========================================================================== */
@media (max-width: 991.98px){
  .cp-shell{
    display: block;              /* sidebar becomes fixed overlay */
    height: 100vh;
    height: 100dvh;
  }

  .cp-main{
    height: 100vh;
    height: 100dvh;
  }

  /* Show header & footer */
  .cp-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;

    height:56px;
    flex: 0 0 56px;

    padding:0 12px;
    background: transparent;
    color:#fff;
    border-bottom:1px solid rgba(255,255,255,.08);

    /* IMPORTANT: do NOT use sticky for this layout
       header stays because it is outside scroll container */
    position: relative;
    z-index: 30;
  }

  .cp-header__menu{
    appearance:none;
    border:0;
    background:transparent;
    padding:6px;
    border-radius:10px;
    cursor:pointer;
  }
  .cp-header__menu-icon{
    width:30px;
    height:30px;
    display:block;
  }

  .cp-header__title{
    font-weight:700;
    opacity:.95;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .cp-header__right{
    display:flex;
    align-items:center;
    gap:6px;
  }

  .cp-hicon{
    width:34px;
    height:34px;
    border-radius:12px;
    border:1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.06);
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
    text-decoration:none;
  }
  .cp-hicon img{
    width:18px;
    height:18px;
    object-fit:contain;
    display:block;
  }
  .cp-hicon-form{ margin:0; }
  .cp-hicon:hover{
    background: rgba(255,255,255,.10);
    border-color: rgba(255,255,255,.14);
  }

  .cp-footer{
    display:grid;
    position: relative;
    grid-template-columns: repeat(5, 1fr);
    gap:8px;

    flex: 0 0 auto;

    background: transparent;
    border-top:1px solid rgba(255,255,255,.08);
    z-index:30;
    padding:8px;
  }

  .cp-footer__item{
    text-decoration:none;
    color: rgba(255,255,255,.88);
    text-align:center;
    padding:10px 6px;
    border-radius:12px;
    border:1px solid rgba(255,255,255,.06);
    background: transparent;
    font-size:13px;
    font-weight:700;
  }
  .cp-footer__item.is-active{
    background: rgba(255,255,255,.10);
    border-color: rgba(255,255,255,.14);
  }

  /* MAIN content still flex:1; only inner scrolls */
  .content-inner-scroll{
    padding: 0 10px;
  }

  /* Off-canvas sidebar */
  .cp-sidebar{
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;

    width: 80vw;
    max-width: 420px;

    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 50;

    flex: none;
    background-color: #000;
    overflow: hidden;
  }

  body.cp-sidebar-open .cp-sidebar{ transform: translateX(0); }
  body.cp-sidebar-open .cp-backdrop{ display:block; }

  /* Mobile brand */
  .brand--desktop{ display:none; }
  .brand--mobile{ display:flex; }
  .brand--mobile .plus{ width:30px; height:30px; }

  .cp-sidebar__bottom{ padding-bottom: 18px; }
}

/* Desktop brand */
@media (min-width: 992px){
  .brand--desktop{ display:flex; }
  .brand--mobile{ display:none; }
}

/* ==========================================================================
   Quick Modals (QR / Create / Search)
   ========================================================================== */
.cp-qm-overlay{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: 0; /* JS sets correct top offset */
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: none;
}

.cp-qm{
  position: fixed;
  z-index: 70;
  display: none;
}

body.cp-qm-open .cp-qm-overlay{ display:block; }
.cp-qm.is-open{ display:block; }

.cp-qm__panel{
  width: 400px;
  max-width: calc(100vw - 24px);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 14px;
  margin: 0 auto;
}

.cp-qm__title{
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .9;
  margin: 2px 2px 10px;
}

.cp-qm__item{
  display: block;
  text-decoration: none;
  color: #fff;
  border-radius: 16px;
  padding: 12px 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  margin-bottom: 10px;
}
.cp-qm__item:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.14);
}
.cp-qm__item-title{
  font-weight: 800;
  font-size: 14px;
}
.cp-qm__item-sub{
  margin-top: 2px;
  font-size: 12px;
  opacity: .85;
}
.cp-qm__hint{
  font-size: 12px;
  opacity: .75;
  padding: 2px 4px;
}

@media (min-width: 992px){
  .cp-qm--qr,
  .cp-qm--create,
  .cp-qm--search{
    left: 250px;
    top: 92px;
    padding-left: 12px;
  }
}

@media (max-width: 991.98px){
  .cp-qm--qr,
  .cp-qm--create,
  .cp-qm--search{
    left: 12px;
    right: 12px;
    top: 70px;
    display: none;
  }
  .cp-qm.is-open{
    display: block;
  }
  .cp-qm__panel{
    width: 100%;
  }
}

.cp-qm-search{ margin-top: 4px; }
.cp-qm-search__row{
  display: grid;
  grid-template-columns: 1fr 46px 56px;
  gap: 10px;
  align-items: center;
}
.cp-qm-search__input{
  height: 44px;
  border-radius: 14px;
  padding: 0 12px;
  outline: none;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  color: #fff;
  font-weight: 700;
}
.cp-qm-search__input::placeholder{ color: rgba(255,255,255,.6); }

.cp-qm-search__voice,
.cp-qm-search__go{
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.cp-qm-search__voice img{
  width: 18px;
  height: 18px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
.cp-qm-search__voice:hover,
.cp-qm-search__go:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.14);
}
.cp-qm-search__voice.is-listening{
  box-shadow: 0 0 0 2px rgba(171,0,255,.35);
}
.cp-qm-search__voice.is-disabled{
  opacity: .55;
  cursor: not-allowed;
}
.cp-qm-search__status{
  margin-top: 8px;
  font-size: 12px;
  opacity: .8;
  min-height: 16px;
}
