/*
 * web-overrides.css — the ONLY web-specific styling on top of the desktop UI.
 * Loaded after the desktop's own styles.css (which is copied byte-for-byte).
 *
 * Everything here HIDES a piece of desktop chrome whose backend does not exist
 * in a browser yet. Nothing is removed from the DOM and no desktop rule is
 * changed: delete a rule below to bring that control back (the matching
 * window.omicsAPI method in shim/omicsapi.js must then be implemented).
 */

/* Until sign-in state is known, show nothing (avoids a flash of the app). */
html.web-auth-pending body { visibility: hidden; }

/* ── Electron window chrome ─────────────────────────────────────────────── */
#titlebar { display: none; }                 /* File/Edit/View/Help strip + native window controls */
#app { height: 100vh; height: 100dvh; }      /* the 38px title bar is gone, so use the whole viewport —
                                                 100dvh (with a 100vh fallback for older browsers) tracks
                                                 the REAL visible area on mobile, where the browser's own
                                                 address-bar chrome shrinks/grows the viewport dynamically;
                                                 plain 100vh left the bottom of the layout (the chat input
                                                 box) clipped under overflow:hidden whenever that chrome
                                                 was showing (reported 2026-09-23, real device screenshot). */
/* (the drag-resize handles between sidebar | chat | notebook are live: the desktop code stores the widths in localStorage,
   which works in a browser. #resize-right stays hidden by the desktop stylesheet itself.) */

/* ── Desktop-only chrome ─────────────────────────────────────────────────── */
#sidebar-update-card { display: none !important; }             /* desktop auto-updater */
/* (file attach, voice in/out, the web panel, billing, support and profile editing are all live in the
   browser now — the shim routes them through the web backend.) */

/* ── Web-panel layout fix (manuscript/report/Galaxy preview never showed) ──
 * Root-caused live via DOM inspection (2026-09-22): on the web app the Lab
 * Notebook column defaults to hidden, so `.lab-split` carries BOTH
 * `.notebook-hidden` and `.web-open` at once whenever a manuscript preview
 * (or any web_open) auto-opens the panel. renderer/styles.css's own
 * `.lab-split.notebook-hidden .chat-column` rule — written for the simpler
 * "no notebook, nothing else open" case — unconditionally expands chat to
 * `flex:1 1 auto` full width, which crushes `.web-column` (flex:1 1 0) down
 * to ~0px (confirmed: rendered at 0.67px, positioned off past the right
 * edge of the viewport). Restore chat's normal capped share whenever both
 * classes are present together, so the web-column actually gets space.
 * (Cannot fix this in the shared styles.css — it's copied verbatim from
 * the desktop by scripts/sync-web-desktop-ui.js — so it's overridden here.) */
.lab-split.notebook-hidden.web-open .chat-column {
  flex: 0 0 42%;
  max-width: 600px;
  width: auto;
}
.lab-split.notebook-hidden.web-open .chat-messages {
  padding-left: 18px;
  padding-right: 18px;
}
.lab-split.notebook-hidden.web-open .input-area {
  margin-left: 0;
  margin-right: 0;
}

/* Second, independent bug found in the same investigation: the desktop
 * stylesheet sizes the panel's page area with an element-TYPE selector,
 * `.web-view-wrap webview { width:100%; height:100%; ... }`, matching the
 * literal `<webview>` tag Electron provides. The web shim (omicsapi.js)
 * replaces that element with a plain `<iframe id="web-view">` — a
 * different tag name the desktop rule can never match — so the iframe was
 * rendering at the browser's unstyled default size (~300x150) regardless
 * of how correctly its parent panel was sized. Give it explicit sizing
 * directly by id. */
#web-view { width: 100%; height: 100%; border: none; background: #fff; display: block; }

/* ── "Document mode" (manuscript/report canvas vs. an embedded browser) ───
 * The web panel is used for two genuinely different things: browsing a real
 * external site Omi opens for you (Galaxy, NCBI, a paper's DOI — a real URL
 * you might navigate around) and showing a document Omi itself generated
 * (a manuscript/report — nothing to browse, reload, or go back/forward in).
 * The shim (omicsapi.js) tags the panel `.doc-mode` the moment it renders one
 * of our own documents (a `web-doc:` id, handled via srcdoc — no URL at all)
 * and clears it the moment a real http(s)/blob page loads, so the toolbar
 * below always matches what's actually showing: a Claude/ChatGPT-style
 * document canvas for our own output, a normal browser toolbar for anything
 * Omi is showing you on the open web. */
