/* ════════════════════════════════════════════════════════════════
   STUDY GROUPS — Discord + Microsoft Teams inspired academic workspace
   Scoped to .sg-* ; built entirely on brand.css tokens so dark mode
   (html[data-theme="dark"]) is automatic. Loaded after styles.css.
   ════════════════════════════════════════════════════════════════ */

.sg-view { max-width: 1240px; }

/* embedded inside the Campus Connect shell (cc-nav | [Study Groups]) :
   spans the feed + right-rail columns, keeping the cc channel nav as the
   way back to the feed. cc-feed / cc-side are x-show-hidden when active. */
.sg-embed { grid-column: 2 / 4; min-width: 0; }
.sg-embed .sg-main { min-width: 0; }
/* Collapse in lock-step with .cc-shell (which goes single-column at 1100px).
   Mismatched breakpoints left sg-embed pinned at grid-column 2/4 over a
   single-track grid in the 980–1100px range, forcing the workspace into
   min-content implicit columns and crushing the feed. */
@media (max-width: 1100px) { .sg-embed { grid-column: 1 / -1; } }

/* shared live pulse dot ----------------------------------------- */
.sg-pulse {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--emerald); box-shadow: 0 0 0 0 rgba(16, 185, 129, .55);
  animation: sgPulse 1.8s infinite; vertical-align: middle; margin-right: 5px;
}
@keyframes sgPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); }
  70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── BROWSE LAYOUT : Discord server rail + main ─────────────────── */
.sg-wrap { display: grid; grid-template-columns: 76px 1fr; gap: 18px; align-items: start; }

.sg-rail {
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 0; position: sticky; top: 16px;
}
.sg-rail-btn {
  position: relative; width: 50px; height: 50px; border: none; cursor: pointer;
  border-radius: 16px; background: var(--mist); color: var(--ink-2);
  font-size: 20px; display: flex; align-items: center; justify-content: center;
  transition: border-radius .18s, background .18s, color .18s;
}
.sg-rail-btn:hover { border-radius: 14px; background: var(--honey-glow); }
.sg-rail-btn.active { border-radius: 14px; background: var(--honey); color: var(--on-accent); }
.sg-rail-btn .sg-rail-pip {
  position: absolute; left: -12px; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--ink);
  transition: transform .18s;
}
.sg-rail-btn.active .sg-rail-pip { transform: translateY(-50%) scaleY(1); background: var(--honey-d); }
.sg-rail-btn:hover .sg-rail-pip { transform: translateY(-50%) scaleY(.6); }
.sg-rail-btn .sg-rail-tip {
  position: absolute; left: 60px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: var(--ink); color: #fff; font-size: 11px;
  font-weight: 700; padding: 5px 9px; border-radius: 7px; opacity: 0; pointer-events: none;
  transition: opacity .15s; z-index: 6; font-family: 'Inter', sans-serif;
}
.sg-rail-btn:hover .sg-rail-tip { opacity: 1; }

/* ── toolbar ────────────────────────────────────────────────────── */
.sg-main { min-width: 0; }
.sg-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.sg-tb-head h2 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 19px; color: var(--ink); }
.sg-tb-stats {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
  font-size: 12.5px; color: var(--mute); font-weight: 600;
}
.sg-tb-stats b { color: var(--ink-2); }
.sg-dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }
.sg-live-text b { color: var(--emerald-d); }

.sg-tb-actions { display: flex; align-items: center; gap: 10px; }
.sg-search {
  display: flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; height: 40px; min-width: 260px;
}
.sg-search:focus-within { border-color: var(--honey); }
.sg-search-ic { color: var(--mute); font-size: 16px; }
.sg-search input { border: none; outline: none; background: transparent; flex: 1; font-size: 13px; color: var(--ink); font-family: 'Inter', sans-serif; }
.sg-create {
  height: 40px; padding: 0 16px; border: none; border-radius: 11px; cursor: pointer;
  background: var(--honey); color: var(--on-accent); font-weight: 700; font-size: 13px;
  font-family: 'Inter', sans-serif; white-space: nowrap; transition: filter .15s;
}
.sg-create:hover { filter: brightness(1.05); }

/* ── filter chips ───────────────────────────────────────────────── */
.sg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sg-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; color: var(--body);
  font-family: 'Inter', sans-serif; transition: .15s;
}
.sg-chip:hover { border-color: var(--honey); color: var(--ink); }
.sg-chip.active { background: var(--honey-glow); border-color: var(--honey); color: var(--honey-d); }
.sg-chip-n {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  background: var(--mist); color: var(--mute); padding: 1px 6px; border-radius: 999px;
}
.sg-chip.active .sg-chip-n { background: var(--honey); color: var(--on-accent); }

/* ── GROUP CARDS ────────────────────────────────────────────────── */
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }

