/* mobile-ui.css — floating + (note) FAB, chat hub menu, install card,
   mobile drawer, dashboard message previews, admin feature grid, and
   mobile-first responsive overrides. */

/* Hide all floating helpers while auth-gate / boot loader are visible. */
.auth-gate.show ~ .note-fab,
.auth-gate.show ~ .chat-fab,
.auth-gate.show ~ .install-card,
.auth-gate.show ~ .chat-hub,
.auth-gate.show ~ .drawer,
.auth-gate.show ~ .drawer-scrim,
.auth-gate.show ~ #tts-toggle-fab,
body.app-loading .note-fab,
body.app-loading .chat-fab,
body.app-loading .install-card,
body.app-loading .chat-hub,
body.app-loading #tts-toggle-fab{
  display:none !important;
}

.more-features-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
@media(max-width:720px){
  .more-features-toggle span{
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip:rect(0 0 0 0);
  }
  .more-features-toggle{
    width:40px;
    height:40px;
    justify-content:center;
    padding:0;
    border-radius:50%;
  }
}

/* === Hamburger menu button (visible only on mobile) === */
.menu-toggle{display:none;margin-right:4px}
@media(max-width:980px){
  .menu-toggle{display:inline-grid}
}

/* === Slide-out Drawer (mobile sidebar) === */
.drawer-scrim{
  position:fixed;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(2px);
  opacity:0;pointer-events:none;transition:opacity .2s;z-index:400;
}
.drawer-scrim.open{opacity:1;pointer-events:auto}
.drawer{
  position:fixed;left:0;top:0;bottom:0;width:min(84vw,300px);
  background:var(--surface);border-right:1px solid var(--border);
  box-shadow:14px 0 36px rgba(15,23,42,.22);
  transform:translateX(-102%);transition:transform .26s ease;
  z-index:410;display:flex;flex-direction:column;overflow:hidden;
}
.drawer.open{transform:translateX(0)}
.drawer-head{
  display:flex;justify-content:space-between;align-items:center;
  padding:14px 14px 10px;border-bottom:1px solid var(--border);
  background:linear-gradient(135deg,rgba(0,89,186,.08),rgba(0,105,107,.06));
}
.drawer-title{display:flex;align-items:center;gap:8px;font-weight:800;font-size:1rem;color:var(--text)}
.drawer-title .ico{width:22px;height:22px;color:var(--accent)}
.drawer-nav{flex:1;overflow-y:auto;padding:8px 6px 22px}
/* Reuse `.nav-item` styles from base.css so drawer looks like sidebar. */
.drawer-nav .nav-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;cursor:pointer;color:var(--text);font-weight:600;font-size:.9rem}
.drawer-nav .nav-item:hover{background:var(--surface2)}
.drawer-nav .nav-item.active{background:var(--accent-soft);color:var(--accent);font-weight:700;position:relative}
.drawer-nav .nav-item.active::before{content:'';position:absolute;left:0;top:20%;bottom:20%;width:3px;border-radius:3px;background:linear-gradient(180deg,#0059ba,#00696b)}
.drawer-nav .nav-item .nav-icon{display:grid;place-items:center;width:22px;height:22px;color:var(--text2)}
.drawer-nav .nav-item.active .nav-icon{color:var(--accent)}
.drawer-nav .nav-item .nav-badge{margin-left:auto;background:var(--surface2);padding:2px 8px;border-radius:99px;font-size:.7rem;font-weight:700;color:var(--text2)}
.drawer-nav .nav-item .nav-badge.warn{background:rgba(245,158,11,.14);color:var(--warn)}
.drawer-nav .sidebar-section-label{
  padding:12px 12px 6px;font-size:.68rem;font-weight:700;
  letter-spacing:.08em;text-transform:uppercase;color:var(--text3);
}
.drawer-nav .sidebar-divider{height:1px;background:var(--border);margin:6px 12px}

/* === Floating note FAB === */
.note-fab{
  position:fixed;right:14px;bottom:204px;width:48px;height:48px;border-radius:50%;
  background:var(--cta-grad);color:#fff;
  display:grid;place-items:center;border:none;cursor:pointer;
  box-shadow:0 4px 16px rgba(0,89,186,.35);
  z-index:300;transition:transform .15s, box-shadow .2s;
  touch-action:none;
}
.note-fab:hover{transform:scale(1.05)}
.note-fab:active{transform:scale(.96)}
.note-fab .ico{width:22px;height:22px}

/* Chat FAB: part of the right-side FAB column + touch-action for drag. */
.chat-fab{bottom:144px !important;right:14px !important;touch-action:none}

/* === Chat hub === */
.chat-hub{
  position:fixed;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(2px);
  display:none;align-items:flex-end;justify-content:center;z-index:340;
  animation:hub-fade .18s ease;
}
.chat-hub.open{display:flex}
@keyframes hub-fade{from{opacity:0}to{opacity:1}}
.chat-hub-card{
  width:min(440px,100%);background:var(--surface);
  border-top-left-radius:20px;border-top-right-radius:20px;
  padding:18px 16px 26px;border:1px solid var(--border);border-bottom:none;
  box-shadow:0 -20px 40px rgba(15,23,42,.25);
  display:grid;grid-template-columns:repeat(2,1fr);gap:10px;
  animation:hub-slide .22s ease;
}
@keyframes hub-slide{from{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}
.chat-hub-head{
  grid-column:1 / -1;display:flex;justify-content:space-between;align-items:center;
  font-weight:700;color:var(--text);font-size:.95rem;margin-bottom:4px;
}
.chat-hub-head button{background:transparent;color:var(--text2);border:none;cursor:pointer;font-size:1.3rem}
.chat-hub-btn{
  display:flex;flex-direction:column;align-items:flex-start;gap:4px;
  padding:14px;border-radius:14px;background:var(--surface2);border:1px solid var(--border);
  color:var(--text);cursor:pointer;text-align:left;
  transition:transform .12s, background .15s;
}
.chat-hub-btn:hover{background:var(--accent-soft);transform:translateY(-2px)}
.chat-hub-btn .ico{width:20px;height:20px;color:var(--accent)}
.chat-hub-btn-title{font-weight:700;font-size:.9rem}
.chat-hub-btn-sub{font-size:.72rem;color:var(--text2)}

/* === Install / Download App card (redesigned) === */
.install-card{
  position:fixed;left:50%;bottom:80px;
  transform:translateX(-50%) translateY(140%);
  width:min(92vw,460px);
  background:var(--cta-grad);
  color:#fff;border-radius:18px;padding:14px 16px 14px 14px;
  display:flex;align-items:center;gap:12px;
  box-shadow:0 24px 50px rgba(0,89,186,.4),0 0 0 1px rgba(255,255,255,.08) inset;
  z-index:295;transition:transform .45s cubic-bezier(.2,.8,.2,1),opacity .3s;
  opacity:0;pointer-events:none;
}
.install-card.show{transform:translateX(-50%) translateY(0);opacity:1;pointer-events:auto}
.install-close{
  position:absolute;top:6px;right:6px;width:26px;height:26px;
  background:rgba(255,255,255,.18);border:none;border-radius:50%;
  color:#fff;cursor:pointer;display:grid;place-items:center;
  opacity:.85;transition:opacity .15s, background .15s;
}
.install-close:hover{opacity:1;background:rgba(255,255,255,.28)}
.install-close .ico{width:14px;height:14px}
.install-icon{
  width:42px;height:42px;border-radius:12px;flex-shrink:0;
  background:rgba(255,255,255,.2);display:grid;place-items:center;
  box-shadow:0 8px 16px rgba(0,0,0,.15);
}
.install-icon .ico{width:22px;height:22px;color:#fff}
.install-body{flex:1;min-width:0;line-height:1.25}
.install-heading{font-weight:800;font-size:.94rem;letter-spacing:.01em;padding-right:22px}
.install-sub{font-size:.74rem;opacity:.92;margin-top:2px}
.install-go{
  background:#fff;color:var(--accent2,#00696b);border:none;
  border-radius:99px;padding:9px 16px;font-weight:800;font-size:.82rem;
  cursor:pointer;display:inline-flex;align-items:center;gap:6px;
  box-shadow:0 6px 14px rgba(0,0,0,.15);
  transition:transform .12s;flex-shrink:0;
}
.install-go:hover{transform:translateY(-1px)}
.install-go .ico{width:14px;height:14px}

/* Subtle pulse on the shadow to draw attention without disturbing the
   transform (so positioning overrides keep working). */
.install-card.show{animation:install-pulse 2.4s ease-in-out 1s infinite}
@keyframes install-pulse{0%,100%{box-shadow:0 24px 50px rgba(0,89,186,.4),0 0 0 1px rgba(255,255,255,.08) inset}50%{box-shadow:0 28px 70px rgba(0,105,107,.6),0 0 0 1px rgba(255,255,255,.12) inset}}

/* Desktop: nudge into bottom-right corner. */
@media(min-width:1200px){
  .install-card{left:auto;right:24px;bottom:24px;transform:translateY(140%)}
  .install-card.show{transform:translateY(0)}
}

/* === Dashboard preview grid (Community + DM) === */
.preview-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:18px;
}
.preview-card{
  background:var(--surface);border:1px solid var(--border);border-radius:16px;
  padding:14px;display:flex;flex-direction:column;gap:10px;min-height:140px;
}
.preview-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.preview-title{font-weight:700;font-size:.92rem;color:var(--text);display:flex;align-items:center;gap:6px}
.preview-title .ico{width:18px;height:18px;color:var(--accent)}
.preview-list{flex:1;display:flex;flex-direction:column;gap:6px;min-height:60px}
/* Class Resources widget: card height fits content (no forced whitespace). */
#qbclass-widget{height:fit-content;min-height:0}
#qbclass-widget .preview-list{flex:0 0 auto;min-height:0}
.preview-empty{font-size:.8rem;color:var(--text3);text-align:center;padding:12px;background:var(--surface2);border-radius:10px}
.preview-row{
  display:flex;gap:8px;align-items:flex-start;padding:8px 10px;
  border-radius:10px;background:var(--surface2);cursor:pointer;
  transition:background .15s;
}
.preview-row:hover{background:var(--accent-soft)}
.preview-avatar{
  width:30px;height:30px;border-radius:50%;background:var(--accent-soft);
  display:grid;place-items:center;font-size:.75rem;font-weight:700;color:var(--accent);
  flex-shrink:0;overflow:hidden;
}
.preview-avatar img{width:100%;height:100%;object-fit:cover}
.preview-row-body{flex:1;min-width:0}
.preview-row-name{font-size:.82rem;font-weight:700;color:var(--text);display:flex;justify-content:space-between;gap:6px}
.preview-row-time{font-size:.68rem;color:var(--text3);font-weight:500;flex-shrink:0}
.preview-row-msg{font-size:.78rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}

/* === Feature grid (admin-managed more features) === */
.feature-grid{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));
  gap:10px;margin-top:10px;
}
.feature-tile{
  position:relative;background:var(--surface);border:1px solid var(--border);
  border-radius:14px;padding:14px 12px;cursor:pointer;
  display:flex;flex-direction:column;align-items:flex-start;gap:8px;
  transition:transform .15s, box-shadow .2s, border-color .15s;
  text-align:left;color:var(--text);
}
.feature-tile:hover{transform:translateY(-2px);box-shadow:0 10px 22px rgba(15,23,42,.08);border-color:var(--accent)}
.feature-tile-icon{
  width:38px;height:38px;border-radius:10px;
  background:var(--accent-soft);display:grid;place-items:center;
}
.feature-tile-icon .ico{width:20px;height:20px;color:var(--accent)}
.feature-tile-title{font-weight:700;font-size:.9rem;line-height:1.2}
.feature-tile-sub{font-size:.72rem;color:var(--text2);line-height:1.3}
.feature-badge{
  position:absolute;top:8px;right:8px;
  font-size:.62rem;font-weight:800;letter-spacing:.04em;
  padding:3px 7px;border-radius:99px;text-transform:uppercase;
}
.feature-badge.hot{background:#fee2e2;color:#dc2626}
.feature-badge.new{background:#dbeafe;color:#1d4ed8}
.feature-badge.upcoming{background:#E9F2EC;color:#00696b}

/* Install card inside Settings */
.install-status{
  font-size:.82rem;padding:8px 12px;border-radius:10px;margin-bottom:10px;
  background:var(--surface2);color:var(--text2);display:none;
}
.install-status.success{background:rgba(0,89,186,.12);color:var(--accent3);display:block}
.install-status.warn{background:rgba(245,158,11,.12);color:var(--warn);display:block}
.install-status.info{background:rgba(0,89,186,.1);color:var(--accent);display:block}

/* === Mobile responsive === */
.bottom-nav-item .ico{width:22px;height:22px}
.bottom-nav-item{min-height:48px}

@media(max-width:980px){
  .content{padding-bottom:calc(90px + env(safe-area-inset-bottom,0px)) !important}
  .chat-fab{bottom:124px !important;right:10px}
  .note-fab{bottom:176px;right:10px}
  #tts-toggle-fab{bottom:72px !important}
  .install-card{bottom:74px}
  .modal-close{width:40px;height:40px}
  .form-group input, .form-group textarea, .form-group select{font-size:16px;padding:11px 12px}
  .btn{min-height:42px}
  .note-card{padding:12px}
  .note-card-title{font-size:.95rem}
  .note-card-content{font-size:.84rem}
  .section-header{flex-wrap:wrap;gap:8px}
  .modal{max-width:calc(100vw - 16px);margin:8px}
  .modal.lg{max-width:calc(100vw - 16px)}
  .modal-body{max-height:65vh;overflow-y:auto}
  .preview-grid{grid-template-columns:1fr}
  .feature-grid{grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:8px}
  .feature-tile{padding:12px 10px}
  .feature-tile-title{font-size:.82rem}
}

@media(max-width:560px){
  .chat-hub-card{grid-template-columns:1fr}
  .install-heading{font-size:.88rem}
  .install-sub{font-size:.7rem}
  .install-go{padding:8px 12px;font-size:.78rem}
  .section-header .section-title{font-size:1.05rem}
  header .header-actions .label{display:none}
  .dm-layout{grid-template-columns:1fr;grid-template-rows:auto 1fr}
  .dm-sidebar{display:flex;overflow-x:auto;padding:6px;gap:6px;border-right:none;border-bottom:1px solid var(--border)}
  .dm-friend{flex:0 0 auto;flex-direction:row;padding:6px 10px;border-radius:99px}
  .lb-table .lb-school{display:none}
  .quiz-options{grid-template-columns:1fr}
  /* Shrink header on very small screens. */
  header{gap:6px;padding:8px 10px !important}
  .logo{font-size:.95rem}
}

/* Tiny phones: drop logo text so header controls never overflow. */
@media(max-width:420px){
  header{padding:6px 8px !important}
  .logo #app-name-header{display:none}
  .logo-img{width:30px;height:30px}
  .header-actions{gap:2px}
  .lang-toggle-btn{font-size:.72rem;padding:5px 8px}
  .btn-icon{width:32px;height:32px}
  .user-avatar{width:30px;height:30px}
  .top-status{gap:8px}
}

.bottom-nav{box-shadow:0 -8px 24px rgba(22,80,50,.08)}
.bottom-nav-item:active{transform:scale(.95)}
.bottom-nav-item.active{color:var(--accent);background:var(--accent-soft);border-radius:12px}
.note-fab[data-dragged="1"], .chat-fab[data-dragged="1"]{transition:none}