#web-panel.doc-mode #web-back,
#web-panel.doc-mode #web-forward,
#web-panel.doc-mode #web-reload,
#web-panel.doc-mode #web-url { display: none; }

/* With back/forward/reload/url-bar hidden, .web-url (the toolbar's only
 * flex:1 child) is gone too — nothing left to push the remaining icons
 * (zoom, open-external, the new download button, maximize, close)
 * rightward, so with no override they cluster at the left with empty
 * space trailing. Right-align them instead, matching the top-right icon
 * cluster every real document viewer (Google Docs, Word Online, a PDF
 * reader) uses. */
#web-panel.doc-mode .web-toolbar { justify-content: flex-end; }

/* The download button only means anything for one of Omi's OWN documents
 * (a web-doc: id, srcdoc-rendered — see the .doc-mode comment above) —
 * there's nothing for it to save when the panel is showing a real
 * external page (Galaxy, NCBI, a paper's DOI), and desktop doesn't offer
 * a download button there either. Injected globally by the shim
 * (omicsapi.js) since it has no other way to reach into index.html; kept
 * hidden here outside document mode instead of only toggled in JS, so it
 * can never flash visible for a frame during a mode transition. */
#web-panel:not(.doc-mode) #web-download-btn { display: none; }

/* ── Cloud-access paywall popup + the reminder strip above the chat input ──
 * (shim/omicsapi.js showCloudAccessPaywall). Theme tokens only, so it follows
 * light/dark like the rest of the app. */
