/* ============================================================
   nu associates — Site PMC
   Desktop / Laptop layout
   Breakpoint: 1024px and above
   Additive — phone layout (base) stays unchanged below 1024px.
   Strategy: re-style existing markup (topbar, tabs-bar, content)
   into a sidebar + topbar + content layout without HTML changes.
   ============================================================ */

@media (min-width: 1024px) {

  body {
    font-size: var(--text-base);
    background: #F2F4F7;
  }

  /* ── FONT SCALE — desktop tokens larger than mobile defaults ── */
  :root {
    --text-xs:   0.75rem;    /* 12px  — was 11px */
    --text-sm:   0.875rem;   /* 14px  — was 13px */
    --text-base: 1rem;       /* 16px  — was 14px */
    --text-md:   1.0625rem;  /* 17px  — was 16px */
    --text-lg:   1.25rem;    /* 20px  — was 18px */
    --text-xl:   1.5rem;     /* 24px  — was 22px */
  }

  /* App container becomes a CSS grid: sidebar | topbar+content */
  #app-container, #app.is-visible, body > div.app, .app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
    background: #F2F4F7;
  }

  /* Topbar stays at the top of the right column */
  .topbar, #topbar, header.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    border-bottom: 1px solid #E2E6EC;
    background: #FFFFFF !important;
    color: #1A2332 !important;
    padding: 10px 28px !important;
    min-height: 56px;
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .topbar *, #topbar * { color: inherit; }
  .topbar .tb-brand, .topbar .tb-ctx { color: #1A2332 !important; }
  .topbar .tb-ctx { color: var(--steel) !important; }
  /* On desktop topbar, brand-name is dark and sub is softer */
  .topbar .tb-brand-name { color: #1A2332 !important; }
  .topbar .tb-brand-sub  { color: #657B90 !important; }
  .tb-right {
    background: rgba(29, 61, 98, 0.05) !important;
    border-color: rgba(29, 61, 98, 0.08) !important;
  }
  .tb-role {
    background-color: transparent !important;
    border: none !important;
    color: #1A2332 !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%231A2332' stroke-width='1.6'><path d='M1 1l5 5 5-5'/></svg>") !important;
  }
  .tb-role.is-impersonating {
    background-color: #B07D1A !important;
    color: #FFFFFF !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='white' stroke-width='1.6'><path d='M1 1l5 5 5-5'/></svg>") !important;
  }
  .tb-notif {
    background: transparent !important;
    color: #1A2332 !important;
  }
  .tb-notif:hover {
    background: rgba(0, 0, 0, 0.05) !important;
  }
  .tb-logout {
    color: var(--text2) !important;
    border: none !important;
    border-radius: 50% !important;
    background: transparent !important;
  }
  .tb-logout:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    color: var(--navy) !important;
  }

  /* Tabs bar repositioned as vertical sidebar on the left */
  .tabs, #tabs-bar {
    position: fixed;
    left: 0;
    top: 130px;
    bottom: 0;
    width: 240px;
    background: #1D3D62;
    padding: 10px 14px 24px;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: normal !important;
    border-right: 1px solid #16304f;
    z-index: 50;
    /* Fade bottom edge to signal "more sections scrollable below".
       Override the mobile horizontal fade applied in app.css. */
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent 100%) !important;
            mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent 100%) !important;
  }

  /* Sidebar brand header */
  .bottom-nav::before, #bottom-nav::before {
    content: "nu associates";
    position: absolute;
    top: 22px;
    left: 20px;
    right: 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.3px;
  }
  .bottom-nav::after, #bottom-nav::after {
    content: "SITE PMC";
    position: absolute;
    top: 48px;
    left: 20px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    font-weight: 400;
    color: rgba(255,255,255,.50);
    letter-spacing: 3px;
  }

  /* Individual nav items restyled */
  .tabs .tab, #tabs-bar .tab {
    padding: 10px 14px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    width: 100% !important;
    flex: 0 0 auto !important;
    box-sizing: border-box !important;
    border-radius: 6px !important;
    color: rgba(255,255,255,.72) !important;
    font-size: var(--text-sm) !important;
    font-weight: 500 !important;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none !important;
    background: transparent !important;
    transition: background 0.15s, color 0.15s;
  }
  .tabs .tab:hover, #tabs-bar .tab:hover {
    background: rgba(255,255,255,.08) !important;
    color: #FFFFFF !important;
  }
  .tabs .tab.active, #tabs-bar .tab.active {
    background: rgba(255,255,255,.14) !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
  }

  /* ── BUCKET SWITCHER inside the sidebar.
     On mobile this is a fixed bottom bar; on desktop we relocate it into the
     sidebar header so the IA stays identical: pick a bucket → see its sections.
     Same labels, same icons, same active state — just oriented vertically. */
  .bottom-nav, #bottom-nav {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    height: 130px !important;
    bottom: auto !important;
    right: auto !important;
    width: 240px !important;
    background: #1D3D62 !important;
    border-top: none !important;
    border-bottom: 1px solid #16304f !important;
    padding: 72px 6px 10px !important;
    z-index: 51;                   /* above .tabs (50) so chips are clickable */
    display: flex !important;
    flex-direction: row !important;
    gap: 2px !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
  }
  .bottom-nav .bb-item, #bottom-nav .bb-item {
    flex: 1 1 0px !important;
    min-height: 44px !important;    /* touch target — iPad / hybrid laptops */
    padding: 6px 1px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: rgba(255,255,255,.55) !important;
    border-radius: 6px;
    transition: background .15s, color .15s;
  }
  .bottom-nav .bb-item.active, #bottom-nav .bb-item.active {
    background: rgba(255,255,255,.14);
    color: #FFFFFF !important;
  }
  .bottom-nav .bb-item:hover:not(.active),
  #bottom-nav .bb-item:hover:not(.active) {
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.85) !important;
  }
  .bottom-nav .bb-icon svg, #bottom-nav .bb-icon svg {
    stroke: currentColor !important;
    fill: none !important;
    width: 16px !important; height: 16px !important;
  }
  .bottom-nav .bb-label, #bottom-nav .bb-label,
  .bottom-nav .bb-item.active .bb-label, #bottom-nav .bb-item.active .bb-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.01em !important;
    margin-top: 2px;
  }
  .bottom-nav .bb-icon-rupee, #bottom-nav .bb-icon-rupee {
    font-size: 17px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    position: relative !important;
    top: 2px !important;
    color: currentColor;
  }

  /* Tabs sit below the bucket switcher — push them down by switcher height.
     Switcher row: top:64px + 44px min-height + 18px padding = 126px end → 132px clear. */
  .tabs, #tabs-bar {
    padding-top: 14px !important;
  }

  /* Content wrapper shifts to account for sidebar */
  .content, #content-area {
    grid-column: 2;
    max-width: none !important;
    padding: 16px 32px 48px !important;
  }

  /* Content inner max-width for readability on very wide screens */
  #content-area { min-height: calc(100vh - 56px); }
  #content-area > * { max-width: 1400px; margin-left: 0; margin-right: 0; }

  /* Topbar also shifts */
  .topbar, #topbar, header.topbar { grid-column: 2; }

  /* Hide sync-banner styling adjustments for desktop */
  .sync-banner { grid-column: 2; }

  /* work-pinned must shift right of sidebar, same as .content */
  .work-pinned { grid-column: 2; padding: 12px 32px 0 !important; }

  /* ── PENDING ACTIONS — HORIZONTAL STRIP ON DESKTOP ──────────────────────
     Switch from mobile stacked chips to a single horizontal row.
     Title left, chips inline to the right, wraps gracefully on narrow widths.
     ── */
  .pa-strip-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .pa-strip-chips {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .pa-chip {
    width: auto !important;
    min-height: 32px !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    justify-content: center;
    gap: 6px;
  }
  .pa-chip-label { font-size: var(--text-sm); }

  /* ── SECTION HEADER ROW — show inline button on desktop ──────────────── */
  .sec-hdr-btn   { display: inline-flex !important; }
  .sec-action-mobile { display: none !important; }

  /* Footer out of the way on desktop */
  .footer { display: none !important; }

  /* ── TYPOGRAPHY ───────────────────────────────────────── */
  h1, .h1 { font-size: var(--text-xl); }
  h2, .h2 { font-size: var(--text-lg); }
  .sec-label {
    font-size: var(--text-xs);
    letter-spacing: 1.8px;
    color: #657B90;
    text-transform: uppercase;
    font-weight: 600;
    margin: 20px 0 12px;
  }

  /* ── DASHBOARD — MULTI-COLUMN ─────────────────────────── */
  .dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
  }
  .dash-grid .full { grid-column: 1 / -1; }

  @media (min-width: 1440px) {
    .dash-grid { grid-template-columns: 1fr 1fr 1fr; }
    .dash-grid .full { grid-column: 1 / -1; }
    .dash-grid .wide { grid-column: span 2; }
  }

  /* ── PROJECT CARDS IN 2-COL GRID ──────────────────────── */
  .projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
  }

  /* ── CARDS ────────────────────────────────────────────── */
  .card, .project-card, .action-item, .approval-card,
  .task-card, .drawing-row {
    background: #FFFFFF;
    border: 1px solid #E2E6EC;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(29,61,98,.04);
  }

  /* ── FORMS — WIDER FIELDS ─────────────────────────────── */
  .field-row input, .field-row select, .field-row textarea,
  .form-row input, .form-row select, .form-row textarea {
    font-size: var(--text-base);
    padding: 10px 12px;
  }
  .form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 900px;
  }
  .form-grid-2 .field-full { grid-column: 1 / -1; }

  /* ── MODAL — CENTRED DIALOG, NOT BOTTOM SHEET ─────────── */
  .modal-overlay {
    align-items: center !important;
    justify-content: center !important;
  }
  .modal, #modal-body {
    max-width: 640px !important;
    width: 90% !important;
    max-height: 85vh;
    overflow-y: auto;
    display: block !important;
    border-radius: var(--r2) !important;
    animation: fadeIn .2s ease !important;
  }

  /* ── BUTTONS ──────────────────────────────────────────── */
  .btn-primary, .btn-secondary, .btn-ghost {
    padding: 10px 20px;
    min-height: 44px;
    font-size: var(--text-base);
    width: auto;
    min-width: 120px;
  }
  .btn-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 16px;
  }

  /* ── PHOTO GRID — LARGER TILES ON DESKTOP ─────────────── */
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
    gap: 12px !important;
  }
  .photo-thumb { aspect-ratio: 4 / 3; }

  /* ── AI SUGGESTION PANELS ─────────────────────────────── */
  .ai-panel {
    background: linear-gradient(135deg, #F8FAFC 0%, #EBF0F7 100%);
    border: 1px solid #D6DFEA;
    border-radius: 10px;
    padding: 14px 16px;
    margin: 12px 0;
  }
  .ai-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #1D3D62;
    margin-bottom: 8px;
  }
  .ai-panel-head::before {
    content: "✦";
    color: #B07D1A;
    font-size: var(--text-base);
  }
  .ai-panel-body { font-size: var(--text-sm); line-height: 1.5; color: #1A2332; }
  .ai-panel-actions { display: flex; gap: 8px; margin-top: 12px; }

  /* ── 3-WAY SIGN-OFF CARD ──────────────────────────────── */
  .signoff-chain {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
  }
  .signoff-slot {
    background: #FFFFFF;
    border: 1px solid #E2E6EC;
    border-left: 3px solid #CDD3DC;
    border-radius: 8px;
    padding: 14px;
  }
  .signoff-slot.signed  { border-left-color: #2A7A4B; }
  .signoff-slot.pending { border-left-color: #B07D1A; }
  .signoff-slot .label {
    font-size: 10px;
    letter-spacing: 1.5px;
    font-weight: 600;
    color: #657B90;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .signoff-slot .who { font-size: var(--text-base); font-weight: 600; color: #1A2332; }
  .signoff-slot .status { font-size: 12px; color: #657B90; margin-top: 4px; }
  .signoff-slot.signed .status { color: #2A7A4B; font-weight: 500; }

  /* ── DELEGATION BANNER ────────────────────────────────── */
  .delegation-banner {
    background: linear-gradient(90deg, #B07D1A 0%, #8b6415 100%);
    color: #FFFFFF;
    padding: 8px 20px 8px 260px;
    font-size: 12px;
    text-align: center;
    position: sticky;
    top: 56px;
    z-index: 55;
  }

  /* ── SCROLLBARS ───────────────────────────────────────── */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: #F2F4F7; }
  ::-webkit-scrollbar-thumb { background: #CDD3DC; border-radius: 5px; }
  ::-webkit-scrollbar-thumb:hover { background: #93A3B4; }
}

/* XL desktop tweaks */
@media (min-width: 1440px) {
  #app-container, #app.is-visible, body > div.app, .app-shell {
    grid-template-columns: 260px minmax(0, 1fr) !important;
  }
  .tabs, #tabs-bar { width: 260px !important; }
  .bottom-nav, #bottom-nav { width: 260px !important; }
  #content-area > * { max-width: 1600px; margin-left: 0; margin-right: 0; }
}



/* ── DESKTOP DARK MODE OVERRIDES ── */
@media (min-width: 1024px) {
  html[data-theme="dark"] body {
    background: #0F1419 !important;
  }
  html[data-theme="dark"] #app.is-visible {
    background: #0F1419 !important;
  }
  html[data-theme="dark"] .topbar,
  html[data-theme="dark"] #topbar,
  html[data-theme="dark"] header.topbar {
    background: #0D1B2A !important;
    border-bottom-color: #2A3A4A !important;
  }
  html[data-theme="dark"] .topbar *,
  html[data-theme="dark"] #topbar * { color: #E8ECF0; }
  html[data-theme="dark"] .topbar .tb-brand-name { color: #E8ECF0 !important; }
  html[data-theme="dark"] .topbar .tb-brand-sub  { color: #8899AA !important; }
  html[data-theme="dark"] .topbar .tb-ctx { color: #8899AA !important; }
  html[data-theme="dark"] .tb-right {
    background: rgba(255,255,255,.06) !important;
    border-color: rgba(255,255,255,.12) !important;
  }
  html[data-theme="dark"] .tb-role {
    color: #E8ECF0 !important;
    background-color: rgba(255,255,255,.08) !important;
    border: 1px solid rgba(255,255,255,.15) !important;
    background-image: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    padding-right: 10px !important;
  }
  html[data-theme="dark"] .tb-role.is-impersonating {
    background-color: rgba(176,125,26,.55) !important;
    color: #FFFFFF !important;
  }
  html[data-theme="dark"] .tb-notif {
    color: #E8ECF0 !important;
  }
  html[data-theme="dark"] .tb-notif:hover {
    background: rgba(255,255,255,.1) !important;
  }
  html[data-theme="dark"] .tb-logout {
    color: #B0C4D8 !important;
  }

  /* Sidebar */
  html[data-theme="dark"] .tabs,
  html[data-theme="dark"] #tabs-bar {
    background: #0D1B2A !important;
    border-right-color: #1A2332 !important;
  }
  html[data-theme="dark"] .bottom-nav,
  html[data-theme="dark"] #bottom-nav {
    background: #0D1B2A !important;
    border-bottom-color: #1A2332 !important;
  }

  /* Content area */
  html[data-theme="dark"] .content {
    background: #0F1419;
  }
  html[data-theme="dark"] .content .card,
  html[data-theme="dark"] .content .stat-card,
  html[data-theme="dark"] .content .proj-card,
  html[data-theme="dark"] .content .action-item,
  html[data-theme="dark"] .content .report-card,
  html[data-theme="dark"] .content .pa-strip,
  html[data-theme="dark"] .content .wp-card,
  html[data-theme="dark"] .content [style*="background:var(--white)"],
  html[data-theme="dark"] .content [style*="background:#fff"],
  html[data-theme="dark"] .content [style*="background: var(--white)"],
  html[data-theme="dark"] .content [style*="background:white"] {
    background: #1A2332 !important;
    border-color: #2A3A4A !important;
    color: #E8ECF0 !important;
  }
  html[data-theme="dark"] .content .btn-sm {
    background: #0F1419 !important;
    border-color: #3A4A5A !important;
    color: #B0C4D8 !important;
  }
  html[data-theme="dark"] .content .btn-primary {
    background: #1D3D62 !important;
    color: #fff !important;
  }
}

/* ── DARK MODE — weekly sign-off slots ── */
html[data-theme="dark"] .signoff-slot {
  background: #1A2332 !important;
  border-color: #2A3A4A !important;
}
html[data-theme="dark"] .signoff-slot .label { color: #8899AA !important; }
html[data-theme="dark"] .signoff-slot .who { color: #E8ECF0 !important; }
html[data-theme="dark"] .signoff-slot .status { color: #8899AA !important; }
html[data-theme="dark"] .signoff-slot.signed .status { color: #4ADE80 !important; }

/* ── DARK MODE — input sections and text areas in weekly signoff ── */
html[data-theme="dark"] #content-area .section-block,
html[data-theme="dark"] #content-area [style*="background:#FFFFFF"],
html[data-theme="dark"] #content-area [style*="background: #FFFFFF"],
html[data-theme="dark"] #content-area [style*="background:white"],
html[data-theme="dark"] #content-area [style*="border:1px solid #E"] {
  background: #1A2332 !important;
  border-color: #2A3A4A !important;
  color: #E8ECF0 !important;
}
