/* ============================================================
   openSIS Support — shared styles
   Palette (from brand assets):
     --ink   #26252a   (logo black)
     --red   #e8262d   (logo red)
     --mist  #f6f7fb   (cool white)
   Type: Bricolage Grotesque (display) / Inter (body)
   ============================================================ */

   :root {
    --ink: #26252a;
    --ink-soft: #3c3b42;
    --red: #e8262d;
    --red-dark: #c81e24;
    --paper: #ffffff;
    --mist: #f6f7fb;
    --line: #e6e9f1;
    --muted: #6f7480;
    --radius: 16px;
    --shadow-sm: 0 1px 3px rgba(38, 37, 42, 0.06);
    --shadow-lg: 0 12px 40px rgba(38, 37, 42, 0.10);
    --font-display: "Bricolage Grotesque", "Inter", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --col: 720px; /* reading column */
  }
  
  * { box-sizing: border-box; }
  
  html, body { height: 100%; }
  
  body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--mist);
    -webkit-font-smoothing: antialiased;
  }
  
  img { display: block; }
  button { font-family: inherit; cursor: pointer; }
  
  :focus-visible {
    outline: 3px solid rgba(232, 38, 45, 0.4);
    outline-offset: 2px;
    border-radius: 8px;
  }
  
  /* ============ LOGIN ============ */
  
  .login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
      radial-gradient(600px 320px at 50% 12%, rgba(163, 190, 245, 0.35), transparent 70%),
      var(--mist);
  }
  
  .login-card {
    width: min(420px, 100%);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px 28px;
    text-align: center;
  }
  
  .login-logo { width: 72px; height: 72px; margin: 0 auto 14px; }
  
  .login-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.7rem;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
  }
  
  .login-sub {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin: 0 0 26px;
  }
  
  .login-form { text-align: left; }
  
  .field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }
  
  .field-wrap { position: relative; margin-bottom: 8px; }
  
  .field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    translate: 0 -50%;
    width: 18px;
    height: 18px;
    opacity: 0.55;
  }
  
  .field-wrap input {
    width: 100%;
    font: inherit;
    padding: 13px 14px 13px 42px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--mist);
    color: var(--ink);
    transition: border-color 0.15s ease, background 0.15s ease;
  }
  
  .field-wrap input:focus {
    outline: none;
    border-color: var(--red);
    background: var(--paper);
  }
  
  .field-error { color: var(--red-dark); font-size: 0.82rem; margin: 0 0 8px; }
  
  .btn-primary {
    width: 100%;
    margin-top: 10px;
    padding: 13px 16px;
    border: none;
    border-radius: 12px;
    background: var(--red);
    color: #fff;
    font-size: 0.98rem;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.1s ease;
  }
  
  .btn-primary:hover { background: var(--red-dark); }
  .btn-primary:active { transform: scale(0.99); }
  
  .login-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.8rem;
    margin: 22px 0 0;
  }
  
  .login-foot img { width: 14px; height: 14px; opacity: 0.7; }
  
  /* ============ CHAT ============ */
  
  .chat-body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    /* soft CSS glow instead of the opaque PNG (which showed as a rectangle) */
    background:
      radial-gradient(720px 360px at 50% -80px, rgba(163, 190, 245, 0.30), transparent 70%),
      var(--mist);
  }
  
  /* --- header --- */
  
  .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(16px, 4vw, 32px);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand-logo { width: 38px; height: 38px; }
  .brand-text { display: flex; flex-direction: column; line-height: 1.25; }
  
  .brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
  }
  
  .brand-tag { color: var(--muted); font-size: 0.74rem; }
  
  /* --- thread --- */
  
  .chat-scroll { flex: 1; overflow-y: auto; }
  
  .chat-thread {
    width: min(var(--col), 100%);
    margin: 0 auto;
    padding: 32px clamp(16px, 4vw, 24px) 24px;
    display: flex;
    flex-direction: column;
    gap: 26px;
  }
  
  /* welcome state */
  
  .welcome {
    text-align: center;
    padding: 8vh 8px 12px;
  }
  
  .welcome-logo { width: 60px; height: 60px; margin: 0 auto 18px; }
  
  .welcome-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2rem);
    letter-spacing: -0.02em;
    margin: 0 0 10px;
  }
  
  .welcome-sub {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 46ch;
    margin: 0 auto 26px;
  }
  
  .suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  
  .suggestion {
    padding: 10px 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  }
  
  .suggestion:hover {
    border-color: var(--red);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(38, 37, 42, 0.08);
  }
  
  /* messages */
  
  @keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  
  .msg { animation: msg-in 0.25s ease both; }
  
  /* user message: dark pill, right aligned */
  .msg-user {
    align-self: flex-end;
    max-width: 85%;
    background: var(--ink);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    padding: 11px 16px;
    font-size: 0.94rem;
    line-height: 1.55;
    box-shadow: var(--shadow-sm);
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }
  
  /* bot message: avatar + rich text directly on the page */
  .msg-bot {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    max-width: 100%;
  }
  
  .msg-avatar {
    flex: none;
    width: 34px;
    height: 34px;
    padding: 5px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
  }
  
  .msg-avatar img { width: 100%; height: 100%; }
  
  .msg-content { min-width: 0; flex: 1; padding-top: 4px; }
  
  /* rich answer text */
  
  .msg-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ink-soft);
    overflow-wrap: break-word;
  }
  
  .msg-text p { margin: 0 0 12px; }
  .msg-text p:last-child { margin-bottom: 0; }
  
  .msg-text ol,
  .msg-text ul {
    margin: 0 0 12px;
    padding-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .msg-text li::marker { color: var(--red); font-weight: 600; }
  
  .msg-text strong { color: var(--ink); font-weight: 600; }
  
  .msg-text code {
    background: #eef0f6;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.85em;
  }
  
  /* typing dots */
  
  .typing { display: inline-flex; gap: 5px; padding: 8px 0; }
  
  .typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    opacity: 0.4;
    animation: bounce 1.1s infinite;
  }
  
  .typing i:nth-child(2) { animation-delay: 0.15s; }
  .typing i:nth-child(3) { animation-delay: 0.3s; }
  
  @keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-5px); opacity: 1; }
  }
  
  /* sources */
  
  .sources-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 16px 0 8px;
  }
  
  .msg-sources { display: flex; flex-wrap: wrap; gap: 8px; }
  
  .source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    font-size: 0.79rem;
    font-weight: 500;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, color 0.15s ease;
  }
  
  .source-chip:hover { border-color: var(--red); color: var(--ink); }
  
  .source-chip img { width: 13px; height: 13px; opacity: 0.7; }
  
  .source-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 280px;
    text-transform: capitalize;
  }
  
  /* follow-up suggestions */

  .followups {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
  }

  .followups-label {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.92rem;
    margin-bottom: 12px;
  }

  .followups-list { display: flex; flex-wrap: wrap; gap: 10px; }

  .followup {
    padding: 9px 18px;
    background: var(--paper);
    border: 1px solid #d5d9e2;
    border-radius: 999px;
    font-size: 0.88rem;
    color: var(--ink-soft);
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease;
  }

  .followup:hover { border-color: var(--red); background: var(--mist); }

  /* error */
  
  .msg-error .msg-text {
    color: var(--red-dark);
    background: #fdf1f1;
    border: 1px solid rgba(232, 38, 45, 0.35);
    border-radius: 12px;
    padding: 10px 14px;
  }
  
  /* --- input bar --- */
  
  .chat-inputbar {
    padding: 8px clamp(16px, 4vw, 24px) 14px;
    background: linear-gradient(to top, var(--mist) 60%, transparent);
  }
  
  .chat-form {
    width: min(var(--col), 100%);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 8px 8px 8px 20px;
    box-shadow: var(--shadow-lg);
    transition: border-color 0.15s ease;
  }
  
  .chat-form:focus-within { border-color: var(--red); }
  
  #chat-input {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ink);
    background: transparent;
    max-height: 140px;
    padding: 8px 0;
  }
  
  #chat-input::placeholder { color: var(--muted); }
  
  .btn-send {
    flex: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  }
  
  .btn-send:hover { background: var(--red-dark); }
  .btn-send:active { transform: scale(0.95); }
  .btn-send:disabled { opacity: 0.45; cursor: not-allowed; }
  
  .inputbar-note {
    width: min(var(--col), 100%);
    margin: 8px auto 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.72rem;
  }
  
  /* motion preference */
  
  @media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
  }
  
  /* small screens */
  
  @media (max-width: 520px) {
    .brand-tag { display: none; }
    .msg-user { max-width: 92%; }
    .msg-avatar { width: 30px; height: 30px; }
    .login-card { padding: 32px 22px 22px; }
    .welcome { padding-top: 5vh; }
  }
  
  /* markdown headings inside answers */
  .msg-text .md-h {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin: 16px 0 8px;
  }
  
  .msg-text .md-h:first-child { margin-top: 0; }
  
  /* nested bullets inside numbered steps */
  .msg-text ol > li { font-weight: 600; color: var(--ink); }
  .msg-text ol > li > ul {
    font-weight: 400;
    color: var(--ink-soft);
    margin: 6px 0 2px;
    padding-left: 18px;
  }