.plans-modal.cloud-paywall {
  max-width: 520px;
  padding: 40px 36px 32px;
  text-align: center;
}
.cloud-pw-icon {
  width: 52px; height: 52px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--accent-light);
  background: color-mix(in srgb, var(--accent-light) 14%, transparent);
}
.cloud-pw-title { margin: 0 0 10px; font-size: 22px; font-weight: 700; color: var(--text); }
.cloud-pw-body { margin: 0 auto 26px; max-width: 400px; font-size: 15px; line-height: 1.55; color: var(--text-muted); }
.cloud-pw-actions { display: flex; gap: 12px; }
.cloud-pw-btn {
  flex: 1 1 0; min-height: 44px; padding: 10px 16px;
  border-radius: 10px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.cloud-pw-primary { background: var(--accent-light); color: #fff; border: 1px solid var(--accent-light); }
.cloud-pw-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.cloud-pw-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.cloud-pw-secondary:hover { border-color: var(--accent-light); color: var(--accent-light); }
@media (max-width: 480px) {
  .plans-modal.cloud-paywall { padding: 32px 22px 24px; }
  .cloud-pw-actions { flex-direction: column; }
}

.cloud-pw-strip {
  display: flex; align-items: center; gap: 10px;
  /* same side gutters as .input-area, so it lines up with the chat card */
  margin: 0 16px 8px; padding: 6px 8px 6px 14px;
  flex-shrink: 0; box-sizing: border-box;
  font-size: 13px; color: var(--text);
  background: color-mix(in srgb, var(--accent-light) 10%, var(--panel-bg));
  border: 1px solid color-mix(in srgb, var(--accent-light) 35%, var(--border));
  border-radius: 10px;
}
.cloud-pw-strip-text { flex: 1 1 auto; min-width: 0; }
.cloud-pw-strip-btn {
  flex: 0 0 auto; padding: 4px 12px; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  background: var(--accent-light); color: #fff; border: none;
}
.cloud-pw-strip-btn:hover { background: var(--accent-hover); }
.cloud-pw-strip-x {
  flex: 0 0 auto; background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1; padding: 2px 4px;
}
.cloud-pw-strip-x:hover { color: var(--text); }

.lab-split.notebook-hidden .cloud-pw-strip { margin-left: max(16px, 15%); margin-right: max(16px, 15%); }
.lab-split.notebook-hidden.web-open .cloud-pw-strip { margin-left: 0; margin-right: 0; }
/* No-headline variant: the one sentence IS the message, so it reads larger. */
.cloud-pw-body.cloud-pw-body-lead { font-size: 18px; max-width: 440px; }

/* The switch bar's markup is created once and inserted UNCONDITIONALLY by the
   shim (no width check in the JS — it relies entirely on CSS to show/hide it),
   so it needs a real always-on baseline here, OUTSIDE the media query below.
   Without this, a desktop-width visit gets NO rule for it at all from this
   file (its flex/background/border styling only exists inside the ≤899px
   block) and the plain <div>+two <button>s fall back to the browser's own
   default block/button chrome — rendering as a small unstyled "Chat" /
   "Notebook" pair pinned to the very top of the centre panel, above the real
   header (reported 2026-09-23, real desktop screenshots: "the chat and
   notebook at the top bar which should not be there... a left over of what
   we had done before on mobile now on desktop view"). Hidden by default;
   the media query re-enables it with display:flex at mobile widths. */
#mobile-view-switch { display: none; }
/* Same reasoning, same fix, for the shared bar (drawer toggle + the switch
   above) that now HOSTS #mobile-view-switch — see the JS-side comment in
   shim/omicsapi.js for why this moved out of .chat-header entirely. */
#mobile-top-bar { display: none; }

/* ==========================================================================
   MOBILE LAYOUT (<=899px) — matches the approved "Lab, Pocket-Sized" mockup.
   Sidebar becomes a slide-out drawer; the chat/notebook split (and the web
   panel, when open) show one surface at a time instead of side by side.
   The 900px cutoff matches an existing breakpoint already used elsewhere in
   the desktop stylesheet itself (.plans-cards-row), and the older, separate
   `web/` static client's own desktop threshold.
   ========================================================================== */
@media (max-width: 899px) {
  /* ---- Sidebar: a real drawer, independent of desktop's .sidebar-collapsed
     (whose default "no class = shown inline" is the opposite of what a
     drawer needs) — this ignores that class entirely at this width. Opened
     via #mobile-drawer-btn (further down, inside the new shared top bar) —
     the real desktop hamburger (.sidebar-expand / #sidebar-expand-btn) is
     NOT forced visible here; it lives inside .chat-header, which this width
     hides outright (see the comment below), so it stays correctly hidden. */
  #resize-left { display: none !important; }

  #app.sidebar-collapsed #left-panel,
  #left-panel {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100dvh;
    width: min(82vw, 300px);
    max-width: 300px;
    z-index: 900;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .35);
  }
  #app.mobile-drawer-open #left-panel { transform: translateX(0); }

  #mobile-scrim {
    position: fixed;
    inset: 0;
    z-index: 890;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  #app.mobile-drawer-open #mobile-scrim { opacity: 1; pointer-events: auto; }

  /* ---- Chat / Notebook: one view at a time ---- */
  /* The real .chat-header is now entirely redundant at this width — the
     drawer toggle and the Chat/Notebook switch both live in the new shared
     #mobile-top-bar below instead (a sibling of .lab-split, so it survives
     switching views — see the long comment in shim/omicsapi.js). All that's
     left inside .chat-header is the always-empty .chat-header-info slot, so
     the whole header is hidden outright rather than left as a dead 53px bar
     sitting on top of the chat messages. */
  .chat-header { display: none !important; }

  /* The shared bar itself: same visual recipe as .chat-header/.notebook-header
     (53px, 18px side padding, bottom border, panel background) so it reads as
     one seamless header regardless of which view is showing beneath it. */
  #mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 53px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-bg);
    flex-shrink: 0;
  }
  /* The mobile-only drawer-open button — same look as the real (now-hidden)
     .sidebar-toggle/.sidebar-expand it stands in for. */
  #mobile-drawer-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
  }
  #mobile-drawer-btn:hover { background: var(--panel-bg-2); color: var(--text); }
  #mobile-view-switch {
    display: flex;
    gap: 4px;
    /* No margin/edge-inset of its own — #mobile-top-bar's own
       `justify-content: space-between` + `padding: 0 18px` already pins it
       flush to the right edge with the correct inset, matching the drawer
       button's own 18px inset on the left — same row, balanced spacing. */
    padding: 4px;
    flex-shrink: 0;
    background: var(--panel-bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .mvs-seg {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .mvs-seg.active { background: var(--panel-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
  .mvs-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent-light);
    opacity: 0;
    transform: scale(.6);
    transition: opacity .15s ease, transform .15s ease;
  }
  .mvs-seg.has-activity .mvs-dot { opacity: 1; transform: scale(1); animation: mvsPulse 1.4s ease-in-out infinite; }
  @keyframes mvsPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 114, 44, .55); }
    50%      { box-shadow: 0 0 0 5px rgba(232, 114, 44, 0); }
  }

  /* The switch decides column visibility outright, overriding every desktop
     state combination (.notebook-hidden / .web-open / .nb-max) at this width. */
  #resize-lab, .lab-resize { display: none !important; }
  .lab-split .chat-column,
  .lab-split .notebook-column {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
  }
  #app[data-mobile-view="notebook"] .lab-split .chat-column { display: none !important; }
  #app[data-mobile-view="notebook"] .lab-split .notebook-column { display: flex !important; }
  #app[data-mobile-view="chat"] .lab-split .notebook-column { display: none !important; }

  /* Two notebook-header icons exist purely to manage desktop's side-by-side
     split — #maximize-nb-btn temporarily hides the chat column so the
     notebook fills the space, #hide-nb-btn collapses the notebook away back
     to a chat-only view. Both are meaningless at this width: the app already
     shows exactly one column at a time via #mobile-view-switch above, so
     there's no split to expand into and "hide the notebook" is just tapping
     Chat on the switch — hidden here rather than left as two dead buttons. */
  #maximize-nb-btn, #hide-nb-btn { display: none !important; }

  /* .notebook-hidden (desktop: no cells yet, so the chat column widens to
     fill the whole panel) carries TWO more effects the column-visibility
     override above doesn't touch — a header button to reopen the notebook,
     and a 15%-of-panel side gutter on the messages/input card that's sized
     for a wide desktop window. On a fresh "New chat" (reported 2026-09-23,
     real screenshots) this stacked a redundant second icon in the header
     next to the real hamburger AND squeezed the input card in from the
     sides compared to a session where .notebook-hidden wasn't set. At this
     width the switch above is the ONE way to reach the notebook, and the
     plain split-view spacing is what should always apply, regardless of
     .notebook-hidden — so neutralize both effects unconditionally: */
  #notebook-toggle-btn { display: none !important; }
  .lab-split.notebook-hidden .chat-messages { padding-left: 18px; padding-right: 18px; }
  .lab-split.notebook-hidden .input-area { margin-left: 16px; margin-right: 16px; }

  /* The 4 "what would you like to accomplish" starter cards default to one
     4-wide row (min 120px/column) that overflows into a horizontal slide
     on a phone-width screen — 2x2 instead, centered in the same padded
     welcome-message column the title above already sits in. */
  .wes-cards { grid-template-columns: repeat(2, 1fr); max-width: 420px; }

  /* ---- Web panel: a full-screen takeover, not a side-by-side column ---- */
  .lab-split.web-open #web-panel {
    position: fixed;
    inset: 0;
    z-index: 850;
    width: 100% !important;
    max-width: none !important;
    height: 100dvh;
    border-left: none;
  }
}

