/**
 * Plugin Name:  PokéPapi LLM Council
 * File:         public/css/composer_ios.css
 * Description:  Universal iOS-app composer. Removes the left #tool-rail at ALL
 *               widths, promotes the "+" button + bottom sheet to desktop too,
 *               and turns the wide "Debate" submit into a compact circular
 *               send-arrow. Loaded LAST so it wins over style_mobile_v2/v3.css.
 * Version:      0.2.4
 * Author:       PokéPapi
 * License:      GPL-2.0+
 */

/* ═══════════════════════════════════════════════════════════════════
   (1) KILL THE TOOL-RAIL EVERYWHERE.
   The left vertical strip is gone from the product — the "+" menu owns
   Attach / Export / Image / Mode now. The chat reclaims that column.
   ═══════════════════════════════════════════════════════════════════ */
/* Hiding the rail removes it from #main-body's flex flow, so #main-content-col
   (flex:1) already reclaims the full width. Do NOT override #main-body display —
   forcing block collapsed the chat/input flex column and made the input bar
   disappear on desktop/tablet/landscape (phone-portrait survived only because
   its input is position:fixed). */
#tool-rail { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   (1b) SCROLLFIX — restore the mobile chat scroll viewport.
   ─────────────────────────────────────────────────────────────────
   ROOT CAUSE: style_mobile_v3.css (@media max-width:768px) set
     #main-body { display: block !important; }
   to collapse the now-hidden #tool-rail. But the chat scroll viewport
   relies on an UNBROKEN flex height chain:
     #app(100dvh, overflow:hidden) → #main(flex col, min-height:0) →
     #main-body(flex, min-height:0) → #main-content-col(flex col,
     min-height:0) → #chat-area(flex:1, min-height:0, overflow-y:auto)
   `display:block` on #main-body removed it as a flex container, so
   #main-content-col + #chat-area lost their bounded height. #chat-area's
   `flex:1; min-height:0` then had no flex parent to size against, so it
   grew to FULL content height (clientHeight === scrollHeight) and never
   became a scrollable viewport — the whole session became unscrollable
   on phones. (Verified: clientH=6946 === scrollH=6946 at 390px pre-fix.)
   FIX: re-establish the flex column chain on phones and pin #chat-area as
   the one bounded, scrollable region. Loaded last → wins over v3.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #main-body {
    display: flex !important;       /* was block — that broke the height chain */
    flex: 1 1 auto !important;
    min-height: 0 !important;
    flex-direction: row;            /* rail is hidden, content-col reclaims all width */
  }
  #main-content-col {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }
  #chat-area {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;   /* keep scroll inside the chat, don't chain to body */
  }
  /* The composer + discussion bar are siblings of #chat-area in
     #main-content-col — keep them from shrinking so #chat-area takes the
     remaining space and scrolls. */
  #input-area { flex: 0 0 auto; }
}

/* ═══════════════════════════════════════════════════════════════════
   (2) THE "+" BUTTON — leading edge of the composer, all breakpoints.
   iOS-style circular control. (mobile_v4.js injects #mobilePlusBtn.)
   ═══════════════════════════════════════════════════════════════════ */
#mobilePlusBtn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  min-width: 38px;
  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; /* always first in the input row */
  transition: background 0.15s, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
#mobilePlusBtn:hover { background: rgba(139, 92, 246, 0.24); }
#mobilePlusBtn:active { background: rgba(139, 92, 246, 0.30); }
#mobilePlusBtn.active {
  background: var(--accent, #8b5cf6);
  color: #fff;
  transform: rotate(45deg);
}
#mobilePlusBtn svg { width: 20px; height: 20px; }

/* ═══════════════════════════════════════════════════════════════════
   (3) THE "+" SHEET — promoted to all widths. On desktop it renders as a
   compact popover anchored to the composer's bottom-left rather than a
   full-width bottom sheet.
   ═══════════════════════════════════════════════════════════════════ */
#mobile-plus-sheet {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 230;
  background: var(--bg-secondary, #1a1d2e);
  border: 1px solid var(--border);
  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.22s ease, opacity 0.22s 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;
  transition: background 0.12s;
}
#mobile-plus-sheet .plus-row:hover { background: rgba(139, 92, 246, 0.10); }
#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;
}
/* Debate sub-actions in the + menu — nested directly under the Council Debate
   mode entry (Add a Round / Interject / Send to Arbiter). Only shown when the
   session has a debate (toggled in mobile_v4.js). Indented + tinted so they
   read as children of the Mode row. */
#mobile-plus-sheet .plus-subgroup {
  display: flex; flex-direction: column;
  margin: 0 0 4px 18px; padding-left: 10px;
  border-left: 2px solid var(--accent, rgba(139, 92, 246, 0.45));
}
#mobile-plus-sheet .plus-subrow {
  min-height: 48px; padding: 8px 10px;
}
#mobile-plus-sheet .plus-subrow .plus-row-icon {
  width: 32px; height: 32px;
}
#mobile-plus-sheet .plus-subrow .plus-row-label { font-size: 14px; }
#mobile-plus-sheet-backdrop {
  display: none; position: fixed; inset: 0; z-index: 225;
  background: rgba(0,0,0,0.45);
}
#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; }

/* Export / Image popups live in the (now hidden) tool-rail. When opened from
   the + sheet they must render as a viewport-anchored sheet, all widths. */
#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: min(420px, calc(100vw - 16px)) !important;
  max-height: 78vh; overflow-y: auto; z-index: 240 !important;
}

/* Desktop (≥769px): render the sheet as a left-anchored popover, not a
   full-bleed bottom sheet — feels native on a wide window. */
