/* ═══════════════════════════════════════════════════════════
   MAKEMEHAPPY.TODAY — Production Sidebar CSS v2.0
   • Sidebar collapse/minimize (Claude-style)
   • Extra spacing fixes
   • Performance optimizations
═══════════════════════════════════════════════════════════ */

:root {
  --sidebar-collapsed-w: 52px;
  --sb-transition: 0.22s cubic-bezier(.4,0,.2,1);
}

/* ─────────────────────────────────────
   SIDEBAR COLLAPSE TOGGLE BUTTON
───────────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: calc(var(--topbar-h, 52px) + 10px);
  left: calc(var(--sidebar-w, 200px) - 13px);
  z-index: 210;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--border, #E8E0FF);
  box-shadow: 0 2px 8px rgba(167,139,250,.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: left var(--sb-transition), background .2s, box-shadow .2s, transform .2s;
  color: var(--muted, #888);
  line-height: 1;
  padding: 0;
  outline: none;
  font-family: Arial, sans-serif;
  font-weight: 900;
}

.sidebar-toggle::after {
  content: "‹";
  font-size: 1.15rem;
  font-weight: 900;
  transition: transform var(--sb-transition);
  display: block;
  margin-top: -1px;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: var(--soft, #F7F0FF);
  box-shadow: 0 4px 14px rgba(167,139,250,.3);
  color: var(--lav, #A78BFA);
}

/* ─────────────────────────────────────
   SIDEBAR BASE TRANSITIONS
───────────────────────────────────── */
.sidebar {
  transition: width var(--sb-transition), min-width var(--sb-transition);
  will-change: width;
  overflow: hidden;
}

/* ─────────────────────────────────────
   COLLAPSED STATE
───────────────────────────────────── */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w) !important;
  min-width: var(--sidebar-collapsed-w) !important;
}

body.sidebar-collapsed .sidebar-toggle {
  left: calc(var(--sidebar-collapsed-w) - 13px);
}

body.sidebar-collapsed .sidebar-toggle::after {
  transform: rotate(180deg);
}

/* Hide text labels */
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .sidebar-footer .sf-brand,
body.sidebar-collapsed .sidebar-footer .sf-gst {
  display: none !important;
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* Center icons */
body.sidebar-collapsed .nav-item {
  justify-content: center !important;
  padding: 8px 0 !important;
  margin: 2px 4px !important;
  position: relative;
}

body.sidebar-collapsed .nav-icon {
  width: auto !important;
  font-size: 1.2rem !important;
  flex-shrink: 0;
}

/* Tooltips in collapsed mode */
body.sidebar-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed-w) + 4px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(30,30,40,.92);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
  font-family: 'Quicksand', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}

body.sidebar-collapsed .nav-item:hover::after {
  opacity: 1;
}

/* Footer in collapsed */
body.sidebar-collapsed .sidebar-footer {
  padding: 8px 4px !important;
  text-align: center;
  min-height: 40px;
}

/* ─────────────────────────────────────
   SECTION SPACING FIXES
───────────────────────────────────── */

/* Fix extra top whitespace in page sections */
main > section {
  margin-top: 0;
}

/* Compact nav-group-labels */
.nav-group-label {
  padding: 10px 14px 4px !important;
}

/* Fix section headings spacing */
.section-title {
  margin-bottom: 2px !important;
}

.section-sub {
  margin-bottom: 12px !important;
}

/* ─────────────────────────────────────
   PERFORMANCE FIXES
───────────────────────────────────── */

/* Use GPU acceleration for animated elements */
.hc, .feat-card, .nav-item, .sidebar-toggle {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Toast animation via opacity+transform in index.html inline CSS.
   Do not add visibility here — it breaks the slide-in animation. */

/* Prevent layout thrash on cards */
.feat-card, .feed-card, .news-card, .deal-card {
  contain: layout style;
}

/* Lazy image placeholder */
img[loading="lazy"] {
  background: var(--soft, #F7F0FF);
}

/* ─────────────────────────────────────
   GROUPS PAGE — LAYOUT FIXES
───────────────────────────────────── */
.groups-layout {
  gap: 0 !important;
  height: calc(100vh - var(--topbar-h, 52px) - 260px) !important;
  min-height: 400px;
}

.group-sidebar {
  border-right: 1.5px solid var(--border, #E8E0FF);
  overflow-y: auto;
  height: 100%;
}

.group-chat {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
}

/* ─────────────────────────────────────
   CONTENT AREA — REMOVE TOP SPACE
───────────────────────────────────── */
.content > main {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* hero-bg-circles hidden by default to fix whitespace */
.hero-bg-circles {
  display: none !important;
}

/* Fix main hero content spacing */
.hero-content {
  min-height: unset !important;
  padding: 0 !important;
}

/* ─────────────────────────────────────
   MOBILE RESPONSIVE
───────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: none !important;
  }
  body.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
}

/* ─────────────────────────────────────
   DARK THEME SIDEBAR
───────────────────────────────────── */
.theme-dark .sidebar-toggle {
  background: #1a1a2e;
  border-color: #3a3a5c;
  color: #aaa;
}
.theme-dark .sidebar-toggle:hover {
  background: #252540;
  color: var(--lav, #A78BFA);
}
.theme-dark body.sidebar-collapsed .nav-item::after {
  background: rgba(20,20,35,.96);
}

/* ─────────────────────────────────────
   SECTION ACTIVE ANIMATION (optimized)
───────────────────────────────────── */
.section.active > * {
  animation: secFadeIn .2s ease both;
}
@keyframes secFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
