/**
 * File:          public/css/style_mobile_v3.css
 * Version:       0.2.0
 * Last Modified: 2026-05-29 12:00 PM
 * Description:   Mobile UX v3 — model bottom sheet, +menu model chip,
 *                desktop filters button + popover. Loaded AFTER
 *                style_mobile_v2.css so it overrides cleanly.
 *                v0.2.0 (MOBMIMIC): hide the vertical #tool-rail on mobile and
 *                add the iPhone-app "+" composer button + bottom sheet
 *                (mobile_v4.js). Desktop layout unchanged.
 */

/* ───── DESKTOP FILTERS BUTTON + POPOVER (≥769px) ───── */
@media (min-width: 769px) {
  #desktop-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.10);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 16px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    min-height: 32px;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
  }
  #desktop-filters-btn:hover {
    background: rgba(139, 92, 246, 0.18);
    color: var(--text-primary);
    border-color: var(--accent);
  }
  #desktop-filters-btn[aria-expanded="true"] {
    background: var(--accent-dim);
    color: var(--accent-hover);
    border-color: var(--accent);
  }
  /* Native tooltip is fine; tooltip="Filter messages" via title= attribute */

  #desktop-filters-popover {
    position: fixed;
    z-index: 220;
    background: var(--bg-secondary, #1a1d2e);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.45);
    padding: 14px 14px 12px;
    display: none;
    max-height: 70vh;
    overflow: auto;
  }
  #desktop-filters-popover.open { display: block; }
  #desktop-filters-popover .popover-section { margin-bottom: 12px; }
  #desktop-filters-popover .popover-section:last-child { margin-bottom: 0; }
  #desktop-filters-popover .popover-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim, #888);
    margin-bottom: 6px;
    font-weight: 600;
  }
  #desktop-filters-popover .slot { display: block; }
  #desktop-filters-popover #discuss-target-wrap {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  #desktop-filters-popover #discuss-target-wrap .discuss-target-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 14px;
  }
  #desktop-filters-popover #chat-layout-toggle {
    display: inline-flex !important;
    gap: 4px;
  }
  #desktop-filters-popover #chat-layout-toggle button {
    padding: 6px 10px;
    font-size: 12px;
  }
  #desktop-filters-popover #hide-user-toggle {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
  }
  #desktop-filters-popover #filter-status {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim, #888);
    margin-top: 4px;
  }

  /* On desktop, the original discussion-mode-bar children that mobile_v2 stuck
     in the mode bar (.mobile-bar-summary) should not show. The bar itself
     contains only the inline label "Discussion Mode — follow-up to the last debate"
     for context. */
  #discussion-mode-bar .mobile-bar-summary { display: none !important; }
  #discussion-mode-bar #mobile-options-toggle { display: none !important; }
  /* Restore visibility of the .mode-label even though mobile_v2 moved children out
     (it's still in the bar). Provide breathing room. */
  #discussion-mode-bar .mode-label {
    display: block !important;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 14px;
  }

  /* Mobile model sheet must never show on desktop */
  #mobile-model-sheet, #mobile-model-sheet-backdrop { display: none !important; }
  #mobilePlusModelBtn { display: none !important; }
}

