/* =========================================================
   App shell — matches the real JaraFund navigation model:
   a fixed glass sidebar on desktop (Discover, Search, Wallet,
   Messages, Profile, Settings, then a Create Campaign button),
   collapsing to a bottom tab bar on mobile.
========================================================= */

.app-layout{ min-height: 100vh; }

.app-sidebar{
  display: none;
}

@media (min-width: 861px){
  .app-sidebar{
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    width: 232px;
    padding: 10px;
    z-index: 40;
    transition: width .28s cubic-bezier(.4,0,.2,1);
  }
  .app-sidebar-inner{
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 20px;
    padding: 14px 10px;
    background: color-mix(in srgb, var(--card) 75%, transparent);
    backdrop-filter: blur(16px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .app-main{ margin-left: 252px; transition: margin-left .28s cubic-bezier(.4,0,.2,1); }

  /* Collapsed state — icon rail only, logo becomes the expand button */
  .app-sidebar.collapsed{ width: 76px; }
  body:has(.app-sidebar.collapsed) .app-main,
  body.sidebar-collapsed .app-main{ margin-left: 96px; }
  .app-sidebar.collapsed .sidebar-brand{ cursor: pointer; justify-content: center; padding: 10px 0 16px; }
  .app-sidebar.collapsed .sidebar-brand span,
  .app-sidebar.collapsed .sidebar-link span,
  .app-sidebar.collapsed .sidebar-create span,
  .app-sidebar.collapsed .sidebar-foot,
  .app-sidebar.collapsed .sidebar-guest .btn-outline{
    display: none;
  }
  .app-sidebar.collapsed .sidebar-link{ justify-content: center; padding: 11px; }
  .app-sidebar.collapsed .sidebar-link .nav-dot{ position: absolute; top: 6px; right: 6px; margin-left: 0; }
  .app-sidebar.collapsed .sidebar-create{ padding: 11px; }
  .app-sidebar.collapsed .sidebar-nav{ align-items: center; }

  .sidebar-collapse-btn{
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink-soft);
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    transition: transform .2s ease;
  }
  .sidebar-collapse-btn:hover{ color: var(--ink); }
  .app-sidebar.collapsed .sidebar-collapse-btn{ display: none; }
}

.sidebar-brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 16px;
}
.sidebar-brand img{ width: 34px; height: 34px; border-radius: 9px; }
.sidebar-brand span{ font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }

.sidebar-nav{ flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 0 2px; }

.sidebar-link{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  position: relative;
}
.sidebar-link svg{ flex-shrink: 0; }
.sidebar-link:hover{ background: var(--paper-alt); color: var(--ink); }
.sidebar-link.active{ background: var(--green-tint); color: var(--green-deep); }
[data-theme="dark"] .sidebar-link.active{ color: var(--green); }
.sidebar-link .nav-dot{
  width: 7px; height: 7px; border-radius: 50%; background: #D97757; margin-left: auto;
}

.sidebar-create{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 2px 6px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--green) 60%, transparent);
}
.sidebar-create:hover{ background: var(--green-deep); }

.sidebar-foot{ padding: 8px 12px 2px; font-size: 11px; color: var(--ink-soft); }

/* Guest state — logged-out visitors browsing the feed */
.sidebar-guest{
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 2px;
}

/* ---------- Mobile top bar (compact, shown instead of sidebar) ---------- */
.mobile-topbar{
  display: none;
  position: sticky; top: 0; z-index: 50;
  align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mobile-topbar .brand-word{ font-family: var(--font-display); font-weight: 700; font-size: 17px; }

@media (max-width: 860px){
  .mobile-topbar{ display: flex; }
  .app-main{ margin-left: 0; }
}

/* ---------- Mobile bottom tab bar ---------- */
.bottom-nav{
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 60;
}
.bottom-nav-inner{ display: grid; grid-template-columns: repeat(5, 1fr); }
.bottom-nav-item{
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px;
  font-size: 10px; font-weight: 600;
  color: var(--ink-soft);
  position: relative;
}
.bottom-nav-item.active{ color: var(--green-deep); }
[data-theme="dark"] .bottom-nav-item.active{ color: var(--green); }
.bottom-nav-item .nav-dot{
  position: absolute; top: 2px; right: calc(50% - 15px);
  width: 6px; height: 6px; border-radius: 50%; background: #D97757;
}

@media (max-width: 860px){
  .bottom-nav{ display: block; }
  .app-shell{ padding-bottom: 76px; }
}

.avatar-circle{
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green-deep);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  overflow: hidden; flex-shrink: 0;
}
[data-theme="dark"] .avatar-circle{ color: var(--green); }
.avatar-circle img{ width: 100%; height: 100%; object-fit: cover; }

/* =========================================================
   Feed — matches the real "Discover Campaigns" page
========================================================= */
.feed-header{
  padding: 20px 20px 0;
}
.feed-header h1{ font-size: 19px; font-weight: 700; margin: 0; }
.feed-tagline{ font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 0; }

.feed-search{
  position: relative;
  margin-top: 14px;
}
.feed-search svg{
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft);
}
.feed-search input{
  width: 100%;
  height: 38px;
  padding: 0 14px 0 36px;
  border-radius: 10px;
  border: none;
  background: var(--paper-alt);
  color: var(--ink);
  font-size: 13.5px;
}
.feed-search input:focus-visible{ outline: 2px solid var(--green); }

.category-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  overflow-x: auto;
}
.category-row::-webkit-scrollbar{ display: none; }
.category-chip{
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--paper-alt);
  color: var(--ink-soft);
  flex-shrink: 0;
}
.category-chip.active{ background: var(--green); color: #fff; }

.feed-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 4px 20px 40px;
}

