/*
 * agentic_input.css — light-themed input pages (symbol_input_agentic,
 * distchart_input_agentic, insiders_search_input_agentic). Sandboxed under
 * `.ai-*` namespace; inherits no styles from base.css / bootstrap.
 * Visual language mirrors /landing_agentic_light.
 */

/* ---------- Design tokens ---------- */
:root {
  /* Brand — deeper than the dark theme for AA contrast on white */
  --color-primary: #2563eb;
  --color-primary-strong: #1d4ed8;
  --color-primary-dark: #1e40af;
  --color-primary-glow: rgba(37, 99, 235, 0.30);
  --color-primary-soft: rgba(37, 99, 235, 0.08);
  --color-cyan: #0891b2;

  /* Neutrals — saturated tinted blues, not near-white */
  --color-bg: #ffffff;
  --color-bg-2: #eaf1fc;
  --color-bg-3: #d5e5f8;
  --color-surface: #ffffff;
  --color-surface-2: #f1f5fa;
  --color-border: #d8e1ee;
  --color-border-strong: #b8c5d8;

  /* Text — cool slate */
  --color-text: #1e293b;
  --color-text-strong: #0f172a;
  --color-text-muted: #475569;
  --color-text-subtle: #64748b;

  --radius: 12px;
  --radius-lg: 18px;

  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont,
               'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset (scoped via .ai-page) ---------- */
.ai-page *, .ai-page *::before, .ai-page *::after { box-sizing: border-box; }
.ai-page img, .ai-page svg { max-width: 100%; display: block; }
.ai-page button { font: inherit; cursor: pointer; }
.ai-page h1, .ai-page h2, .ai-page p { margin: 0; }

/* Kill the 41px topbar-spacer below the fixed topbar so the hero sits flush.
 * Page-scoped — this stylesheet only loads on the _agentic input pages. */
.topbar-spacer { height: 0 !important; }

/* Topbar brand override — match the light hero brand (dark slate
 * "Disclosure" + blue→cyan gradient "Tracker"). Same treatment as
 * /landing_agentic_light. */
.topbar .disclosure_sharp,
.topbar-inner .disclosure_sharp {
  color: var(--color-text-strong) !important;
}
.topbar .tracker_sharp,
.topbar-inner .tracker_sharp {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-cyan) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--color-primary);
}

/* ---------- Page wrapper ---------- */
.ai-page {
  position: relative;
  min-height: calc(100vh - 41px); /* topbar height; spacer is zeroed above */
  font-family: var(--font-sans);
  color: var(--color-text);
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(8, 145, 178, 0.22), transparent 60%),
    radial-gradient(1000px 700px at -5% 10%, rgba(37, 99, 235, 0.26), transparent 60%),
    linear-gradient(180deg, #dfecff 0%, #f0f6ff 60%, #ffffff 100%);
  display: flex;
  /* Pin the hero near the top, not viewport-center. Vertical monitors used
   * to drop the box far below the fold with align-items:center. */
  align-items: flex-start;
  justify-content: center;
  /* Top padding scales with viewport height so the hero pins near the top
   * on a 27" desktop (1440px tall → 330px) but doesn't drift below the fold
   * on a laptop (~900px tall → ~200px). Mobile is still overridden below. */
  padding: clamp(120px, 22vh, 330px) 24px 80px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient grid texture — dark grid on the light surface */
.ai-page::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.055) 1px, transparent 1px);
  background-size: 48px 48px;
  z-index: 0;
}

/* ---------- Hero stack ---------- */
.ai-hero {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes ai-eyebrow-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.20); }
  50%      { box-shadow: 0 0 0 9px rgba(37, 99, 235, 0);   }
}
.ai-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary);
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
  text-transform: uppercase;
}
.ai-eyebrow::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.20);
  animation: ai-eyebrow-pulse 2.6s ease-out infinite;
}

/* Chained with .ai-hero so the (0,2,0) selector beats the reset
 * .ai-page h1 { margin: 0 } above (0,1,1) — otherwise margin-bottom is dropped. */
.ai-hero .ai-title {
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--color-text-strong);
  margin-bottom: 30px;
}
.ai-title .ai-brand-d { color: var(--color-text-strong); }
.ai-title .ai-brand-t {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 40%, #0891b2 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--color-primary);
}

.ai-subtitle {
  font-size: 16px;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: 36px;
  max-width: 520px;
}
.ai-subtitle .ai-q {
  color: var(--color-primary);
  font-size: 20px;
  font-weight: 700;
  vertical-align: middle;
  margin: 0 4px;
  line-height: 0;
}

