/* ═══════════════════════════════════════════
   PU-Connect Dashboard
   ═══════════════════════════════════════════ */

/* ── Theme toggle icon swap ── */
#dashThemeBtn .theme-sun  { display: none; }
#dashThemeBtn .theme-moon { display: block; }
[data-theme="dark"] #dashThemeBtn .theme-sun  { display: block; }
[data-theme="dark"] #dashThemeBtn .theme-moon { display: none; }

/* ── Tab bar ── */
.dash-tabs {
  display: flex;
  gap: .2rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .2rem;
  width: 100%;
  margin-bottom: .75rem;
}
.dash-tab {
  flex: 1;
  padding: .45rem .75rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  transition: all .18s var(--ease-out);
  white-space: nowrap;
  text-align: center;
}
.dash-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.dash-tab:hover:not(.active) { color: var(--text); }

/* ── Notification button ── */
.notif-btn { position: relative; }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ── Guest banner ── */
.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
}
.gb-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
  margin-bottom: .2rem;
}
.gb-sub { font-size: .8rem; color: var(--text-2); line-height: 1.5; }

/* ── Search bar ── */
.dash-search {
  position: relative;
  margin-bottom: .9rem;
}
.ds-icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  pointer-events: none;
}
.ds-input {
  padding-left: 2.4rem !important;
  padding-right: 2.4rem !important;
}
.ds-clear {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  transition: background .15s;
}
.ds-clear:hover { background: var(--border); color: var(--text); }

/* ── Search autocomplete dropdown ── */
.ds-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  z-index: 300;
  overflow: hidden;
  max-height: min(70vh, calc(100dvh - var(--nav-h) - var(--bot-h) - 2rem));
  overflow-y: auto;
}
.ds-drop-section {
  padding: .35rem .5rem .2rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.ds-drop-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .9rem;
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  color: var(--text);
}
.ds-drop-item:hover, .ds-drop-item:focus { background: var(--surface-2); outline: none; }
.ds-drop-av {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.ds-drop-av img { width: 100%; height: 100%; object-fit: cover; }
.ds-drop-thumb {
  width: 36px; height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.ds-drop-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ds-drop-info { flex: 1; min-width: 0; }
.ds-drop-name {
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.ds-drop-sub {
  font-size: .75rem;
  color: var(--text-2);
  margin-top: .05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-drop-empty {
  padding: 1rem;
  text-align: center;
  font-size: .85rem;
  color: var(--text-2);
}
.ds-drop-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: .2rem 0;
}

/* ── Category pills ── */
.cat-pills {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding-bottom: .2rem;
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  padding: .38rem .85rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  transition: all .18s var(--ease-out);
  white-space: nowrap;
}
.cat-pill:hover { border-color: var(--accent); color: var(--accent); }
.cat-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Section head ── */
.dash-section { margin-bottom: 2rem; }
.section-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .9rem;
}
.section-title { font-size: 1rem; font-weight: 700; }
.section-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  padding: .2rem .5rem;
  border-radius: var(--radius-full);
}

/* ── Boost promo banner ── */
.boost-promo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), color-mix(in srgb, var(--accent) 6%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer;
  transition: opacity .15s;
  margin-bottom: .25rem;
}
.boost-promo-banner:hover { opacity: .88; }
.bpb-left {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--accent);
  min-width: 0;
}
.bpb-left svg { flex-shrink: 0; }
.bpb-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}
.bpb-sub {
  font-size: .72rem;
  color: var(--text-2);
  margin-top: .1rem;
}
.bpb-cta {
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 700;
  padding: .35rem .8rem;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #1a1400;
  white-space: nowrap;
}

/* ── Featured carousel ── */
.carousel-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}
.carousel { overflow: hidden; border-radius: var(--radius); }
.carousel-track {
  display: flex;
  transition: transform .4s var(--ease-out);
}
.fc-slide {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 16/7;
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
}
.fc-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 60%);
  display: flex;
  align-items: flex-end;
  padding: 1.1rem;
  border-radius: var(--radius);
}
.fc-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .25rem;
  line-height: 1.3;
}
.fc-price {
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.carousel-btn:hover { background: var(--surface); }
.carousel-btn.prev { left: .6rem; }
.carousel-btn.next { right: .6rem; }
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: .7rem;
}
.c-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-2);
  transition: all .2s;
}
.c-dot.active { background: var(--accent); width: 18px; border-radius: 3px; }