@media (min-width: 769px) {
  #mobile-plus-sheet {
    left: 24px; right: auto;
    width: 340px;
    bottom: 88px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  }
  #mobile-plus-sheet .sheet-handle { display: none; }
  #mobile-plus-sheet-backdrop.open { background: rgba(0,0,0,0.25); }
  body.plus-sheet-open #app { filter: none; }
  #exportPopup.visible,
  #imageGenPopup {
    left: 24px !important; right: auto !important;
    bottom: 88px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   (4) COMPACT CIRCULAR SEND-ARROW.
   The submit button's inner content is set dynamically (label + svg) by
   several app.js paths. We don't fight that — we hide all children and
   paint a single ↑ glyph, and clamp the button to a circle. Logic never
   reads the button text, so this is purely cosmetic + robust.
   ═══════════════════════════════════════════════════════════════════ */
#sendBtn {
  position: relative;
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: var(--accent) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center; justify-content: center;
  gap: 0 !important;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 0 !important; /* collapse any text label */
}
/* Hide every injected child (logo imgs, SVGs, label spans) */
#sendBtn > * { display: none !important; }
/* Paint the up-arrow */
#sendBtn::after {
  content: "";
  display: block;
  width: 18px; height: 18px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E") center / contain no-repeat;
}
#sendBtn:hover { background: var(--accent-hover) !important; transform: translateY(-1px); }

/* ===================================================================
   (5) MOVE THE MODE DROPDOWN OFF THE CHAT BAR - TASK 1.
   The mode/model picker now lives entirely inside the + menu (its "Mode"
   row). We remove #modelSelectorWrap from the input-row flex flow at ALL
   widths, but keep it in the DOM as the anchor for #modelDropdown so the
   existing desktop dropdown + all app.js logic (state, selection, filter)
   keep working. The + menu Mode row clicks #modelSelectorBtn, which opens
   #modelDropdown anchored to this off-bar point (or the mobile sheet on
   phones via mobile_v3.js).
   =================================================================== */
#input-row { position: relative; }              /* anchor for the hint bubble */
/* Gone from the chat bar entirely, at ALL widths. Kept in the DOM (its
   .sel-option children + hidden <select> back app.js state + the + menu Mode
   row) but display:none so it never paints in the composer. Mode selection
   happens through #mobile-model-sheet, which mobile_v4.js opens at all widths
   and composer_ios.css styles for desktop below. */
#modelSelectorWrap { display: none !important; }

/* ── Promote #mobile-model-sheet to desktop (>=769px) as a compact left
      popover, mirroring the + sheet. On phones style_mobile_v3.css already
      renders it as a full-width bottom sheet (that media block wins there). ── */
@media (min-width: 769px) {
  #mobile-model-sheet {
    display: none;
    position: fixed;
    left: 24px; right: auto;
    bottom: 88px;
    width: 340px;
    max-height: 70vh;
    z-index: 235;
    background: var(--bg-secondary, #1a1d2e);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
    padding: 8px 0 12px;
    flex-direction: column;
    overflow: hidden;
  }
  /* !important beats style_mobile_v3.css's "Mobile model sheet must never show
     on desktop" force-hide (#mobile-model-sheet{display:none!important}). The +
     menu now routes Mode through this sheet at ALL widths, so on desktop the
     OPEN state must win — otherwise clicking Mode does nothing ("disappears"). */
  #mobile-model-sheet.open { display: flex !important; }
  #mobile-model-sheet .sheet-handle { display: none; }
  #mobile-model-sheet h3 {
    margin: 0; padding: 6px 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;
    font-family: inherit;
  }
  #mobile-model-sheet .sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 0 6px 6px; }
  #mobile-model-sheet #modelDropdownFilter {
    display: block; width: calc(100% - 16px) !important;
    margin: 6px 8px 10px !important; padding: 9px 12px !important; font-size: 13px !important;
  }
  #mobile-model-sheet .sel-option {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px; margin: 2px 4px; font-size: 13px;
    border-radius: 10px; cursor: pointer; color: var(--text-primary);
  }
  #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; }
  #mobile-model-sheet-backdrop {
    display: none; position: fixed; inset: 0; z-index: 230; background: rgba(0,0,0,0.25);
  }
  #mobile-model-sheet-backdrop.open { display: block !important; }
  /* Original desktop dropdown popover must never paint now. */
  #modelDropdown.open { display: none !important; }
}

/* ===================================================================
   (6) BOUNCING HINT BUBBLE ABOVE THE + BUTTON - TASK 2.
   A small speech bubble that gently bounces above #mobilePlusBtn to point
   users at the mode menu. Copy is set by mobile_v4.js (new vs active
   session). Dismissed when the + menu opens or after a timeout.
   =================================================================== */
#plus-mode-hint {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 14px);                     /* float above the + button */
  z-index: 215;
  display: inline-flex; align-items: center;
  max-width: min(70vw, 220px);
  padding: 7px 12px;
  background: var(--accent, #8b5cf6);
  color: #fff;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  line-height: 1.2; white-space: nowrap;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.40);
  pointer-events: none;                          /* never blocks the input */
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#plus-mode-hint.show {
  opacity: 1;
  animation: plusHintBounce 1.6s ease-in-out infinite;
}
/* Downward tail pointing at the + button */
#plus-mode-hint::after {
  content: "";
  position: absolute;
  left: 16px; top: 100%;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--accent, #8b5cf6);
}
@keyframes plusHintBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
  #plus-mode-hint.show { animation: none; }
}

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