/* ======================================================
   SIDEBAR LAYOUT & COMPONENTS
   Extracted from explore-feed.css so sidebars can be
   reused safely. Adds sticky behavior to avoid covering
   the footer.
   ====================================================== */

/* Design tokens used by sidebar UI */
:root {
  --bg: hsl(210 20% 98%);
  --fg: hsl(220 26% 10%);
  --card: hsl(0 0% 100%);
  --card-fg: hsl(220 26% 10%);
  --primary: hsl(174 84% 32%);
  --primary-fg: hsl(0 0% 100%);
  --secondary: hsl(213 94% 60%);
  --secondary-fg: hsl(0 0% 100%);
  --muted: hsl(210 20% 95%);
  --muted-fg: hsl(215 16% 47%);
  --accent: hsl(38 92% 50%);
  --accent-fg: hsl(0 0% 100%);
  --destructive: hsl(0 84% 60%);
  --border: hsl(214 20% 90%);
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --font-display: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --transition: 200ms ease;
}

/* Sidebar layout for pages that use the page-with-sidebars wrapper (profile, notifications, etc.) */
.page-with-sidebars {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

@media (min-width: 1280px) {
  .page-with-sidebars {
    max-width: 1440px;
    padding: 0 20px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    grid-template-areas: "left main right";
    gap: 0 24px;
    align-items: start;
  }
  .page-with-sidebars .sidebar-main-content {
    grid-area: main;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
    min-height: unset;
  }
}

@media (min-width: 1440px) {
  .page-with-sidebars {
    grid-template-columns: 280px 1fr 300px;
  }
}

.sidebar-main-content { min-width: 0; }

/* Sidebar containers */
.sidebar {
  position: sticky;
  top: 64px;
  align-self: flex-start;
  flex-shrink: 0;
  overflow: visible;
  /* padding: 20px 0; */
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Align sidebars with the first card on feed/explore (uses .app-layout) */
.app-layout .sidebar {
  top: 24px;
}

/* Explicit left/right sizing so explore/feed and profile share widths */
.sidebar--left { width: 280px; padding-right: 16px; }
.sidebar--right { width: 260px; padding-left: 16px; }

/* For page-with-sidebars layouts, sidebars are grid columns */
.page-with-sidebars .sidebar-left,
.page-with-sidebars .sidebar-right {
  display: none;
}

@media (min-width: 1280px) {
  .page-with-sidebars .sidebar-left,
  .page-with-sidebars .sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 76px;
    align-self: start;
    padding: 16px 0;
    z-index: 40;
  }
  .page-with-sidebars .sidebar-left {
    grid-area: left;
    width: 100%;
  }
  .page-with-sidebars .sidebar-right {
    grid-area: right;
    width: 100%;
  }
}

@media (min-width: 1440px) {
  .page-with-sidebars .sidebar-left { width: 100%; }
  .page-with-sidebars .sidebar-right { width: 100%; }
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h3 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  font-size: 12px;
  color: var(--secondary);
  font-weight: 500;
  transition: opacity var(--transition);
}

.link-btn:hover { opacity: 0.7; text-decoration: underline; }

.icon-sm { width: 16px; height: 16px; flex-shrink: 0; }
.icon-md { width: 20px; height: 20px; flex-shrink: 0; }

/* Notifications */
.notif-list { display: flex; flex-direction: column; gap: 4px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm, 6px);
  transition: background 0.15s;
}
.notif-item:hover { background: var(--muted); }
.notif-item--unread { background: hsl(var(--primary-hsl, 173 80% 36%) / 0.07); }
.notif-item--unread:hover { background: hsl(var(--primary-hsl, 173 80% 36%) / 0.12); }

.notif-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-fg);
  flex-shrink: 0;
}

.notif-text { font-size: 12px; }
.notif-text strong { font-weight: 600; }
.notif-time { font-size: 11px; color: var(--muted-fg); }

/* Promoted */
.promoted-item {
  cursor: pointer;
  margin-bottom: 16px;
}

.promoted-item:last-child { margin-bottom: 0; }

.promoted-img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: transform 300ms;
}

.promoted-item:hover .promoted-img { transform: scale(1.03); }

.promoted-img-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}

.promoted-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--secondary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.promoted-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  transition: color var(--transition);
}

.promoted-item:hover .promoted-title { color: var(--primary); }

.promoted-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-fg);
  margin-top: 4px;
}

.promoted-meta svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Stories */
.stories-row {
  padding: 5px;
  display: flex;
  gap: 12px;
  overflow-x: scroll;
  scrollbar-width: none;
}

.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.story-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  ring: 2px;
  outline: 2px solid transparent;
  outline-offset: 3px;
  transition: transform var(--transition);
}

.story-avatar.has-new { outline-color: var(--accent); }
.story-avatar:not(.has-new) { outline-color: var(--border); }
.story-item:hover .story-avatar { transform: scale(1.1); }

.story-name {
  font-size: 10px;
  color: var(--muted-fg);
  width: 48px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Messages */
.message-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.message-item:hover { background: var(--muted); }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.message-info { flex: 1; min-width: 0; }
.message-name { font-size: 12px; font-weight: 600; }
.message-preview { font-size: 11px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.message-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
  flex-shrink: 0;
}

/* Recommended actions */
.sidebar-action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-action-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.sidebar-action-item:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow-md);
}

.sidebar-action-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 4px;
}

.sidebar-action-meta {
  font-size: 12px;
  color: var(--muted-fg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sidebar-action-meta .badge { text-transform: none; }

/* ── Mobile stories bar ──────────────────────────────────── */
.stories-bar {
  display: none; /* visible only on mobile via media query below */
  gap: 14px;
  overflow-x: auto;
  padding: 12px 16px 8px;
  scrollbar-width: none;
  background: var(--card-bg, #fff);
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: var(--card-shadow, 0 1px 4px rgba(0,0,0,.06));
}

.stories-bar::-webkit-scrollbar { display: none; }

.stories-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.stories-bar__avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  overflow: hidden;
  outline: 2.5px solid var(--border, #e5e7eb);
  outline-offset: 2px;
  transition: transform .15s ease;
}

.stories-bar__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.stories-bar__avatar--new {
  outline-color: var(--accent, #f59e0b);
}

.stories-bar__avatar--add {
  background: var(--primary, #570df8);
  font-size: 1.1rem;
  outline-color: var(--border, #e5e7eb);
}

.stories-bar__item:hover .stories-bar__avatar {
  transform: scale(1.08);
}

.stories-bar__name {
  font-size: .7rem;
  color: var(--muted-fg, #6b7280);
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Responsive: hide sidebars on narrower viewports */
@media (max-width: 1280px) {
  .sidebar--right { display: none; }
  .stories-bar { display: flex; }
}

@media (max-width: 1024px) {
  .sidebar--left { display: none; }
}
