/**
 * MD Link / Connect — UX cleanup (mobile-first)
 * Подключать после connect.css
 */

/* ---- Guest zone: less vertical noise ---- */
.cn-guest-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 0.55rem 0.85rem;
}

.cn-guest-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cn-viral-card {
  border-radius: 16px;
  padding: 0.9rem 1rem !important;
}

.cn-viral-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.cn-viral-title {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Progress thin */
.cn-viral-card .progress,
.cn-goal-progress {
  height: 6px !important;
  border-radius: 999px;
  overflow: hidden;
}

/* Share buttons row — horizontal scroll on small screens */
.cn-share-row,
.cn-viral-card .cn-share-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.cn-share-row::-webkit-scrollbar,
.cn-viral-card .cn-share-actions::-webkit-scrollbar {
  display: none;
}

.cn-share-btn,
.cn-invite-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 40px;
}

/* Collapsed advanced blocks */
.cn-advanced-details,
.cn-card-preview-details {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.55);
  padding: 0.35rem 0.85rem;
}

.cn-advanced-summary,
.cn-card-preview-summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
  padding: 0.55rem 0;
  user-select: none;
}
.cn-advanced-summary::-webkit-details-marker,
.cn-card-preview-summary::-webkit-details-marker {
  display: none;
}
.cn-advanced-summary::before,
.cn-card-preview-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  opacity: 0.7;
}
.cn-advanced-details[open] > .cn-advanced-summary::before,
.cn-card-preview-details[open] > .cn-card-preview-summary::before {
  transform: rotate(90deg);
}

.cn-card-preview-wrap {
  max-width: 280px;
  margin: 0.5rem auto 0.75rem;
}
.cn-card-preview-wrap canvas {
  width: 100% !important;
  height: auto !important;
  border-radius: 12px;
  display: block;
}

/* Soft sheets / toasts */
.cn-soft-share {
  z-index: 80;
}

/* ---- App shell ---- */
.connect-app {
  --cn-ux-radius: 16px;
}

.connect-app > .container-fluid {
  max-width: 1180px;
  margin-inline: auto;
}

/* Feed first on mobile: already col-lg-6; tighten gaps */
.connect-app .row.g-4 {
  --bs-gutter-y: 0.85rem;
}

/* Profile / invite cards less bulky */
.cn-profile-card {
  text-align: center;
  padding: 1rem !important;
}
.cn-invite-card {
  padding: 0.85rem 1rem !important;
}

/* Posts denser */
.cn-post {
  margin-bottom: 0.65rem !important;
}

/* Right sidebar widgets: cap height */
.cn-widget-scroll {
  max-height: 280px;
  overflow-y: auto;
}

/* Mobile bottom nav already exists as .cn-mobile-nav — ensure visible */
@media (max-width: 991.98px) {
  .cn-mobile-nav {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    gap: 0;
    justify-content: space-around;
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 23, 42, 0.94);
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    backdrop-filter: blur(12px);
  }
  .cn-mobile-nav a,
  .cn-mobile-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    font-size: 0.68rem;
    color: #94a3b8;
    text-decoration: none;
    background: none;
    border: 0;
  }
  .cn-mobile-nav a.active,
  .cn-mobile-nav a:hover {
    color: #38bdf8;
  }

  /* Guest content above feed: tighter */
  .container.mt-3.mb-3 {
    margin-top: 0.65rem !important;
    margin-bottom: 0.5rem !important;
  }

  .cn-team-welcome {
    margin-bottom: 0.65rem !important;
  }

  /* Hide secondary stats line on very small screens if empty-looking */
  .cn-invite-stats {
    font-size: 0.8rem;
    opacity: 0.85;
  }

  /* Search form full width */
  #cnGlobalSearchForm .form-control {
    font-size: 16px; /* prevent iOS zoom */
  }
}

@media (max-width: 575.98px) {
  .cn-viral-card {
    padding: 0.75rem !important;
  }
  .cn-status-row {
    flex-wrap: wrap;
  }
  .cn-guest-hint {
    display: none !important;
  }
  /* One primary CTA row */
  .cn-team-welcome-actions {
    flex-direction: column;
    align-items: stretch !important;
  }
  .cn-team-welcome-cta {
    width: 100%;
    text-align: center;
  }
}

/* Desktop: keep sidebars, but don't overpower feed */
@media (min-width: 992px) {
  .cn-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 2px;
  }
  .cn-sidebar::-webkit-scrollbar {
    width: 4px;
  }
  .cn-sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 4px;
  }
}

/* Reduce "card inside card" feel for MD panel when expanded */
#mdLinkDashboard .card {
  background: transparent !important;
  box-shadow: none !important;
}
#mdLinkDashboard .card-body {
  padding-left: 0;
  padding-right: 0;
}

/* Hardcoded Russian soft-share — keep readable */
.cn-soft-share-card {
  max-width: 360px;
}


/* Light theme parity for UX layer */
.connect-app[data-theme="light"] .cn-guest-bar {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.1);
}
.connect-app[data-theme="light"] .cn-mobile-nav {
  background: rgba(255, 255, 255, 0.96) !important;
  border-top: 1px solid rgba(15, 23, 42, 0.1) !important;
}
.connect-app[data-theme="light"] .cn-mobile-nav a,
.connect-app[data-theme="light"] .cn-mobile-nav button {
  color: #64748b !important;
}
.connect-app[data-theme="light"] .cn-mobile-nav a.active {
  color: #2563eb !important;
}
/* Reduce vertical clutter on mobile */
@media (max-width: 991.98px) {
  .md-link-panel .card {
    margin-bottom: 0.65rem !important;
  }
  .md-link-panel .card-body {
    padding: 0.85rem !important;
  }
}


/* ---- Guest v6: one progress + one Invite CTA ---- */
.cn-invite-primary-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.35rem;
}
.cn-invite-primary {
  flex: 1 1 auto;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cn-invite-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}
.cn-invite-secondary {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: #e2e8f0;
  cursor: pointer;
}
.connect-app[data-theme="light"] .cn-invite-secondary {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}
.cn-goal-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Mobile nav theme button */
.cn-mobile-nav .cn-mobile-theme,
.cn-mobile-nav button.cn-mobile-theme {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  font-size: 0.68rem;
  color: #94a3b8;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.cn-mobile-nav .cn-mobile-theme i {
  font-size: 1.05rem;
}
.connect-app[data-theme="light"] .cn-mobile-nav .cn-mobile-theme {
  color: #64748b;
}