/* ── Merged top row (same look as the desktop app) ─────────────────────────────────
   Wide screens: an empty slim 38px row on the page background carries the notebook icons at the
   right (no header bars). Narrow screens (phones/tablets) keep the original bars + the mobile top bar. */
@media (min-width: 900px) {
  #titlebar { display: flex; height: 38px; padding: 0 12px; border-bottom: none; }
  #titlebar .tb-menu, #titlebar .tb-logo, #titlebar .tb-drag { display: none; }
  #app { height: 100vh; height: 100dvh; }
  #left-panel { padding-top: 0; }   /* the web row has no menu, so the sidebar's own logo row starts at the very top */
  .notebook-header-actions, .chat-header-actions { right: 12px; }
  .chat-header .sidebar-expand { left: 12px; }
}
@media (max-width: 899px) {
  #app > :not(#left-panel) { margin-top: 0; }
  #left-panel { padding-top: 0; }
  .logo-section { border-bottom: 1px solid var(--border); }
  .notebook-header-actions #export-menu-btn, .notebook-header-actions #maximize-nb-btn { display: flex; }   /* phones/tablets keep the old bars with the separate icons */
  .notebook-header-actions #more-menu-btn { display: none; }
  .lab-split.web-open .notebook-column { display: none !important; }   /* phones/tablets: the web panel takes the notebook's place as before */
  .chat-header, .notebook-header { height: 53px; padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--panel-bg); overflow: hidden; }
  .chat-header-info { display: flex; }
  .nb-title { display: block; }
  .notebook-header-actions, .chat-header-actions { position: static; top: auto; right: auto; height: auto; z-index: auto; }
  .chat-header .sidebar-expand { position: static; top: auto; left: auto; z-index: auto; margin-right: 4px; }
  .notebook-header-actions .header-btn, .chat-header-actions .header-btn, .chat-header .sidebar-expand { background: var(--panel-bg-2); border-color: var(--border); }
}