/* ---------- Search box (mirrors .la-stock-search on the light theme) ---------- */
.ai-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  padding: 6px 6px 6px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(37, 99, 235, 0.40);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.06),
    0 12px 32px rgba(37, 99, 235, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: ai-search-pulse 3.4s ease-in-out infinite;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.ai-search:focus-within {
  animation: none;
  border-color: var(--color-primary);
  box-shadow:
    0 0 0 5px rgba(37, 99, 235, 0.14),
    0 18px 48px rgba(37, 99, 235, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ai-search__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary);
}

/* Selectors target the existing input/button IDs so legacy JS keeps working */
.ai-search input,
.ai-search #symbol-input,
.ai-search #distchart-input,
.ai-search #insiders-search-input {
  flex: 1;
  min-width: 0;
  padding: 14px 4px;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-strong);
  background: transparent;
  border: none;
  outline: none;
  letter-spacing: 0.01em;
  height: auto;          /* override bootstrap .form-control */
  box-shadow: none;      /* override bootstrap .form-control */
  border-radius: 0;      /* override bootstrap .form-control */
}
.ai-search input::placeholder { color: var(--color-text-subtle); font-weight: 400; }

.ai-search__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(180deg, #3b82f6 0%, var(--color-primary-strong) 100%);
  border: 1px solid transparent;
  border-radius: 10px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow:
    0 6px 18px rgba(37, 99, 235, 0.38),
    0 2px 6px rgba(37, 99, 235, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.ai-search__submit:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #60a5fa 0%, var(--color-primary) 100%);
  box-shadow:
    0 10px 28px rgba(37, 99, 235, 0.45),
    0 3px 8px rgba(37, 99, 235, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.ai-search__submit:active { transform: translateY(0); }
.ai-search__submit:focus-visible {
  outline: 3px solid var(--color-primary-glow);
  outline-offset: 2px;
}
/* Hide bootstrap glyphicon if it leaks through; we render an inline SVG */
.ai-search__submit .glyphicon { display: none; }

@keyframes ai-search-pulse {
  0%, 100% {
    border-color: rgba(37, 99, 235, 0.40);
    box-shadow:
      0 0 0 4px rgba(37, 99, 235, 0.06),
      0 12px 32px rgba(37, 99, 235, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
  50% {
    border-color: rgba(37, 99, 235, 0.80);
    box-shadow:
      0 0 0 6px rgba(37, 99, 235, 0.12),
      0 18px 48px rgba(37, 99, 235, 0.30),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
}

/* ---------- Hint line below the search ---------- */
.ai-hint {
  margin-top: 18px;
  font-size: 13px;
  color: var(--color-text-subtle);
}
.ai-hint kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--color-text);
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  margin: 0 2px;
}

/* ---------- Autocomplete dropdown (light themed)
 * The jquery.autocomplete plugin appends .autocomplete-suggestions to
 * <body>, then absolute-positions it under the input. The plugin sets
 * inline position/top/left/width; agentic_input_align.js re-snaps
 * left/width to the .ai-search container. Visual language: Linear/
 * Stripe — flat white, neutral slate shadow, full-width rows, single
 * subtle hover bg, monochrome match highlight (no gradients, no colored
 * accents on the rows).
 */
.autocomplete-suggestions {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 12px rgba(15, 23, 42, 0.08),
    0 16px 32px rgba(15, 23, 42, 0.10) !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  color: var(--color-text) !important;
  overflow-y: auto;
  margin-top: 6px;
  padding: 4px 0 !important;
  z-index: 9999 !important;
  animation: ai-ac-fade 90ms ease-out both;
}
@keyframes ai-ac-fade {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.autocomplete-suggestion {
  padding: 10px 16px !important;
  margin: 0 !important;
  border: none !important;
  border-left: 2px solid transparent !important;
  border-radius: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text) !important;
  cursor: pointer;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.4;
  transition: background-color 80ms ease, border-color 80ms ease;
}
/* Matched substring — same color, just bolder (no chromatic highlight). */
.autocomplete-suggestion strong {
  color: var(--color-text-strong) !important;
  font-weight: 600;
}
.autocomplete-selected,
.autocomplete-suggestion:hover {
  background-color: #f1f5f9 !important;
  color: var(--color-text-strong) !important;
  border-left-color: var(--color-primary) !important;
}

.autocomplete-no-suggestion {
  padding: 12px 16px;
  color: var(--color-text-subtle);
  font-style: normal;
  font-size: 13px;
}

/* Neutral webkit scrollbar — thin slate thumb, no brand color. */
.autocomplete-suggestions::-webkit-scrollbar { width: 8px; }
.autocomplete-suggestions::-webkit-scrollbar-track { background: transparent; }
.autocomplete-suggestions::-webkit-scrollbar-thumb {
  background-color: rgba(15, 23, 42, 0.18);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 8px;
}
.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background-color: rgba(15, 23, 42, 0.32);
  background-clip: padding-box;
}

/* ---------- Selection ---------- */
.ai-page ::selection {
  background: rgba(37, 99, 235, 0.25);
  color: var(--color-text-strong);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  /* Tighter side padding so the input gets enough room after the base_v2
     sidebar consumes the left 150px (page-body margin-left:155). */
  .ai-page { padding: 80px 12px 60px; }
  .ai-search { padding: 6px 6px 6px 12px; }
  .ai-search input { font-size: 15px; padding: 13px 4px; }
  .ai-search__submit { padding: 10px 14px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-page *, .ai-page *::before, .ai-page *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