.sg-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column; transition: .16s;
}
.sg-card:hover { border-color: #CBD5E1; transform: translateY(-2px); box-shadow: 0 10px 26px -16px rgba(15, 23, 42, .35); }

.sg-card-cover { position: relative; height: 78px; padding: 12px 14px; display: flex; align-items: flex-start; }
.sg-card-glyph { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.sg-card-priv {
  position: absolute; top: 12px; right: 12px; font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: #fff; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35);
  padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(2px);
}
.sg-card-live {
  position: absolute; bottom: 10px; right: 12px; display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .28);
  padding: 3px 9px; border-radius: 999px;
}
.sg-card-live .sg-pulse { background: #fff; box-shadow: 0 0 0 0 rgba(255, 255, 255, .6); animation: sgPulseW 1.8s infinite; }
@keyframes sgPulseW {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); }
  70% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.sg-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.sg-card-body h3 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 15.5px; color: var(--ink); line-height: 1.25; }
.sg-card-blurb { font-size: 12.5px; color: var(--body); line-height: 1.5; }

.sg-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.sg-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 600;
  color: var(--mute); background: var(--mist); padding: 3px 8px; border-radius: 6px;
}

/* avatar (image with initials fallback behind) */
.sg-ava {
  position: relative; width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  overflow: visible; display: inline-block;
}
.sg-ava.sm { width: 30px; height: 30px; }
.sg-ava .sg-ava-fb {
  position: absolute; inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif; font-weight: 800; font-size: 11px; color: var(--on-accent);
  background: linear-gradient(135deg, var(--plum), var(--teal));
}
.sg-ava img { position: relative; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; z-index: 1; }

.sg-leader { display: flex; align-items: center; gap: 9px; padding-top: 2px; }
.sg-leader-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sg-leader-txt b { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.sg-leader-txt i { font-style: normal; font-size: 10.5px; color: var(--mute); }
.sg-crown { color: var(--honey-d); }

.sg-recent {
  display: flex; align-items: center; gap: 8px; background: var(--fog);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 11.5px;
}
.sg-recent-ico { color: var(--teal-d); font-weight: 700; }
.sg-recent-txt { flex: 1; color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-recent-txt b { color: var(--ink-2); font-weight: 700; }
.sg-recent-time { color: var(--mute); font-family: 'JetBrains Mono', monospace; font-size: 9.5px; white-space: nowrap; }

.sg-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 4px; }
.sg-members { font-size: 12px; color: var(--body); display: inline-flex; align-items: center; gap: 5px; }
.sg-members b { color: var(--ink); font-weight: 700; }
.sg-card-cta { display: flex; gap: 7px; }

.sg-open, .sg-join {
  border: 1px solid var(--line); cursor: pointer; font-family: 'Inter', sans-serif;
  font-weight: 700; font-size: 12.5px; padding: 8px 14px; border-radius: 10px; transition: .15s;
}
.sg-open { background: var(--surface); color: var(--ink-2); }
.sg-open:hover { border-color: var(--ink-3); }
.sg-join { background: var(--honey); border-color: var(--honey); color: var(--on-accent); }
.sg-join:hover { filter: brightness(1.05); }
.sg-join.joined { background: var(--emerald-glow); border-color: var(--emerald); color: var(--emerald-d); }
.sg-join.lg { padding: 10px 20px; font-size: 13px; }

.sg-empty {
  grid-column: 1 / -1; text-align: center; padding: 50px 20px; color: var(--mute);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sg-empty-ic { font-size: 34px; opacity: .6; }
.sg-empty b { color: var(--ink-2); font-size: 15px; }
.sg-empty span { font-size: 12.5px; }

/* ── WORKSPACE : Teams-style channels | feed | members ──────────── */
.sg-ws {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden; display: flex; flex-direction: column;
}
.sg-ws-top {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap;
}
.sg-back {
  border: 1px solid var(--line); background: var(--card); color: var(--body); cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 12.5px; padding: 8px 13px; border-radius: 10px; transition: .15s;
}
.sg-back:hover { border-color: var(--ink-3); color: var(--ink); }
.sg-ws-id { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.sg-ws-glyph {
  width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff; flex: 0 0 auto; box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .3);
}
.sg-ws-id h2 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 17px; color: var(--ink); line-height: 1.2; }
.sg-ws-sub { font-size: 12px; color: var(--mute); font-weight: 600; }
.sg-ws-sub b { color: var(--ink-2); }

.sg-ws-body { display: grid; grid-template-columns: 210px 1fr 232px; min-height: 540px; }

/* channels rail */
.sg-ws-channels { border-right: 1px solid var(--line); background: var(--fog); padding: 14px 10px; display: flex; flex-direction: column; gap: 3px; }
.sg-ch-head {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--mute); padding: 10px 10px 5px;
}
.sg-ch {
  display: flex; align-items: center; gap: 8px; width: 100%; border: none; cursor: pointer;
  background: transparent; color: var(--body); border-radius: 9px; padding: 8px 10px;
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600; text-align: left; transition: .12s;
}
.sg-ch:hover { background: var(--mist); color: var(--ink); }
.sg-ch.active { background: var(--honey-glow); color: var(--honey-d); }
.sg-ch-g { font-size: 13px; opacity: .7; flex: 0 0 auto; }
.sg-ch-n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-ch-u {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; min-width: 18px; text-align: center;
  background: var(--rose); color: #fff; padding: 1px 6px; border-radius: 999px;
}
.sg-ch.voice .sg-ch-g { opacity: 1; }
.sg-ch-live { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; color: var(--emerald-d); }
.sg-ch.voice.live { background: var(--emerald-glow); }

