/* ============================================================
   DESKTOP LAYOUT — ≥1024px
   Transforms bottom-nav into left sidebar.
   All rules use !important to override bottom-nav-fix.css.
   ============================================================ */

/* Hide desktop-only items on all screen sizes by default */
.nav-item-desktop { display: none !important; }
#navAdminBtn { display: none !important; }

@media (min-width: 1024px) {
  #navAdminBtn.admin-visible { display: flex !important; }
}

@media (min-width: 1024px) {

  /* ---- Sidebar: reposition bottom-nav ---- */
  .bottom-nav {
    position: fixed !important;
    left: 0 !important;
    right: auto !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 220px !important;
    height: 100vh !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    border-top: none !important;
    border-right: 1px solid rgba(46, 204, 113, 0.2) !important;
    border-radius: 0 !important;
    padding-bottom: 0 !important;
    padding-top: 0 !important;
    transform: none !important;
    max-width: none !important;
    margin: 0 !important;
    background: rgba(8, 8, 8, 0.98) !important;
  }

  /* Logo area injected via ::before */
  .bottom-nav::before {
    content: 'COHABIT';
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 900;
    color: #2ECC71;
    letter-spacing: 4px;
    padding: 28px 20px 20px;
    border-bottom: 1px solid rgba(46, 204, 113, 0.12);
    margin-bottom: 8px;
    flex-shrink: 0;
  }

  /* ---- Nav items: vertical ---- */
  .nav-item {
    flex: 0 0 auto !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 14px 20px !important;
    min-height: auto !important;
    border-radius: 0 !important;
    text-align: left !important;
    width: 100% !important;
  }

  /* Inject label from aria-label attribute (no .label span in HTML) */
  .nav-item::after {
    content: attr(aria-label);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem !important;
    font-weight: 600;
    letter-spacing: 1.5px !important;
    text-transform: uppercase;
    opacity: 0.85;
  }

  .nav-item .label {
    font-size: 0.75rem !important;
    letter-spacing: 1.5px !important;
    opacity: 1 !important;
  }

  /* Reserve border-left on ALL items so active border never shifts content */
  .nav-item {
    border-left: 3px solid transparent !important;
  }

  .nav-item.active {
    border-left: 3px solid #2ECC71 !important;
    background: rgba(46, 204, 113, 0.08) !important;
    color: #2ECC71 !important;
  }

  /* Hide mobile top-bar indicator (::before from style-nav-fix.css) */
  .nav-item.active::before {
    display: none !important;
  }

  /* ::after = label text on desktop. Reset ALL mobile positioning so it
     stays inline in the flex row and never moves. */
  .nav-item::after,
  .nav-item.active::after {
    content: attr(aria-label) !important;
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    background: transparent !important;
    border-radius: 0 !important;
    display: inline !important;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem !important;
    font-weight: 600;
    letter-spacing: 1.5px !important;
    text-transform: uppercase;
    opacity: 0.85;
    animation: none !important;
  }

  .nav-item.active::after {
    opacity: 1;
  }

  /* Desktop-only nav items: hidden on mobile */
  .nav-item-desktop {
    display: none !important;
  }

  /* Add habit button pinned to bottom of sidebar.
     order:99 moves it after Groups+Profile (which come after it in HTML source).
     Reset mobile circle styles, render as sidebar row item. */
  .nav-add-btn {
    order: 99 !important;
    margin-top: auto !important;
    margin-bottom: 0 !important;
    border-top: 1px solid rgba(46, 204, 113, 0.15) !important;
    border-radius: 0 !important;
    padding: 16px 20px !important;
    width: 100% !important;
    height: auto !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    background: rgba(46, 204, 113, 0.04) !important;
    position: relative !important;
    z-index: auto !important;
  }

  /* Icon: small rounded square instead of big circle */
  .nav-add-btn .nav-add-icon {
    width: 28px !important;
    height: 28px !important;
    border-radius: 6px !important;
    background: rgba(46, 204, 113, 0.18) !important;
    box-shadow: none !important;
    flex-shrink: 0 !important;
  }

  .nav-add-btn .nav-add-icon svg {
    width: 16px !important;
    height: 16px !important;
  }

  /* Label injected via ::after from aria-label (translated via applyTranslations) */
  .nav-add-btn::after {
    content: attr(aria-label);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #2ECC71;
  }

  .nav-add-btn:hover {
    background: rgba(46, 204, 113, 0.1) !important;
  }

  /* Show desktop-only nav items (Settings, Share) */
  .nav-item-desktop {
    display: flex !important;
  }

  /* "Manage Habits" label — use aria-label like all other nav items */
  .nav-item-manage::after,
  .nav-item-manage.active::after {
    content: attr(aria-label) !important;
  }

  /* ---- Pages: offset by sidebar width ---- */
  .page {
    left: 220px !important;
    right: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding-bottom: 24px !important;
  }

  /* Override responsive.css 700px max-width on page IDs */
  #page-today,
  #page-stats,
  #page-motivation,
  #page-profile,
  #page-groups,
  #page-admin {
    max-width: none !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Remove bottom-nav reserved space */
  body,
  .page-content,
  main {
    padding-bottom: 0 !important;
  }

  /* Hide sidebar on auth / onboarding pages */
  body.no-bottom-nav .bottom-nav {
    display: none !important;
  }

  body.no-bottom-nav .page {
    left: 0 !important;
  }

  /* Auth page — stay centered, no sidebar offset */
  #page-auth {
    left: 0 !important;
    right: 0 !important;
  }
}