.feed-card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.feed-card:hover{ box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--green) 25%, var(--line)); }

.feed-card-image{
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--paper-alt);
  overflow: hidden;
}
.feed-card-image img{ width: 100%; height: 100%; object-fit: cover; }
.feed-card-image::after{
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.25), transparent 50%);
}
.feed-badge-category{
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 5px 10px;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  color: var(--ink);
  backdrop-filter: blur(4px);
}
.feed-badge-boosted{
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
}

.feed-card-body{ padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.feed-card-title{
  font-size: 14px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-card-author{ display: flex; align-items: center; gap: 8px; }
.feed-card-author .mini-avatar{
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
}
[data-theme="dark"] .feed-card-author .mini-avatar{ color: var(--green); }
.feed-card-author .owner-name{ font-size: 11.5px; color: var(--ink-soft); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-card-author .days-left{ font-size: 10px; color: var(--ink-soft); display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

.feed-progress-row{ display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 2px; }
.feed-raised{ font-size: 16px; font-weight: 700; }
.feed-goal{ font-size: 11.5px; color: var(--ink-soft); margin-left: 4px; }
.feed-percent{ font-size: 12px; font-weight: 700; color: var(--green-deep); }
[data-theme="dark"] .feed-percent{ color: var(--green); }
.feed-progress-track{ height: 6px; border-radius: 999px; background: var(--paper-alt); overflow: hidden; }
.feed-progress-fill{ height: 100%; background: var(--green); border-radius: 999px; transition: width .5s ease; }

.feed-card-footer{
  display: flex; align-items: center; gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft);
}
.feed-card-footer button{ background: none; border: none; padding: 0; display: flex; align-items: center; gap: 5px; color: inherit; cursor: pointer; font-size: 12px; }
.feed-card-footer button:hover{ color: var(--ink); }
.feed-like-btn.liked{ color: #E0526B; }
.feed-like-btn svg{ transition: transform .15s ease; }
.feed-like-btn.liked svg{ fill: #E0526B; transform: scale(1.1); }

/* ---------- Messages page ---------- */
.messages-layout{
  display: grid;
  grid-template-columns: 300px 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100vh - 120px);
  background: var(--card);
  margin: 20px;
}
.convo-list{ border-right: 1px solid var(--line); overflow-y: auto; }
.convo-item{ display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.convo-item:hover, .convo-item.active{ background: var(--paper-alt); }
.convo-name{ font-weight: 600; font-size: 14px; }
.convo-preview{ font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }

.thread-pane{ display: flex; flex-direction: column; height: 100%; }
.thread-head{ display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.thread-body{ flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble{ max-width: 70%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.4; }
.msg-bubble.mine{ align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.msg-bubble.theirs{ align-self: flex-start; background: var(--paper-alt); border-bottom-left-radius: 4px; }
.thread-input{ display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.thread-input input{ flex: 1; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-family: var(--font-body); }

@media (max-width: 720px){
  .messages-layout{ grid-template-columns: 1fr; height: calc(100vh - 160px); margin: 12px; }
  .convo-list{ display: none; }
  .messages-layout.list-mode .convo-list{ display: block; }
  .messages-layout.list-mode .thread-pane{ display: none; }
}

/* ---------- Profile page ---------- */
.profile-header{ display: flex; gap: 24px; align-items: center; margin-bottom: 28px; flex-wrap: wrap; padding: 20px; }
.profile-avatar{
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
[data-theme="dark"] .profile-avatar{ color: var(--green); }
.profile-avatar img{ width: 100%; height: 100%; object-fit: cover; }
.profile-name{ font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-meta{ display: flex; gap: 18px; font-size: 13px; color: var(--ink-soft); margin-top: 8px; flex-wrap: wrap; }
.profile-meta strong{ color: var(--ink); }
.profile-bio{ color: var(--ink-soft); font-size: 14px; max-width: 60ch; margin-top: 8px; }

.campaign-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; padding: 0 20px 20px; }
.mini-card{ background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.mini-card h4{ font-size: 14px; margin: 0 0 10px; }
.mini-progress{ height: 6px; border-radius: 999px; background: var(--paper-alt); overflow: hidden; margin-bottom: 8px; }
.mini-progress-fill{ height: 100%; background: var(--green); }
.mini-card .mini-stats{ font-size: 12px; color: var(--ink-soft); }

/* ---------- Loading skeletons (feed cards) ---------- */
/* feed.js renders these while the first page of a search/category is
   loading — matches .feed-card's real proportions so the layout doesn't
   jump once real cards swap in. */
.feed-skeleton-row{
  display: contents;
}
.feed-skeleton-card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  height: 320px;
  display: flex;
  flex-direction: column;
}
.feed-skeleton-card::before{
  content: "";
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--paper-alt);
}
.feed-skeleton-card::after{
  content: "";
  flex: 1;
  margin: 14px;
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    var(--paper-alt) 25%,
    color-mix(in srgb, var(--paper-alt) 60%, var(--line)) 37%,
    var(--paper-alt) 63%
  );
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
}
@keyframes skeletonShimmer{
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce){
  .feed-skeleton-card::after{ animation: none; }
}

/* ---------- Card entrance (real cards, once loaded) ---------- */
.feed-card{
  animation: feedCardIn .3s ease both;
}
@keyframes feedCardIn{
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce){
  .feed-card{ animation: none; }
}

/* ---------- Small consistency fix: mini-card progress bars now animate
   like the main feed's do, instead of jumping instantly ---------- */
.mini-progress-fill{ transition: width .5s ease; }

/* ---------- Tasteful press feedback on primary actions ---------- */
.btn:active{ transform: scale(.97); }
.reaction-btn:active{ transform: scale(.94); }
