/* ============================================================
   Oilsoft Support — UI
   Industrial palette: petrol-navy + safety-amber accent.
   ============================================================ */
:root {
  --navy-900: #0B2239;
  --navy-800: #10314f;
  --navy-700: #1b4068;
  --accent:   #F59E0B;
  --accent-600: #D97706;

  --bg:       #eef2f6;
  --surface:  #ffffff;
  --text:     #0f172a;
  --muted:    #64748b;
  --border:   #e2e8f0;

  --bot-bubble: #f1f5f9;
  --ok-bg: #ecfdf5; --ok-fg: #065f46; --ok-bd: #a7f3d0;
  --err-bg: #fef2f2; --err-fg: #b91c1c; --err-bd: #fecaca;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 34, 57, .12);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* The .auth/.app views set `display: flex`, which would otherwise override the
   `hidden` attribute (author rules beat the UA `[hidden]{display:none}`), leaving
   both the login and chat screens rendered stacked. Keep `hidden` authoritative. */
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand--stack { flex-direction: column; gap: 14px; text-align: center; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-weight: 700; font-size: 15px; }
.brand__sub  { font-size: 12px; color: var(--muted); }
.brand__status { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.brand__status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .25);
}
#userName::before { content: " · "; }

/* ============================================================
   LOGIN
   ============================================================ */
.auth {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--navy-700), transparent 60%),
    linear-gradient(160deg, var(--navy-900), #081a2c);
}
.auth__card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex; flex-direction: column;
}
.auth__heading { margin: 18px 0 4px; font-size: 22px; text-align: center; }
.auth__lede { margin: 0 0 22px; color: var(--muted); font-size: 14px; text-align: center; }
.auth__form { display: flex; flex-direction: column; gap: 14px; }
.auth__error { color: var(--err-fg); font-size: 13px; min-height: 18px; text-align: center; }
.auth__footer { margin: 22px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: #334155; }
.field input {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font: inherit; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .2);
}

/* ---------- Buttons ---------- */
.btn { border: none; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; padding: 11px 16px; }
.btn--primary { background: var(--accent); color: #1f1300; }
.btn--primary:hover { background: var(--accent-600); }
.btn--primary:disabled { opacity: .55; cursor: default; }
.btn--block { width: 100%; }

/* ============================================================
   CHAT APP SHELL
   ============================================================ */
.app {
  display: flex; flex-direction: column;
  width: min(760px, 100%);
  height: 100vh;
  margin: 0 auto;
  background: var(--surface);
}
@media (min-width: 800px) {
  .app {
    height: calc(100vh - 40px);
    margin: 20px auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-900));
}
.topbar .brand__sub, .topbar .brand__status { color: rgba(255, 255, 255, .8); }
.topbar__actions { display: flex; gap: 6px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: transparent; border: none; cursor: pointer; color: #fff;
  transition: background .15s;
}
.iconbtn:hover { background: rgba(255, 255, 255, .12); }
.iconbtn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Message log ---------- */
.log {
  flex: 1; overflow-y: auto; padding: 20px 18px;
  display: flex; flex-direction: column; gap: 14px;
  background:
    radial-gradient(600px 200px at 100% 0, rgba(27, 64, 104, .04), transparent 70%);
  scroll-behavior: smooth;
}
.log::-webkit-scrollbar { width: 10px; }
.log::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 3px solid var(--surface); }

.msg { display: flex; gap: 10px; max-width: 88%; animation: rise .22s ease both; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }
.msg--bot  { align-self: flex-start; }

.msg__avatar {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.msg--bot .msg__avatar { background: var(--navy-900); }
.msg--bot .msg__avatar svg { width: 18px; height: 18px; }
.msg--user .msg__avatar { background: var(--accent); color: #1f1300; }

.msg__bubble {
  padding: 11px 14px; border-radius: 14px; line-height: 1.5;
  font-size: 14.5px; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg--bot .msg__bubble { background: var(--bot-bubble); color: var(--text); border-top-left-radius: 5px; }
.msg--user .msg__bubble { background: var(--navy-800); color: #fff; border-top-right-radius: 5px; }
.msg__bubble.is-error { background: var(--err-bg); color: var(--err-fg); border: 1px solid var(--err-bd); }

/* rich content inside bot bubbles */
.msg__bubble p { margin: 0 0 8px; }
.msg__bubble p:last-child { margin-bottom: 0; }
.msg__bubble ul, .msg__bubble ol { margin: 6px 0; padding-left: 20px; }
.msg__bubble li { margin: 3px 0; }
.msg__bubble code { background: rgba(15, 34, 57, .08); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.msg__bubble a { color: var(--accent-600); font-weight: 600; }

/* system / ticket notice */
.msg--system { align-self: center; max-width: 92%; }
.msg__system {
  background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-bd);
  font-size: 13px; padding: 8px 14px; border-radius: 999px;
}

/* typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }

/* ---------- Suggested prompts ---------- */
.suggest { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 88%; margin-left: 40px; }
.chip {
  border: 1px solid var(--border); background: #fff; color: #1e293b;
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px;
  cursor: pointer; transition: border-color .15s, background .15s, transform .05s;
}
.chip:hover { border-color: var(--accent); background: #fff8ec; }
.chip:active { transform: translateY(1px); }

/* ---------- Composer ---------- */
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 14px 14px; }
.composer__note { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); text-align: center; }
.composer__row { display: flex; gap: 10px; align-items: flex-end; }
.composer__row textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; font: inherit; line-height: 1.45; max-height: 160px;
  transition: border-color .15s, box-shadow .15s;
}
.composer__row textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .18);
}
.composer__send {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; border: none;
  background: var(--accent); color: #1f1300; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.composer__send:hover { background: var(--accent-600); }
.composer__send:disabled { opacity: .5; cursor: default; }
.composer__send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; }
  .typing i { animation: none; opacity: .5; }
  .log { scroll-behavior: auto; }
}
