/* ============================================================================
   /shared/ai-portal.css  -  Full-screen mobile "AI Legal Analyst" portal.
   Hosts the EXISTING GPT chat engine: on open, #homepage-chat is relocated into
   the portal body (the live chat, with its built-in paperclip + mic + send +
   free-message gating, comes along intact). On close it moves back, so the
   inline section and desktop are untouched. Pairs with /shared/ai-portal.js.
   ============================================================================ */

/* AI-first hero command box (mobile entry into the portal). */
.hero-cmd { display: none; }
@media (max-width: 768px) {
  .hero-cmd {
    display: flex; align-items: center; gap: 10px; width: 100%; margin-top: .8rem;
    background: rgba(255,255,255,.97); border: 1px solid rgba(255,255,255,.5);
    border-radius: 14px; padding: 13px 14px; cursor: pointer; text-align: left;
    box-shadow: 0 12px 32px rgba(0,0,0,.28); font-family: inherit;
  }
  .hero-cmd-ic { flex: 0 0 auto; color: #16a36c; display: inline-flex; }
  .hero-cmd-ph { flex: 1; min-width: 0; color: #475569; font-size: 14px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero-cmd-go { flex: 0 0 auto; background: linear-gradient(135deg,#16c784,#31e6a1);
    color: #03130d; font-weight: 900; font-size: 13px; border-radius: 10px; padding: 7px 12px; }
}

/* AI-forward single sticky action (replaces the 2-button law-firm bar). */
.sticky-cta .sticky-ai {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg,#16c784,#31e6a1); color: #03130d; font-weight: 800;
}
.sticky-cta .sticky-ai:hover { background: linear-gradient(135deg,#13b377,#2bd494); }

/* Always-visible mobile header "AI Analyst" pill (injected by ai-portal.js). */
.tlaw-hdr-ai { display: none; }
@media (max-width: 1024px) {
  .tlaw-hdr-ai {
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 8px;
    min-height: 38px; padding: 0 13px; border-radius: 999px; border: 1px solid rgba(42,245,152,.40);
    background: linear-gradient(135deg,#16c784,#31e6a1); color: #06131f; font-weight: 800; font-size: 13px;
    font-family: inherit; cursor: pointer; white-space: nowrap; box-shadow: 0 0 0 4px rgba(22,199,132,.10);
  }
  .tlaw-hdr-ai__dot { width: 7px; height: 7px; border-radius: 50%; background: #06131f; }
}

/* The portal overlay. */
.ai-portal {
  position: fixed; inset: 0; height: 100dvh; z-index: 2000; display: flex; flex-direction: column;
  background: #0b1430; transform: translateY(100%); transition: transform .28s ease;
  visibility: hidden;
}
.ai-portal[aria-hidden="false"] { transform: translateY(0); visibility: visible; }

.ai-portal-topbar {
  display: flex; align-items: center; gap: 12px; color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: linear-gradient(165deg,#0b1430,#13203f);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ai-portal-close {
  flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px; color: #fff; cursor: pointer; padding: 0;
}
.ai-portal-close:hover { background: rgba(255,255,255,.18); }
.ai-portal-id { display: flex; flex-direction: column; min-width: 0; }
.ai-portal-id strong { font-size: 15px; font-weight: 800; line-height: 1.2; }
.ai-portal-id span { font-size: 11.5px; color: #9fb3d8; }
.ai-portal-status {
  margin-left: auto; flex: 0 0 auto; font-size: 10.5px; font-weight: 800; color: #86efac;
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); border-radius: 999px;
  padding: 4px 9px; white-space: nowrap;
}
/* Tiny ST avatar + AI-assisted badge keep humanity in the cockpit header. */
.ai-portal-avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: top center; border: 1px solid rgba(255,255,255,.22); }
.ai-portal-badge { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #bcd2ff; background: rgba(127,176,255,.16); border: 1px solid rgba(127,176,255,.35); border-radius: 999px; padding: 2px 7px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }

/* The composer's send control reads "Analyze" INSIDE the Analyst (translatable via
   --cmd-analyze, set by command-nav.js). Other pages keep the engine's paper-plane icon. */
#ai-portal #uchat-send-btn { width: auto !important; min-width: auto !important; flex: 0 0 auto; padding: 0 16px !important; height: 40px; border-radius: 11px !important; background: #f59e0b !important; color: #0b1430 !important; font-weight: 800; font-size: 14px; }
#ai-portal #uchat-send-btn svg { display: none !important; }
#ai-portal #uchat-send-btn::after { content: var(--cmd-analyze, "Analyze"); }

.ai-portal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; }
#ai-portal-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
#ai-portal-mount #homepage-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }

/* Make the relocated engine panel fill the portal, input pinned at the bottom. */
#ai-portal-mount #uchat-panel,
#ai-portal-mount #uchat-panel.uchat-inline,
#ai-portal-mount #uchat-panel.uchat-homepage-panel {
  position: static !important; flex: 1; min-height: 0; height: auto !important; max-height: none !important;
  width: 100% !important; margin: 0 !important; border: 0 !important; border-radius: 0 !important;
  box-shadow: none !important; display: flex !important; flex-direction: column !important;
}
#ai-portal-mount #uchat-panel .uchat-body { flex: 1; min-height: 0 !important; max-height: none !important; }
#ai-portal-mount #uchat-panel .uchat-input-area { display: block !important; }

/* Loading hint shown until the engine boots inside the portal. */
.ai-portal-loading {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  color: #64748b; font-size: 14px; padding: 24px;
}

/* Portal quick-start chips (horizontal scroll, above the chat). */
.ai-portal-chips {
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity; padding: 10px 12px; background: #0b1430;
  border-bottom: 1px solid rgba(255,255,255,.07); scrollbar-width: none; flex: 0 0 auto;
}
.ai-portal-chips::-webkit-scrollbar { display: none; }
.ai-portal-chips .ai-chip {
  flex: 0 0 auto; scroll-snap-align: start; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #eaf0fb; font-family: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.ai-portal-chips .ai-chip:hover { background: rgba(255,255,255,.14); }

/* "Fill in Details" intake card fills the portal body when a lane chip unfolds. */
.ai-portal-form { flex: 1; min-height: 0; width: 100%; }

/* Desktop: the workspace is a comfortable centered column (wide, never full-bleed),
   so the nav-launched Demand Letters intake reads as a premium mega-panel. */
@media (min-width: 1025px) {
  .ai-portal-body { align-items: center; }
  #ai-portal-form, #ai-portal-mount, .ai-portal-chips { max-width: 1180px; width: 100%; margin-left: auto; margin-right: auto; }
}

/* Bottom sheets (upload + more) inside the portal. */
.ai-sheet-backdrop { position: absolute; inset: 0; background: rgba(3,8,20,.55); opacity: 0; visibility: hidden; transition: opacity .2s; z-index: 5; }
.ai-sheet-backdrop.is-open { opacity: 1; visibility: visible; }
.ai-sheet {
  position: absolute; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom,0px));
  z-index: 6; max-height: 72vh; overflow: auto; border-radius: 20px; background: #fff;
  border: 1px solid rgba(15,23,42,.12); box-shadow: 0 24px 80px rgba(3,8,20,.45);
  transform: translateY(115%); transition: transform .24s ease; visibility: hidden;
}
.ai-sheet.is-open { transform: translateY(0); visibility: visible; }
.ai-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.ai-sheet-head strong { font-size: 15px; color: #0f172a; }
.ai-sheet-x { border: 0; background: transparent; font-size: 24px; line-height: 1; color: #64748b; cursor: pointer; width: 36px; height: 36px; }
.ai-sheet-body { padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-sheet-opt {
  min-height: 50px; border-radius: 14px; border: 1px solid rgba(15,23,42,.12); background: #f8fafc;
  color: #0f172a; font-family: inherit; font-weight: 700; font-size: 15px; text-align: left; padding: 0 14px; cursor: pointer;
}
.ai-sheet-opt:hover { background: #eef2f7; }
.ai-paste-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ai-paste { width: 100%; min-height: 96px; border: 1px solid rgba(15,23,42,.18); border-radius: 12px; padding: 10px 12px; font-family: inherit; font-size: 16px; resize: vertical; }
.ai-paste-add { min-height: 44px; border: 0; border-radius: 12px; background: linear-gradient(135deg,#16c784,#31e6a1); color: #03130d; font-weight: 800; font-family: inherit; cursor: pointer; }
.ai-chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-grid-chip { min-height: 48px; border-radius: 14px; border: 1px solid rgba(15,23,42,.12); background: #f8fafc; color: #0f172a; font-family: inherit; font-weight: 700; font-size: 14px; text-align: left; padding: 8px 12px; cursor: pointer; }
.ai-grid-chip:hover { background: #eef2f7; }
@media (prefers-reduced-motion: reduce) { .ai-sheet, .ai-sheet-backdrop { transition: none; } }

body.ai-portal-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .ai-portal { transition: none; } }

/* ============================================================================
   Dark-theme the relocated GPT engine WHEN it lives inside the portal, so the
   cockpit reads as one "advanced dark" surface instead of the light chatbox.
   Scoped to #ai-portal only: the sitewide FAB and every other page keep the
   engine's normal light theme untouched.
   ============================================================================ */
#ai-portal #uchat-panel,
#ai-portal .uchat-panel,
#ai-portal .uchat-homepage-panel,
#ai-portal .uchat-body { background: #0b1430 !important; color: #eaf0fb !important; }
#ai-portal .uchat-header { background: #0b1430 !important; border-color: rgba(255,255,255,.10) !important; }

/* Welcome / intro / picker cards */
#ai-portal .uchat-welcome,
#ai-portal .uchat-homepage-welcome,
#ai-portal .uchat-picker-card,
#ai-portal .uchat-foldout,
#ai-portal .uchat-foldout-body,
#ai-portal .uchat-issue-card,
#ai-portal .uchat-matter-card { background: rgba(255,255,255,.045) !important; border: 1px solid rgba(255,255,255,.10) !important; color: #eaf0fb !important; border-radius: 14px !important; }
#ai-portal .uchat-welcome p,
#ai-portal .uchat-homepage-welcome p,
#ai-portal .uchat-subtitle,
#ai-portal .uchat-welcome-hint,
#ai-portal .uchat-footer,
#ai-portal .uchat-foldout-body { color: #cdd9f0 !important; }
#ai-portal .uchat-welcome strong,
#ai-portal .uchat-welcome b,
#ai-portal .uchat-welcome h1, #ai-portal .uchat-welcome h2, #ai-portal .uchat-welcome h3,
#ai-portal .uchat-matter-card-h,
#ai-portal .uchat-issue-card strong { color: #fff !important; }

/* Quick-start / tree / action chips -> dark pills */
#ai-portal .uchat-quick-q,
#ai-portal .uchat-tree-option,
#ai-portal .uchat-action-chip,
#ai-portal .uchat-projects-btn,
#ai-portal .uchat-intake-yesno-btn { background: rgba(255,255,255,.07) !important; color: #eaf0fb !important; border: 1px solid rgba(255,255,255,.16) !important; }
#ai-portal .uchat-quick-q:hover,
#ai-portal .uchat-tree-option:hover,
#ai-portal .uchat-action-chip:hover { background: rgba(255,255,255,.13) !important; }

/* Message bubbles */
#ai-portal .uchat-msg-content { color: #eaf0fb !important; }
#ai-portal .uchat-msg.user .uchat-msg-content,
#ai-portal .uchat-msg-user .uchat-msg-content { background: #1d3a8a !important; color: #fff !important; }
#ai-portal .uchat-msg.ai .uchat-msg-content,
#ai-portal .uchat-msg-ai .uchat-msg-content,
#ai-portal .uchat-msg.assistant .uchat-msg-content { background: rgba(255,255,255,.06) !important; border: 1px solid rgba(255,255,255,.08) !important; color: #eaf0fb !important; }
#ai-portal .uchat-msg-content a { color: #7fb0ff !important; }

/* Composer / inputs */
#ai-portal .uchat-input-area { background: #0b1430 !important; border-top: 1px solid rgba(255,255,255,.10) !important; }
#ai-portal .uchat-input,
#ai-portal textarea.uchat-input,
#ai-portal .uchat-email-input,
#ai-portal input.uchat-email-input,
#ai-portal .uchat-direct-field,
#ai-portal .uchat-intake-form input,
#ai-portal .uchat-intake-form select,
#ai-portal .uchat-intake-form textarea { background: rgba(0,0,0,.28) !important; color: #eaf0fb !important; border: 1px solid rgba(255,255,255,.16) !important; color-scheme: dark; }
#ai-portal .uchat-input::placeholder,
#ai-portal .uchat-email-input::placeholder { color: #8fa6cf !important; }

/* Belt-and-suspenders: any inline white background left in the engine markup */
#ai-portal #uchat-panel [style*="#fff"],
#ai-portal #uchat-panel [style*="#FFF"],
#ai-portal #uchat-panel [style*="rgb(255"] { background-color: rgba(255,255,255,.05) !important; }
