/* social.css — leaderboard, friends, dm, class community, quizzes, shared notes,
   boot loader, and supporting bits. Keeps these features visually consistent
   with the rest of the app while staying mobile-responsive by default. */

/* === Boot loader (covers the screen until auth state resolves) === */
.app-skeleton{
  position:fixed;inset:0;z-index:99999;
  display:flex;align-items:center;justify-content:center;padding:24px;
  background:linear-gradient(135deg,#F1F7F3,#E9F2EC);
  transition:opacity .28s ease,visibility .28s ease;
}
.app-skeleton.is-hidden{opacity:0;visibility:hidden}
[data-theme="dark"] .app-skeleton{background:linear-gradient(135deg,#FFFFFF,#EAF6FF)}
.app-skeleton-card{display:flex;flex-direction:column;align-items:center;gap:12px;text-align:center}
.app-skeleton-logo-wrap{
  width:92px;height:92px;border-radius:28px;display:grid;place-items:center;
  background:transparent;
}
.app-skeleton-logo{width:64px;height:64px;object-fit:contain;animation:app-logo-bob 1.1s ease-in-out infinite}
.app-skeleton-progress{
  width:180px;height:8px;border-radius:999px;background:rgba(0,105,107,.16);overflow:hidden;
}
.app-skeleton-progress span{
  display:block;width:38%;height:100%;border-radius:inherit;
  background:var(--brand-grad);
  animation:app-progress 1.15s ease-in-out infinite;
}
.app-skeleton-text{font-size:.95rem;color:var(--text2);letter-spacing:.04em;font-weight:600}
@keyframes app-logo-bob{0%,100%{transform:translateY(0) scale(1)}50%{transform:translateY(-7px) scale(1.04)}}
@keyframes app-progress{0%{transform:translateX(-130%)}100%{transform:translateX(240%)}}

.boot-loader{
  position:fixed;inset:0;z-index:5000;
  display:none;align-items:center;justify-content:center;flex-direction:column;gap:14px;
  background:linear-gradient(135deg,#F1F7F3,#E9F2EC);
}
[data-theme="dark"] .boot-loader{background:linear-gradient(135deg,#FFFFFF,#EAF6FF)}
body.app-loading .boot-loader{display:flex}
body.app-loading .app-container{visibility:hidden}
body.app-loading .auth-gate{visibility:hidden}
.boot-orb{
  width:88px;height:88px;border-radius:24px;display:grid;place-items:center;color:#fff;
  background:var(--brand-grad);
  box-shadow:0 18px 40px rgba(0,89,186,.32);
}
.boot-orb .ico{width:46px;height:46px}
.boot-spinner{
  width:32px;height:32px;border-radius:50%;border:3px solid rgba(0,105,107,.18);
  border-top-color:#00696b;animation:boot-spin .9s linear infinite;
}
@keyframes boot-spin{to{transform:rotate(360deg)}}
.boot-text{font-size:.9rem;color:var(--text2);letter-spacing:.04em}

/* === Register: school request block === */
.school-request-block{
  background:var(--surface2);border:1px dashed var(--border);
  border-radius:12px;padding:12px;margin:10px 0;
}

/* === Leaderboard === */
.lb-controls{
  display:flex;align-items:center;gap:8px;margin:10px 0 4px;font-size:.86rem;color:var(--text2);
}
.lb-controls select{
  padding:6px 10px;border-radius:8px;border:1px solid var(--border);
  background:var(--surface);color:var(--text);
}
.lb-table{width:100%;border-collapse:collapse;font-size:.9rem}
.lb-table th, .lb-table td{padding:10px 8px;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle}
.lb-table th{font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;color:var(--text2)}
.lb-rank{font-weight:800;font-size:1rem;width:64px}
.lb-user{display:flex;align-items:center;gap:10px}
.lb-avatar{
  width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0;
  background:var(--brand-grad);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:.95rem;
}
.lb-avatar-fallback{display:grid;place-items:center}
.lb-name{font-weight:700;color:var(--text)}
.lb-school{font-size:.72rem;color:var(--text3)}
.lb-me{background:rgba(0,105,107,.08)}
.lb-me .lb-name{color:var(--accent)}

/* === Class community + DM (shared chat shell) === */
.chat-shell{
  display:flex;flex-direction:column;height:65vh;min-height:420px;
  border:1px solid var(--border);border-radius:14px;background:var(--surface);overflow:hidden;
}
@media(max-width:600px){.chat-shell{height:52vh;min-height:320px}}
.chat-shell-messages{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px}
.chat-shell-input{
  display:grid;grid-template-columns:1fr auto auto;gap:6px;padding:10px;
  border-top:1px solid var(--border);background:var(--surface2);
}
.chat-shell-input textarea{
  resize:none;min-height:44px;max-height:120px;padding:10px;border-radius:10px;
  border:1px solid var(--border);background:var(--surface);color:var(--text);
}

/* Class community message bubbles */
.cc-msg{display:flex;gap:8px;align-items:flex-end}
.cc-msg-me{flex-direction:row-reverse}
.cc-avatar{
  width:32px;height:32px;border-radius:50%;flex-shrink:0;object-fit:cover;
  background:var(--brand-grad);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:.85rem;
}
.cc-bubble{
  max-width:78%;background:var(--surface2);border-radius:12px;padding:8px 12px;
  border:1px solid var(--border);color:var(--text);
}
.cc-msg-me .cc-bubble{background:var(--brand-grad);color:#fff;border-color:transparent}
.cc-author{font-size:.74rem;color:var(--text3);margin-bottom:2px;display:flex;justify-content:space-between;gap:10px}
.cc-msg-me .cc-author{color:rgba(255,255,255,.85)}
.cc-time{opacity:.7}
.cc-text{white-space:pre-wrap;word-break:break-word;line-height:1.45}
.cc-bubble-admin{background:linear-gradient(135deg,rgba(245,197,66,.20),rgba(245,197,66,.08));border-color:#d4a017}
.cc-admin-badge{background:linear-gradient(135deg,#f5c542,#d4a017);color:#3a2c00;font-size:.62rem;font-weight:800;padding:1px 6px;border-radius:999px;letter-spacing:.02em}
.cc-pinned-bar{padding:8px 12px;margin-bottom:8px;border:1px solid #d4a017;border-radius:10px;background:linear-gradient(135deg,rgba(245,197,66,.16),rgba(245,197,66,.06));color:var(--text);font-size:.85rem;white-space:pre-wrap;word-break:break-word}
.cc-pinned-bar[hidden]{display:none}
.cc-quote{border-left:3px solid var(--accent,#6366f1);background:rgba(127,127,127,.12);border-radius:6px;padding:4px 8px;margin-bottom:4px;font-size:.78rem;opacity:.9;white-space:pre-wrap;word-break:break-word}
.cc-quote-name{font-weight:700;margin-right:6px}
.cc-actions{margin-top:4px;text-align:right}
.cc-reply-btn{background:none;border:none;color:inherit;opacity:.65;font-size:.72rem;cursor:pointer;padding:2px 4px}
.cc-reply-btn:hover{opacity:1;text-decoration:underline}
.cc-reply-bar{display:flex;align-items:center;gap:8px;padding:6px 10px;margin-top:8px;border:1px solid var(--border);border-left:3px solid var(--accent,#6366f1);border-radius:8px;background:var(--surface2);color:var(--text);font-size:.8rem}
.cc-reply-bar[hidden]{display:none}
.cc-reply-info{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cc-reply-clear{background:none;border:none;color:inherit;cursor:pointer;font-size:.85rem;padding:2px 6px}

/* === Friends === */
.fr-card{
  display:flex;align-items:center;gap:12px;padding:10px;
  border-bottom:1px solid var(--border);
}
.fr-card:last-child{border-bottom:0}
.fr-avatar{
  width:42px;height:42px;border-radius:50%;flex-shrink:0;object-fit:cover;
  background:var(--brand-grad);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:1rem;
}
.fr-info{flex:1;min-width:0}
.fr-name{font-weight:700;color:var(--text)}
.fr-meta{font-size:.74rem;color:var(--text3)}

/* === DM layout === */
.dm-layout{display:grid;grid-template-columns:240px 1fr;gap:12px;height:65vh;min-height:420px}
.dm-sidebar{
  border:1px solid var(--border);border-radius:12px;background:var(--surface);
  overflow-y:auto;padding:6px;display:flex;flex-direction:column;gap:4px;
}
.dm-friend{
  display:flex;align-items:center;gap:10px;padding:8px;border-radius:10px;
  border:0;background:transparent;color:var(--text);text-align:left;cursor:pointer;
  font-size:.88rem;
}
.dm-friend:hover{background:var(--surface2)}
.dm-friend.active{background:var(--cta-soft);color:var(--accent)}
.dm-main{display:flex;flex-direction:column;border:1px solid var(--border);border-radius:12px;background:var(--surface);overflow:hidden}
.dm-main .chat-shell-messages{flex:1}
.dm-msg{display:flex;justify-content:flex-start}
.dm-msg-me{justify-content:flex-end}
.dm-bubble{
  max-width:75%;background:var(--surface2);border:1px solid var(--border);
  border-radius:12px;padding:8px 12px;color:var(--text);
}
.dm-msg-me .dm-bubble{background:var(--brand-grad);color:#fff;border-color:transparent}
.dm-text{white-space:pre-wrap;word-break:break-word;line-height:1.45}
.dm-time{font-size:.7rem;opacity:.7;margin-top:2px;text-align:right}
.dm-img-bubble{padding:6px;background:var(--surface2)}
.dm-msg-me .dm-img-bubble{background:var(--brand-grad)}
.dm-img{
  display:block;max-width:240px;max-height:240px;border-radius:8px;cursor:zoom-in;
  object-fit:cover;
}

/* === Notification bell + panel === */
.notif-wrap{position:relative}
.notif-badge{
  position:absolute;top:-6px;right:-6px;min-width:17px;height:17px;padding:0 4px;
  border-radius:999px;background:#ef4444;color:#fff;font-size:.64rem;font-weight:700;
  align-items:center;justify-content:center;border:2px solid var(--surface);
}
.notif-badge.badge-pop{animation:badgePop .4s var(--ease-decel)}
@keyframes badgePop{
  0%{transform:scale(.4)}
  55%{transform:scale(1.35)}
  100%{transform:scale(1)}
}
#notif-bell.bell-shake{animation:bellShake .5s var(--ease-standard)}
@keyframes bellShake{
  0%,100%{transform:rotate(0)}
  20%{transform:rotate(14deg)}
  40%{transform:rotate(-12deg)}
  60%{transform:rotate(8deg)}
  80%{transform:rotate(-4deg)}
}
.notif-panel{
  position:absolute;top:calc(100% + 8px);right:0;width:min(340px,86vw);max-height:70vh;
  background:var(--surface);border:1px solid var(--border);border-radius:14px;
  box-shadow:0 12px 34px rgba(0,0,0,.18);overflow:hidden;
  display:none;z-index:9999;flex-direction:column;
}
.notif-panel.open{display:flex}
.notif-panel-head{
  padding:11px 14px;font-weight:700;font-size:.9rem;color:var(--text);
  border-bottom:1px solid var(--border);background:var(--surface2);
}
.notif-list{overflow-y:auto}
.notif-empty{padding:26px 14px;text-align:center;color:var(--text3);font-size:.84rem;display:flex;flex-direction:column;gap:8px;align-items:center}
.notif-item{
  display:flex;gap:10px;padding:11px 14px;border-bottom:1px solid var(--border);
  cursor:pointer;align-items:flex-start;transition:background .12s;
}
.notif-item:hover{background:var(--surface2)}
.notif-item.unread{background:var(--cta-soft)}
.notif-icon{flex-shrink:0;color:var(--accent);margin-top:2px}
.notif-body{flex:1;min-width:0}
.notif-title{font-weight:700;font-size:.82rem;color:var(--text)}
.notif-text{font-size:.76rem;color:var(--text2);margin-top:1px;line-height:1.4;word-break:break-word}
.notif-time{font-size:.66rem;color:var(--text3);margin-top:3px}
.notif-actions{display:flex;gap:6px;flex-shrink:0}
@media(max-width:560px){
  .notif-panel{position:fixed;top:56px;right:8px;left:8px;width:auto;max-height:64vh}
}

/* === Mention chips (share note modal) === */
.mention-chip{
  display:inline-flex;align-items:center;gap:6px;
  border:1px solid var(--border);border-radius:999px;padding:5px 11px;
  font-size:.78rem;color:var(--text);cursor:pointer;background:var(--surface2);
  user-select:none;
}
.mention-chip input{accent-color:var(--accent)}
.mention-chip:has(input:checked){
  background:var(--cta-soft);border-color:var(--accent);color:var(--accent);
}

.section-sub-title{
  grid-column:1/-1;display:flex;align-items:center;gap:6px;
  font-weight:700;font-size:.86rem;color:var(--text2);margin:6px 0 2px;
}

/* === Quiz === */
.quiz-card{
  display:flex;justify-content:space-between;align-items:center;gap:12px;
  padding:14px;border-bottom:1px solid var(--border);
}
.quiz-title{font-weight:700;color:var(--text);font-size:1rem}
.quiz-meta{font-size:.74rem;color:var(--text3);margin-top:2px}
.quiz-progress{font-size:.78rem;color:var(--text2);margin-bottom:8px}
.quiz-q{font-size:1rem;font-weight:600;color:var(--text);margin-bottom:14px}
.quiz-options{display:flex;flex-direction:column;gap:8px}
.quiz-option{
  text-align:left;padding:10px 14px;border-radius:10px;border:1px solid var(--border);
  background:var(--surface);color:var(--text);font-size:.92rem;cursor:pointer;
}
.quiz-option:hover{background:var(--surface2);border-color:var(--accent)}
.quiz-finish{text-align:center;padding:24px}
.quiz-score{font-size:1.6rem;font-weight:800;color:var(--accent);margin-bottom:10px}

/* === Shared notes === */
.shared-note-card{
  background:var(--surface);border:1px solid var(--border);border-radius:12px;
  padding:12px 14px;margin-bottom:10px;
}
.shared-note-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.shared-note-title{font-weight:700;color:var(--text)}
.shared-note-by{font-size:.74rem;color:var(--text3)}
.shared-note-blocks{margin-top:10px;display:flex;flex-direction:column;gap:8px}
.shared-block{
  background:var(--surface2);border-left:3px solid var(--accent);
  border-radius:8px;padding:8px 10px;
}
.shared-block-author{font-size:.72rem;color:var(--text3);margin-bottom:4px}
.shared-block-text{white-space:pre-wrap;color:var(--text);line-height:1.5}

/* === Mic button when listening (used by voice.js) === */
.mic-listening{
  background:linear-gradient(145deg,#ef4444,#dc2626) !important;color:#fff !important;
  animation:mic-pulse 1.4s ease-in-out infinite;
}
@keyframes mic-pulse{
  0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.5)}
  50%{box-shadow:0 0 0 8px rgba(239,68,68,0)}
}

/* === Mobile responsive === */
@media(max-width:768px){
  .dm-layout{grid-template-columns:1fr;height:auto;min-height:0}
  .dm-sidebar{max-height:140px;flex-direction:row;overflow-x:auto;flex-wrap:nowrap}
  .dm-sidebar .dm-friend{flex:0 0 auto}
  .chat-shell{height:60vh}
  .lb-table th, .lb-table td{padding:6px 4px;font-size:.82rem}
  .lb-school{display:none}
  .quiz-card{flex-direction:column;align-items:flex-start}
}

/* ===== Stylish Friends Search ===== */
.friends-search-wrap{position:relative;margin-bottom:14px}
.friends-search-wrap .search-icon{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--text2);pointer-events:none}
#friends-search-input{
  width:100%;padding:11px 16px 11px 40px;
  border:2px solid var(--border);border-radius:50px;
  background:var(--surface2);color:var(--text);font-size:.9rem;
  transition:border-color .2s,box-shadow .2s;outline:none;box-sizing:border-box;
}
#friends-search-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(0,89,186,.15);background:var(--surface)}
#friends-search-input::placeholder{color:var(--text3)}

/* ===== Task shortcut on dashboard ===== */
.dashboard-task-shortcut{
  background:var(--surface2);border:1px solid var(--border);border-radius:16px;
  padding:14px 16px;margin-top:16px;display:flex;align-items:center;gap:12px;
}
.dashboard-task-shortcut input{
  flex:1;border:1.5px solid var(--border);border-radius:10px;
  padding:9px 13px;background:var(--surface);color:var(--text);font-size:.9rem;outline:none;
}
.dashboard-task-shortcut input:focus{border-color:var(--accent)}
.dashboard-task-shortcut .task-time-input{
  width:130px;border:1.5px solid var(--border);border-radius:10px;
  padding:9px 10px;background:var(--surface);color:var(--text);font-size:.9rem;outline:none;
}
.task-reminder-badge{
  display:inline-flex;align-items:center;gap:5px;
  background:rgba(245,158,11,.15);color:var(--warn);
  border-radius:8px;padding:3px 9px;font-size:.75rem;font-weight:600;
}
.task-cat-badge{
  display:inline-flex;align-items:center;gap:4px;
  border-radius:8px;padding:2px 8px;font-size:.72rem;font-weight:600;
  white-space:nowrap;
}
.task-pri-badge{
  display:inline-flex;align-items:center;gap:4px;
  border-radius:8px;padding:2px 8px;font-size:.72rem;font-weight:600;
  white-space:nowrap;
}
.task-due-badge{
  display:inline-flex;align-items:center;gap:4px;
  border-radius:8px;padding:2px 8px;font-size:.72rem;font-weight:600;
  border:1px solid transparent;white-space:nowrap;
}
.task-proj-badge{
  display:inline-flex;align-items:center;gap:4px;
  background:rgba(99,102,241,.12);color:#818cf8;
  border-radius:8px;padding:2px 8px;font-size:.72rem;font-weight:600;
  white-space:nowrap;
}
.task-tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.task-tag{
  background:var(--surface2);color:var(--text2);border:1px solid var(--border);
  border-radius:20px;padding:2px 10px;font-size:.7rem;font-weight:500;
}
button.pri{padding:.42rem .6rem;font-size:.72rem}
.dash-task-icon{font-size:1rem;margin-right:2px}

/* ===== Offline badge auto-hide ===== */
#offline-badge{transition:opacity .5s}
#offline-badge.fade-out{opacity:0;pointer-events:none}

/* ===== Focus Mode overlay ===== */
#focus-mode-overlay{
  position:fixed;inset:0;z-index:1900;
  background:rgba(0,0,0,.92);
  display:none;flex-direction:column;align-items:center;justify-content:center;
  color:#fff;
}
#focus-mode-overlay.active{display:flex}
.focus-mode-timer{font-size:clamp(2.6rem,14vw,5rem);font-weight:800;font-family:'Plus Jakarta Sans','Noto Sans Bengali','Hind Siliguri','Nirmala UI',sans-serif;letter-spacing:2px;margin:16px 0}
.focus-mode-label{font-size:1.1rem;opacity:.7;margin-bottom:30px}
.focus-mode-actions{display:flex;gap:12px}
.focus-mode-bg{position:absolute;inset:0;background:radial-gradient(ellipse at center,rgba(0,89,186,.15) 0%,transparent 70%);pointer-events:none}

/* Revision session overlay */
.rev-session-overlay-wrap{flex-direction:column;align-items:center;justify-content:center}
.rev-session-overlay-wrap.active{display:flex!important}

.dashboard-widget-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:12px;margin-top:12px}
.dashboard-widget-grid .dashboard-task-widget{grid-column:span 5}
.dashboard-widget-grid .dashboard-leaderboard-widget{grid-column:span 4}
.dashboard-widget-grid .dashboard-prayer-widget{grid-column:span 3}
/* Class Resources widget + Offline Warrior: full-width rows, content height
   (no stretch-induced whitespace from sharing a grid row). */
.dashboard-widget-grid .dashboard-qbclass-widget{grid-column:span 12}
.dashboard-widget-grid .ow-dash-card{grid-column:span 12;min-height:0;align-self:start}
.dash-task-row,.dash-lb-row{display:flex;align-items:center;gap:10px;padding:9px;border-radius:10px;background:var(--surface2);border:1px solid var(--border)}
.task-check-btn{width:28px;height:28px;border-radius:50%;display:grid;place-items:center;background:rgba(0,89,186,.14);color:var(--accent3);border:1px solid rgba(0,89,186,.28);flex-shrink:0}
.dash-task-main{min-width:0;flex:1}
.dash-task-title{font-weight:700;color:var(--text);font-size:.86rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dash-task-meta{font-size:.72rem;color:var(--text3);display:flex;gap:4px;align-items:center;margin-top:2px}
.dash-lb-rank{font-weight:800;color:var(--accent);width:28px;text-align:center}
.dash-lb-name{font-weight:700;color:var(--text);font-size:.86rem;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-lb-time{margin-left:auto;font-weight:800;color:var(--accent3);font-size:.78rem;white-space:nowrap}

/* Dashboard widget grid — collapse to a single column on tablet & phone so
   cards never sit side-by-side, clip off-screen, or shrink below usable width. */
@media(max-width:980px){
  .dashboard-widget-grid{grid-template-columns:1fr}
  .dashboard-widget-grid > *{grid-column:1 / -1;min-width:0;max-width:100%}
  /* Mobile reading order: Today's Task → Prayer → Top Focus → Class Resources
     (XP/streak card has no order → stays first, above everything). */
  .dashboard-widget-grid .dashboard-task-widget{order:1}
  .dashboard-widget-grid .dashboard-prayer-widget{order:2}
  .dashboard-widget-grid .dashboard-leaderboard-widget{order:3}
  .dashboard-widget-grid .dashboard-qbclass-widget{order:4}
}

@media(max-width:768px){
  .dashboard-task-shortcut{display:grid;grid-template-columns:1fr auto;align-items:stretch}
  .dashboard-task-shortcut>svg{display:none}
  .dashboard-task-shortcut input{min-width:0}
  .dashboard-task-shortcut .task-time-input{width:100%}
  #quick-task-btn{grid-column:1 / -1;justify-content:center}
}