/* ───── MOBILE (≤768px) ───── */
@media (max-width: 768px) {
  /* Desktop filters button hidden on mobile — the mobile-filters-btn already exists */
  #desktop-filters-btn { display: none !important; }
  #desktop-filters-popover { display: none !important; }

  /* Hide the model selector wrap from the input row — model selection now
     happens via the +menu chip (Issue 2: free up Ask textarea width). */
  #modelSelectorWrap {
    display: none !important;
  }

  /* +menu Model chip — visible when input-row.show-utilities is set, alongside
     attach / export / image-gen icons. */
  #mobilePlusModelBtn {
    display: none !important;
  }
  #input-row.show-utilities #mobilePlusModelBtn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    width: auto !important;
    padding: 0 10px !important;
    height: 38px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid var(--border);
    color: #c4b5fd;
    border-radius: 19px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    order: 15;
  }
  #mobilePlusModelBtn .mobile-plus-model-label {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Convene button — clamped + ellipsis so long labels never clip mid-letter. */
  #sendBtn {
    min-height: 44px !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
    flex-shrink: 0;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* While +menu is open we hide Send so the utility tray + Ask placeholder don't
     get squeezed off-screen. User taps + → picks a utility → +menu auto-closes
     → Send returns. (mobile_v2 already auto-closes on attach/export/imgGen clicks
     and mobile_v3 closes when the model chip is tapped.) */
  #input-row.show-utilities #sendBtn,
  #input-row.show-utilities #stopBtn {
    display: none !important;
  }

  /* Make the Ask textarea take everything that's left. */
  #promptInput {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
  }
  /* When +menu is open, the utility row replaces the Ask area visually. Hide the
     placeholder so the user focuses on picking a utility. */
  #input-row.show-utilities #promptInput {
    display: none !important;
  }

  /* ── Model Bottom Sheet ── */
  #mobile-model-sheet {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 220;
    background: var(--bg-secondary, #1a1d2e);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -12px 32px rgba(0,0,0,0.55);
    padding: 8px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: 78vh;
    overflow: hidden;
    flex-direction: column;
  }
  #mobile-model-sheet.open { display: flex; }
  #mobile-model-sheet .sheet-handle {
    width: 40px; height: 4px;
    background: rgba(255,255,255,0.18);
    border-radius: 2px;
    margin: 4px auto 8px;
  }
  #mobile-model-sheet h3 {
    margin: 0;
    padding: 0 16px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #mobile-model-sheet h3 button {
    background: none;
    border: 0;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
  }
  #mobile-model-sheet .sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 6px 6px;
  }
  /* Style the moved children — they were inside #modelDropdown which had its
     own absolute-positioned popover styling; we override here. */
  #mobile-model-sheet #modelDropdownFilter {
    display: block;
    width: calc(100% - 16px) !important;
    margin: 6px 8px 10px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
  }
  #mobile-model-sheet .sel-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    margin: 2px 4px;
    font-size: 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary);
    min-height: 44px;
  }
  #mobile-model-sheet .sel-option:hover,
  #mobile-model-sheet .sel-option.active {
    background: rgba(139, 92, 246, 0.18);
    color: #c4b5fd;
  }
  #mobile-model-sheet .sel-option img.sel-logo,
  #mobile-model-sheet .sel-option .sel-icon svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
  }
  #mobile-model-sheet .sel-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 4px;
    margin-top: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim, #888);
    font-weight: 600;
  }
  #mobile-model-sheet .sel-group-label img.sel-logo {
    width: 14px; height: 14px;
  }
  /* Hide the original desktop dropdown popover anchor — its absolute positioning
     causes the left-edge clipping we're fixing. */
  body:not(.model-sheet-open) #modelDropdown.open { display: none !important; }

  #mobile-model-sheet-backdrop {
    display: none;
    position: fixed; inset: 0;
    z-index: 215;
    background: rgba(0,0,0,0.55);
  }
  #mobile-model-sheet-backdrop.open { display: block; }
  body.model-sheet-open { overflow: hidden; }
  body.model-sheet-open #app { filter: brightness(0.6); transition: filter 0.2s; }

  /* ═══ Plus-menu vertical stack (Fix 1, agent/plus-menu-redesign) ═══
     When the +menu is open (#input-row.show-utilities), the utility buttons
     (attach, export, image-gen, model-chip) lift out of the input row and
     stack vertically as a popover ABOVE the input row. Each item is full
     width with icon + label, matching iOS action-sheet ergonomics.
     We use the existing IDs/classes — no DOM moves — pure CSS. */
  #input-row.show-utilities {
    position: relative;
  }
  #input-row.show-utilities::before {
    content: "More actions";
    position: absolute;
    left: 8px; right: 8px;
    bottom: calc(100% + 8px);
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim, #94a3b8);
    background: var(--bg-elevated, #1a1a24);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
    z-index: 9;
    pointer-events: none;
  }
  #input-row.show-utilities #attachBtn,
  #input-row.show-utilities #exportBtn,
  #input-row.show-utilities #imageGenBtn,
  #input-row.show-utilities #mobilePlusModelBtn {
    position: absolute;
    left: 8px;
    right: 8px;
    width: auto !important;
    height: auto !important;
    min-height: 48px;
    padding: 12px 16px !important;
    border-radius: 0 !important;
    background: var(--bg-elevated, #1a1a24);
    border: 1px solid var(--border);
    border-bottom: none;
    border-left-width: 1px;
    border-right-width: 1px;
    color: var(--text-primary, #e2e8f0);
    font-size: 14px;
    font-weight: 500;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    z-index: 10;
    box-shadow: -8px 0 24px rgba(0,0,0,0.25), 8px 0 24px rgba(0,0,0,0.25);
  }
  /* Row positions — each 48px above the previous, stacked from input row up.
     Order (bottom→top): attach, model, image-gen, export, then header from ::before. */
  #input-row.show-utilities #attachBtn {
    bottom: calc(100% + 8px);
  }
  #input-row.show-utilities #mobilePlusModelBtn {
    bottom: calc(100% + 56px);
  }
  #input-row.show-utilities #imageGenBtn {
    bottom: calc(100% + 104px);
  }
  #input-row.show-utilities #exportBtn {
    bottom: calc(100% + 152px);
    border-top: 1px solid var(--border);
    border-radius: 0 !important;
  }
  /* Header ::before sits above the topmost option (export at +152px + 48px = +200px) */
  #input-row.show-utilities::before {
    bottom: calc(100% + 200px);
  }
  /* Inject text labels next to each icon — uses ::after on each button */
  #input-row.show-utilities #attachBtn::after  { content: "Attach files / scan QR"; }
  #input-row.show-utilities #exportBtn::after  { content: "Export this session"; }
  #input-row.show-utilities #imageGenBtn::after{ content: "Generate image (AI)"; }
  #input-row.show-utilities #attachBtn::after,
  #input-row.show-utilities #exportBtn::after,
  #input-row.show-utilities #imageGenBtn::after {
    flex: 1;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #e2e8f0);
  }
  /* The model chip already has its own label span — make it grow */
  #input-row.show-utilities #mobilePlusModelBtn .mobile-plus-model-label {
    flex: 1;
    max-width: none !important;
    text-align: left;
    font-size: 14px !important;
    font-weight: 500 !important;
  }
  /* SVGs in each row — slightly larger for tap clarity */
  #input-row.show-utilities #attachBtn svg,
  #input-row.show-utilities #exportBtn svg,
  #input-row.show-utilities #imageGenBtn svg,
  #input-row.show-utilities #mobilePlusModelBtn svg {
    width: 20px !important; height: 20px !important;
    flex-shrink: 0;
    color: var(--accent, #a78bfa);
  }
  /* Backdrop dim — applied via the input-area when utilities shown */
  #input-row.show-utilities::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 8;
    pointer-events: none;
  }
  /* The popups that anchor to old inline buttons (export-popup, imageGenPopup)
     need to stay reachable — when stacked, anchor them to viewport not button. */
  #input-row.show-utilities #exportPopup,
  #input-row.show-utilities #imageGenPopup {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 80px !important;
    top: auto !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    z-index: 20;
  }


  /* Fix1b: neutralize wrap divs around export/imageGen so the absolute-positioned
     buttons inside them anchor to #input-row, not to the narrow wraps. */
  #input-row.show-utilities #exportBtnWrap,
  #input-row.show-utilities #imageGenBtnWrap {
    position: static !important;
  }

}