/* ============================================================
   PAGE HABITS — ≥1024px full-width single column
   Date, score, habits all span full content width.
   ============================================================ */

@media (min-width: 1024px) {
  #page-today {
    padding: 0 32px 24px !important;
    max-width: 860px !important;
    margin: 0 auto !important;
  }
}

/* ============================================================
   PAGE STATS — ≥1024px two-column
   ============================================================ */

@media (min-width: 1024px) {
  #page-stats {
    padding: 24px 32px !important;
  }

  #page-stats .stats-top-row {
    gap: 20px;
  }

  #page-stats .chart-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  #page-stats .chart-wrapper {
    margin: 0;
  }

  #page-stats .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ============================================================
   PAGE GROUPS — ≥1024px
   List centred. Detail opens as centred modal overlay.
   ============================================================ */

@media (min-width: 1024px) {
  #page-groups {
    display: flex !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  #page-groups .groups-container {
    padding: 24px 32px;
    max-width: 620px;
    width: 100%;
  }

  /* display:flex !important always-on: intentional.
     Visibility controlled by opacity (not display).
     JS closes via classList.remove("active") — does not set display:none. */
  #groupDetailModal {
    position: fixed !important;
    left: 220px !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    background: rgba(0, 0, 0, 0.75) !important;
    align-items: center !important;
    justify-content: center !important;
    transform: none !important;
    transition: opacity 0.2s ease !important;
    opacity: 0 !important;
    pointer-events: none !important;
    display: flex !important;
  }

  #groupDetailModal.active {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  #groupDetailModal .modal {
    width: 90% !important;
    max-width: 680px !important;
    height: auto !important;
    max-height: 85vh !important;
    border-radius: 20px !important;
    overflow-y: auto !important;
    border-left: none !important;
  }
}

/* ============================================================
   PAGE PROFILE — ≥1024px
   ============================================================ */

@media (min-width: 1024px) {
  #page-profile {
    padding: 32px !important;
  }

  #page-profile #profileStatsGrid,
  #page-profile .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  #page-profile .fun-stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ============================================================
   PAGE SETTINGS — ≥1024px two-column card grid
   ============================================================ */

@media (min-width: 1024px) {
  #page-motivation {
    padding: 32px !important;
  }

  #page-motivation .settings-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    max-width: 960px;
    margin: 0 auto;
  }

  #page-motivation .settings-category {
    border-radius: 16px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(46, 204, 113, 0.1);
    overflow: hidden;
    height: fit-content;
  }

  #page-motivation .settings-category-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(46, 204, 113, 0.04);
  }

  #page-motivation .settings-category:last-child {
    grid-column: 1 / -1;
  }
}