/* feed */
.sg-ws-feed { display: flex; flex-direction: column; min-width: 0; }
.sg-feed-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.sg-feed-head b { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 14px; color: var(--ink); }
.sg-feed-g { color: var(--mute); font-size: 15px; }
.sg-feed-meta { margin-left: auto; font-size: 11px; color: var(--mute); }
.sg-feed-scroll { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; max-height: 470px; }

.sg-msg { display: flex; gap: 11px; }
.sg-msg.pin { background: var(--honey-glow); margin: -6px -10px; padding: 10px; border-radius: 12px; border: 1px solid var(--honey-soft); }
.sg-msg-body { min-width: 0; flex: 1; }
.sg-msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.sg-msg-meta b { font-size: 13px; font-weight: 700; color: var(--ink); }
.sg-msg-meta span { font-size: 10.5px; color: var(--mute); font-family: 'JetBrains Mono', monospace; }
.sg-pin-badge { color: var(--honey-d) !important; font-family: 'Inter', sans-serif !important; font-weight: 700; }
.sg-msg-text { font-size: 13px; color: var(--body); line-height: 1.55; }
.sg-file {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-top: 2px;
}
.sg-file:hover { border-color: var(--teal); }
.sg-file-ic { font-size: 20px; }
.sg-file span { display: flex; flex-direction: column; line-height: 1.3; }
.sg-file b { font-size: 12.5px; color: var(--ink); }
.sg-file i { font-style: normal; font-size: 10.5px; color: var(--mute); font-family: 'JetBrains Mono', monospace; }

.sg-composer { border-top: 1px solid var(--line); padding: 12px 16px; background: var(--surface); }
.sg-composer-row { display: flex; gap: 9px; }
.sg-composer-row input {
  flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 11px; padding: 0 14px; height: 42px;
  font-size: 13px; color: var(--ink); font-family: 'Inter', sans-serif; outline: none;
}
.sg-composer-row input:focus { border-color: var(--honey); }
.sg-send { border: none; cursor: pointer; background: var(--honey); color: var(--on-accent); font-weight: 700; font-size: 13px; padding: 0 20px; border-radius: 11px; font-family: 'Inter', sans-serif; }
.sg-send:hover { filter: brightness(1.05); }
.sg-locked { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--mute); }

/* members roster */
.sg-ws-members { border-left: 1px solid var(--line); background: var(--fog); padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 600px; }
.sg-mem-head {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--emerald-d); padding: 8px 8px 5px; display: flex; align-items: center;
}
.sg-mem-head.off { color: var(--mute); margin-top: 8px; }
.sg-mem { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; transition: .12s; }
.sg-mem:hover { background: var(--mist); }
.sg-mem .sg-ava { overflow: visible; }
.sg-mem-dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--fog); background: var(--mute); z-index: 2;
}
.sg-ava.st-online .sg-mem-dot { background: var(--emerald); }
.sg-ava.st-room .sg-mem-dot { background: var(--plum); }
.sg-ava.st-idle .sg-mem-dot { background: var(--honey); }
.sg-mem-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sg-mem-txt b { font-size: 12.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-mem-txt i { font-style: normal; font-size: 10px; color: var(--mute); }
.sg-mem-leader { margin-top: auto; padding: 10px 8px 4px; font-size: 11.5px; color: var(--body); border-top: 1px solid var(--line); }
.sg-mem-leader b { color: var(--ink-2); }

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .sg-ws-body { grid-template-columns: 1fr; }
  .sg-ws-channels { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  .sg-ws-members { border-left: none; border-top: 1px solid var(--line); max-height: none; }
  .sg-ch-head { width: 100%; }
}
@media (max-width: 680px) {
  .sg-wrap { grid-template-columns: 1fr; }
  .sg-rail { flex-direction: row; flex-wrap: wrap; justify-content: center; position: static; }
  .sg-rail-btn .sg-rail-pip, .sg-rail-btn .sg-rail-tip { display: none; }
}