/* ── Listings grid ── */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 45%), 1fr));
  gap: clamp(.5rem, 2vw, .85rem);
}

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s var(--ease-out), box-shadow .2s;
}
.listing-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.lc-img {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--surface-2);
}
.lc-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.listing-card:hover .lc-img img { transform: scale(1.04); }
.lc-img-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lc-body { padding: .7rem .8rem .85rem; }
.lc-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: var(--radius-full);
  margin-bottom: .4rem;
}
.lc-badge.product { background: var(--accent-dim); color: var(--accent); }
.lc-badge.service { background: var(--warn-dim);   color: var(--warn); }
.lc-title {
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: .3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lc-price {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .2rem;
}
.lc-seller { font-size: .72rem; }

/* ── Skeleton loader ── */
.listings-loader {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 45%), 1fr));
  gap: clamp(.5rem, 2vw, .85rem);
}
.listing-skel { padding: .85rem; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }

/* ── Empty state ── */
.empty-state {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-2);
  text-align: center;
  font-size: .9rem;
  gap: .5rem;
}

/* ── Detail drawer ── */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.drawer.open { pointer-events: all; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s;
}
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer-sheet {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.25rem 1.25rem 2rem;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .35s var(--ease-out);
  border-top: 1px solid var(--border);
}
.drawer.open .drawer-sheet { transform: translateY(0); }
.drawer-handle {
  width: 36px; height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

/* ── Post modal ── */
.post-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}
.post-modal.open { pointer-events: all; }
.pm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .25s;
}
.post-modal.open .pm-backdrop { opacity: 1; }
.pm-sheet {
  position: relative;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.5rem 1.25rem 2rem;
  transform: translateY(100%);
  transition: transform .3s var(--ease-out);
}
.post-modal.open .pm-sheet { transform: translateY(0); }
.pm-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .25rem; }
.pm-sub   { font-size: .82rem; color: var(--text-2); margin-bottom: 1.1rem; }
.pm-options { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.pm-option {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .9rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.pm-option:hover { border-color: var(--accent); background: var(--accent-dim); }
.pm-opt-icon { font-size: 1.3rem; }
.pm-opt-label { flex: 1; }

/* ── Responsive ── */
@media (min-width: 640px) {
  .listings-grid { grid-template-columns: repeat(auto-fill, minmax(min(200px, 45%), 1fr)); }
  .listings-loader { grid-template-columns: repeat(auto-fill, minmax(min(200px, 45%), 1fr)); }
  .fc-slide { aspect-ratio: 16/6; }
}

@media (min-width: 1200px) {
  .listings-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .listings-loader { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 600px) {
  .dash-tabs { overflow-x: auto; scrollbar-width: none; }
  .dash-tabs::-webkit-scrollbar { display: none; }
  .dash-tab { flex-shrink: 0; padding: .42rem .6rem; font-size: .78rem; }
  .fc-slide { aspect-ratio: 16/9; }
  .fc-title { font-size: .88rem; }
  .drawer-sheet { padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom)); }
  .pm-sheet { padding: 1.2rem 1rem 1.5rem; }
}

@media (max-width: 480px) {
  .boost-promo-banner { flex-wrap: wrap; gap: .6rem; }
  .bpb-left { flex: 1 1 100%; }
  .bpb-cta { align-self: flex-start; }
  .bpb-sub { white-space: normal; }
  .guest-banner { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .listings-grid { grid-template-columns: repeat(2, 1fr); gap: clamp(.4rem, 2vw, .6rem); }
  .listings-loader { grid-template-columns: repeat(2, 1fr); gap: clamp(.4rem, 2vw, .6rem); }
  .lc-body { padding: .55rem .65rem .7rem; }
  .lc-title { font-size: .8rem; }
  .lc-price { font-size: .83rem; }
  .section-title { font-size: .92rem; }
  .cat-pill { padding: .32rem .7rem; font-size: .74rem; }
}

@media (max-width: 380px) {
  .listings-grid, .listings-loader { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .dash-tab { font-size: .74rem; padding: .38rem .5rem; }
  /* Ensure cards are never too narrow: below 320px collapse to 1 col */
}

@media (max-width: 320px) {
  .listings-grid, .listings-loader { grid-template-columns: 1fr; }
}