/* ═══════════════════════════════════════════════════════════════════
   MOBMIMIC (v0.2.0) — iPhone-app parity on phone browsers.
   • Hide the vertical #tool-rail (the "stupid bar" the user reported).
   • Add the leading-edge "+" button to the composer.
   • iOS-style bottom sheet listing Mode / Export / Attach / Image.
   Mobile-only; desktop (≥769px) keeps its docked rail untouched.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* (1) Remove the leftover vertical tool rail on phones — actions move
         into the "+" bottom sheet, matching the native iPhone app. */
  #tool-rail { display: none !important; }
  #main-body { display: block !important; }

  /* (2) The "+" composer button — leading edge of #input-row, iOS-styled. */
  #mobilePlusBtn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    min-width: 40px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid var(--border);
    color: var(--accent-hover, #c4b5fd);
    cursor: pointer;
    order: -1; /* keep it first even if DOM order shifts */
    -webkit-tap-highlight-color: transparent;
  }
  #mobilePlusBtn:active { background: rgba(139, 92, 246, 0.28); }
  #mobilePlusBtn.active {
    background: var(--accent, #8b5cf6);
    color: #fff;
    transform: rotate(45deg);
    transition: transform 0.18s ease;
  }
  #mobilePlusBtn svg { width: 20px; height: 20px; }

  /* (3) The "+" bottom sheet — mirrors #mobile-model-sheet styling. */
  #mobile-plus-sheet {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 230;
    background: var(--bg-secondary, #1a1d2e);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -12px 32px rgba(0,0,0,0.55);
    padding: 8px 0 calc(14px + env(safe-area-inset-bottom, 0px));
    max-height: 78vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  #mobile-plus-sheet.open { display: block; transform: translateY(0); }
  #mobile-plus-sheet .sheet-handle {
    width: 40px; height: 4px;
    background: rgba(255,255,255,0.18);
    border-radius: 2px;
    margin: 4px auto 8px;
  }
  #mobile-plus-sheet h3 {
    margin: 0;
    padding: 0 16px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #mobile-plus-sheet h3 button {
    background: none; border: 0;
    color: var(--text-secondary);
    font-size: 22px; cursor: pointer;
    padding: 2px 6px; line-height: 1;
    font-family: inherit;
  }
  #mobile-plus-sheet .plus-sheet-list {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
  }
  #mobile-plus-sheet .plus-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px;
    background: none;
    border: 0;
    border-radius: 12px;
    color: var(--text-primary, #e2e8f0);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
  }
  #mobile-plus-sheet .plus-row:active { background: rgba(139, 92, 246, 0.16); }
  #mobile-plus-sheet .plus-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.14);
    color: var(--accent-hover, #c4b5fd);
  }
  #mobile-plus-sheet .plus-row-icon svg { width: 20px; height: 20px; }
  #mobile-plus-sheet .plus-row-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
  }
  #mobile-plus-sheet .plus-row-label {
    font-size: 15px;
    font-weight: 600;
  }
  #mobile-plus-sheet .plus-row-sub {
    font-size: 12px;
    color: var(--text-dim, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #mobile-plus-sheet .plus-row-chev {
    color: var(--text-dim, #94a3b8);
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
  }
  #mobile-plus-sheet-backdrop {
    display: none;
    position: fixed; inset: 0;
    z-index: 225;
    background: rgba(0,0,0,0.55);
  }
  #mobile-plus-sheet-backdrop.open { display: block; }
  body.plus-sheet-open { overflow: hidden; }
  body.plus-sheet-open #app { filter: brightness(0.6); transition: filter 0.2s; }

  /* (4) Export / Image popups still live in the (now hidden) #tool-rail, so
         when triggered from the + sheet they must render as a viewport-anchored
         sheet rather than next to the invisible rail. */
  #exportPopup.visible,
  #imageGenPopup {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    max-height: 78vh;
    overflow-y: auto;
    z-index: 240 !important;
  }
  /* imageGenPopup uses inline display:none; reveal it when shown by its handler.
     (app.js toggles its display via the imageGenBtn handler.) */
}

/* === END OF FILE (FILENAME: /var/www/vhosts/pokepapi.com/council/public/css/style_mobile_v3.css) === */
