/* =========================================================================
   Flemby Chat — neon glass UI
   Dark glassmorphism, aurora glow background, gradient accents.
   All class / id hooks match app.js; only the look changes.
   ========================================================================= */

:root {
  /* base surfaces */
  --bg-0:        #07070e;
  --bg-1:        #0b0b16;
  --ink:         #eceefb;
  --ink-soft:    #a3a7c4;
  --ink-faint:   #6b6f8d;

  /* glass */
  --glass:       rgba(255, 255, 255, 0.045);
  --glass-2:     rgba(255, 255, 255, 0.07);
  --glass-brd:   rgba(255, 255, 255, 0.10);
  --glass-brd-2: rgba(255, 255, 255, 0.16);

  /* neon accents */
  --violet:  #8b5cf6;
  --indigo:  #6366f1;
  --cyan:    #22d3ee;
  --pink:    #f472b6;
  --accent-grad:  linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #22d3ee 100%);
  --accent-grad2: linear-gradient(135deg, #f472b6 0%, #8b5cf6 60%, #6366f1 100%);
  --glow-violet: rgba(139, 92, 246, 0.55);
  --glow-cyan:   rgba(34, 211, 238, 0.45);

  --danger: #ff6b6b;

  --radius: 14px;
  --font:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
[hidden] { display: none !important; }

/* ---------- Aurora glow background ---------- */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
  will-change: transform;
}
body::before {
  width: 60vw; height: 60vw;
  top: -18vw; left: -12vw;
  background: radial-gradient(circle at 30% 30%, var(--violet), transparent 65%);
  animation: drift1 22s ease-in-out infinite alternate;
}
body::after {
  width: 55vw; height: 55vw;
  bottom: -20vw; right: -14vw;
  background: radial-gradient(circle at 70% 70%, var(--cyan), transparent 62%);
  animation: drift2 26s ease-in-out infinite alternate;
}
/* a fixed deep-space base sits under the blobs */
body { background:
  radial-gradient(140% 120% at 80% -10%, #14122b 0%, transparent 55%),
  radial-gradient(120% 120% at -10% 110%, #0a1626 0%, transparent 55%),
  var(--bg-0);
}
@keyframes drift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(8vw, 6vh) scale(1.15); }
}
@keyframes drift2 {
  from { transform: translate(0, 0) scale(1.05); }
  to   { transform: translate(-7vw, -5vh) scale(1); }
}

/* ---------- Brand ---------- */
.brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 19px;
  color: var(--ink);
}
.brand span {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Glass scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.5) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--violet), var(--cyan));
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-clip: border-box; }

/* =========================================================================
   Login
   ========================================================================= */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 22px;
  padding: 38px 32px;
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
/* glowing gradient ring around the card */
.login-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 23px;
  padding: 1px;
  background: var(--accent-grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.6;
  pointer-events: none;
}
.login-card .brand { font-size: 26px; }
.login-sub { margin: 8px 0 26px; color: var(--ink-soft); font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-brd);
  border-radius: 11px;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.7);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22), 0 0 22px -4px var(--glow-violet);
}

.btn-primary {
  position: relative;
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  font: 600 15px/1 var(--font);
  color: #fff;
  background: var(--accent-grad);
  background-size: 180% 180%;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px var(--glow-violet), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .15s, box-shadow .2s, background-position .4s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  background-position: 100% 0;
  box-shadow: 0 14px 38px -8px var(--glow-violet), 0 0 0 1px rgba(255,255,255,.08);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: default; transform: none; }

.login-error {
  margin: 16px 0 0;
  color: var(--danger);
  font-size: 14px;
  text-shadow: 0 0 16px rgba(255, 107, 107, 0.4);
}

/* =========================================================================
   App layout
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: 288px 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: relative;
  background: rgba(10, 10, 20, 0.55);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--glass-brd);
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
}
.btn-new {
  font: 600 13px/1 var(--font);
  color: #fff;
  background: var(--glass-2);
  border: 1px solid var(--glass-brd-2);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  transition: border-color .18s, box-shadow .2s, transform .15s;
}
.btn-new:hover {
  border-color: rgba(139, 92, 246, 0.8);
  box-shadow: 0 0 18px -4px var(--glow-violet);
  transform: translateY(-1px);
}

.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 11px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.3;
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s;
}
.conv-item:hover { background: var(--glass); color: var(--ink); }
.conv-item.active {
  background: var(--glass-2);
  color: #fff;
  border-color: var(--glass-brd);
}
/* glowing accent bar on the active conversation */
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 3px;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--glow-violet);
}
.conv-item .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-del {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 7px;
  transition: opacity .15s, color .15s, background .15s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: rgba(255, 107, 107, 0.12); }

/* monthly budget meter */
.usage {
  padding: 12px 16px 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.usage-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 500;
}
.usage-bar {
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent-grad);
  box-shadow: 0 0 12px -2px var(--glow-violet);
  transition: width .35s ease;
}
.usage-fill.over {
  background: linear-gradient(135deg, #ff6b6b, #f472b6);
  box-shadow: 0 0 12px -2px rgba(255, 107, 107, 0.6);
}
.usage-note { margin-top: 6px; color: var(--danger); }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--glass-brd);
}
.who { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.btn-ghost {
  font: 500 13px/1 var(--font);
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--glass-brd);
  border-radius: 9px;
  padding: 7px 11px;
  cursor: pointer;
  transition: border-color .18s, color .18s, box-shadow .2s;
}
.btn-ghost:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, 0.7);
  box-shadow: 0 0 16px -4px var(--glow-cyan);
}

/* =========================================================================
   Chat
   ========================================================================= */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;        /* allow the column to shrink so the composer stays visible */
  height: 100%;
  overflow: hidden;
  background: transparent;
  position: relative;
}
.messages {
  flex: 1 1 auto;
  min-height: 0;        /* let the scroll area shrink instead of pushing the composer off-screen */
  overflow-y: auto;
  padding: 30px 0 8px;
  scroll-behavior: smooth;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-soft);
  text-align: center;
  padding: 24px;
}
.empty-mark {
  font-family: var(--display);
  font-size: 38px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 40px rgba(139, 92, 246, 0.35);
}
.empty-mark span {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.empty-state p { max-width: 380px; margin: 0; font-size: 15px; line-height: 1.6; }

/* ---------- Messages ---------- */
.msg {
  max-width: 800px;
  margin: 0 auto;
  padding: 8px 24px 24px;
  display: flex;
  gap: 14px;
  animation: msgIn 0.4s cubic-bezier(.2,.8,.2,1) both;
}
.msg .avatar {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.msg.user .avatar {
  background: var(--accent-grad2);
  box-shadow: 0 0 18px -4px rgba(244, 114, 182, 0.6), inset 0 1px 0 rgba(255,255,255,.25);
}
.msg.assistant .avatar {
  background: var(--accent-grad);
  box-shadow: 0 0 18px -4px var(--glow-violet), inset 0 1px 0 rgba(255,255,255,.25);
}
.msg .body {
  min-width: 0;
  flex: 1;
  line-height: 1.7;
  font-size: 15.5px;
  color: var(--ink);
  word-wrap: break-word;
}
/* user text gets a subtle glass bubble; assistant text flows on the canvas */
.msg.user .body {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 14px;
  padding: 11px 16px;
  align-self: flex-start;
}
.msg .body > *:first-child { margin-top: 0; }
.msg .body > *:last-child { margin-bottom: 0; }
.msg .body p { margin: 0 0 12px; }
.msg .body ul, .msg .body ol { margin: 0 0 12px; padding-left: 22px; }
.msg .body li { margin: 4px 0; }
.msg .body h1, .msg .body h2, .msg .body h3 { margin: 18px 0 9px; line-height: 1.3; font-family: var(--display); }
.msg .body h1 { font-size: 1.4em; }
.msg .body h2 { font-size: 1.25em; }
.msg .body h3 { font-size: 1.1em; }
.msg .body a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(34, 211, 238, 0.4);
  transition: text-shadow .15s;
}
.msg .body a:hover { text-shadow: 0 0 12px var(--glow-cyan); }
.msg .body blockquote {
  margin: 0 0 12px; padding: 4px 16px;
  border-left: 3px solid var(--violet);
  color: var(--ink-soft);
  background: var(--glass);
  border-radius: 0 8px 8px 0;
}
.msg .body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(139, 92, 246, 0.14);
  color: #d6c8ff;
  padding: 2px 6px;
  border-radius: 6px;
}
.msg .body pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-brd);
  color: #e8e8f5;
  padding: 15px 17px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 0 0 12px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.3);
}
.msg .body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.86em;
  line-height: 1.6;
}
.cursor::after {
  content: "";
  display: inline-block;
  width: 9px; height: 1.05em;
  margin-left: 3px;
  vertical-align: text-bottom;
  border-radius: 2px;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--glow-violet);
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { opacity: 0; } }

/* =========================================================================
   Composer
   ========================================================================= */
.composer {
  flex: 0 0 auto;
  padding: 12px 16px 20px;
  background: linear-gradient(to top, var(--bg-0) 30%, transparent);
}
.composer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 18px;
  padding: 9px 9px 9px 16px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 12px 36px -12px rgba(0,0,0,0.6);
  transition: border-color .2s, box-shadow .25s;
}
.composer-inner:focus-within {
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18), 0 0 34px -10px var(--glow-violet);
}
#input {
  flex: 1;
  border: none;
  resize: none;
  outline: none;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.5;
  max-height: 200px;
  background: transparent;
  color: var(--ink);
  padding: 7px 0;
}
#input::placeholder { color: var(--ink-faint); }
.btn-send {
  flex: 0 0 auto;
  font: 600 14px/1 var(--font);
  color: #fff;
  background: var(--accent-grad);
  background-size: 160% 160%;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  box-shadow: 0 8px 22px -8px var(--glow-violet), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .15s, box-shadow .2s, background-position .4s, opacity .2s;
}
.btn-send:hover { transform: translateY(-1px); background-position: 100% 0; box-shadow: 0 12px 30px -8px var(--glow-violet); }
.btn-send:active { transform: translateY(0); }
.btn-send:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.composer-hint {
  max-width: 800px;
  margin: 10px auto 0;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}

/* =========================================================================
   Mobile
   ========================================================================= */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 30;
  width: 40px; height: 40px;
  border-radius: 11px;
  border: 1px solid var(--glass-brd);
  background: var(--glass-2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .messages { padding-top: 62px; }
  .msg { padding-left: 16px; padding-right: 16px; }
}

/* =========================================================================
   Chat header + model picker
   ========================================================================= */
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 20px;
  min-height: 56px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--glass-brd);
  background: rgba(7, 7, 14, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.model-picker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 13px;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  transition: border-color .18s, box-shadow .2s;
}
.model-picker:hover { border-color: var(--glass-brd-2); box-shadow: 0 0 18px -6px var(--glow-violet); }
.model-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 10px var(--glow-violet);
  animation: pulse 2.4s ease-in-out infinite;
}
.model-picker select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: 600 13.5px/1 var(--font);
  cursor: pointer;
  padding-right: 18px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: right 6px center, right 1px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.model-picker select option { background: #14121f; color: var(--ink); }

/* =========================================================================
   Attach button + attachment previews
   ========================================================================= */
.btn-attach {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--glass-brd);
  border-radius: 11px;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .2s, background .15s;
}
.btn-attach:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(34, 211, 238, 0.7);
  box-shadow: 0 0 18px -5px var(--glow-cyan);
}
.btn-attach:disabled { opacity: .35; cursor: not-allowed; }

.attachments {
  max-width: 800px;
  margin: 0 auto 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 4px;
}
.attach-thumb {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-brd-2);
  box-shadow: 0 6px 18px -6px rgba(0,0,0,.6);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
.attach-remove:hover { background: var(--danger); }

/* images inside a sent message */
.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-images img {
  max-width: 360px;
  max-height: 360px;
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--glass-brd);
  box-shadow: 0 6px 20px -8px rgba(0,0,0,.6);
  cursor: zoom-in;
  transition: transform .12s;
}
.msg-images img:hover { transform: scale(1.01); }

/* fullscreen image viewer */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.msg-text { white-space: pre-wrap; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* mobile: keep model picker clear of the fixed menu toggle */
@media (max-width: 760px) {
  .chat-head { padding-left: 60px; }
  .messages { padding-top: 14px; }
}

/* ---------- Motion / entrances ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  .sidebar, .messages { transition: none; scroll-behavior: auto; }
  .cursor::after,
  .login-card, .msg, .model-dot { animation: none; }
  .btn-primary, .btn-send, .btn-new, .conv-item { transition: none; }
}

/* =========================================================================
   Search, rename, conversation actions
   ========================================================================= */
.sidebar-search { padding: 4px 10px 8px; }
.sidebar-search input {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
}
.sidebar-search input::placeholder { color: var(--ink-faint); }
.sidebar-search input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.conv-act {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 7px;
  transition: opacity .15s, color .15s, background .15s;
}
.conv-item:hover .conv-act { opacity: 1; }
.conv-act:hover { color: var(--ink); background: var(--glass-2); }
.conv-del:hover { color: var(--danger); background: rgba(255, 107, 107, 0.12); }
.conv-rename {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-brd-2);
  border-radius: 7px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 4px 7px;
}
.conv-rename:focus { outline: none; border-color: rgba(139, 92, 246, 0.7); }
.foot-actions { display: flex; gap: 8px; align-items: center; }

/* =========================================================================
   Chat-head export, Stop button, message + code actions
   ========================================================================= */
.head-btn {
  font: 600 12.5px/1 var(--font);
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color .18s, color .18s, box-shadow .2s;
}
.head-btn:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 16px -5px var(--glow-cyan);
}
.btn-send.is-stop {
  background: linear-gradient(135deg, #ff6b6b, #f472b6);
  box-shadow: 0 8px 22px -8px rgba(255, 107, 107, 0.6);
}
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .15s;
}
.msg:hover .msg-actions,
.msg.assistant.is-last .msg-actions { opacity: 1; }
.act-btn {
  font: 500 12px/1 var(--font);
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.act-btn:hover { color: #fff; border-color: var(--glass-brd-2); }
.act-regen { display: none; }
.msg.assistant.is-last .act-regen { display: inline-flex; }
.msg .body pre { position: relative; }
.code-copy {
  position: absolute;
  top: 8px; right: 8px;
  font: 500 11px/1 var(--font);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-brd);
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.msg .body pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: #fff; }

/* =========================================================================
   Admin modal
   ========================================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  overflow: auto;
  background: rgba(14, 14, 26, 0.94);
  border: 1px solid var(--glass-brd-2);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise .35s cubic-bezier(.2,.8,.2,1) both;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--glass-brd);
}
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 18px; }
.modal-close {
  background: transparent; border: none; color: var(--ink-soft);
  font-size: 18px; cursor: pointer; border-radius: 8px; padding: 4px 8px;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 18px 22px 22px; }
.add-user { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.add-user input {
  flex: 1; min-width: 130px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  color: var(--ink); font: inherit; font-size: 14px; padding: 10px 12px;
}
.add-user input:focus { outline: none; border-color: rgba(139, 92, 246, 0.6); }
.au-btn { width: auto; margin: 0; padding: 10px 16px; flex: 0 0 auto; }
.admin-error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th {
  text-align: left; color: var(--ink-soft); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--glass-brd);
}
.admin-table td { padding: 10px; border-bottom: 1px solid var(--glass-brd); vertical-align: middle; }
.admin-table tr.row-disabled { opacity: 0.55; }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 6px; background: var(--accent-grad); color: #fff;
}
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-btn {
  font: 500 12px/1 var(--font);
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
}
.admin-btn:hover { color: #fff; border-color: var(--glass-brd-2); }

/* model on/off toggles in the admin panel */
.admin-models { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  background: var(--glass);
}
.model-row.off { opacity: 0.6; }
.model-row .model-name { font-size: 13.5px; font-weight: 500; }
.toggle-btn {
  flex: 0 0 auto;
  min-width: 52px;
  font: 600 12px/1 var(--font);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  border: 1px solid var(--glass-brd-2);
  transition: filter .15s;
}
.toggle-btn.on { background: linear-gradient(135deg, #22d3ee, #4ade80); color: #04210f; border-color: transparent; }
.toggle-btn.off { background: rgba(255,255,255,0.06); color: var(--ink-soft); }
.toggle-btn:hover { filter: brightness(1.1); }

/* =========================================================================
   Bots (header picker + manage modal)
   ========================================================================= */
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quality-ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  font-size: 13px;
}
.quality-ctl select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: 600 13px/1 var(--font);
  cursor: pointer;
  padding-right: 4px;
}
.quality-ctl select option { background: #14121f; color: var(--ink); }
.bot-picker { display: inline-flex; align-items: center; gap: 8px; }
.bot-picker select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  color: var(--ink);
  font: 600 13px/1 var(--font);
  cursor: pointer;
  padding: 9px 28px 9px 13px;
  max-width: 200px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: right 12px center, right 7px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.bot-picker select:hover { border-color: var(--glass-brd-2); }
.bot-picker select option { background: #14121f; color: var(--ink); }

.bot-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.bot-form input,
.bot-form textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
}
.bot-form input:focus,
.bot-form textarea:focus { outline: none; border-color: rgba(139, 92, 246, 0.6); }
.bot-form-actions { display: flex; gap: 8px; }
.bot-form-actions .au-btn { margin: 0; }
.bots-list { display: flex; flex-direction: column; gap: 8px; }
.bot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  background: var(--glass);
}
.bot-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bot-info strong { font-size: 14px; }
.bot-info span { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-row-acts { display: flex; gap: 6px; flex: 0 0 auto; }

/* =========================================================================
   Language toggle, quick actions, starters, settings
   ========================================================================= */
.foot-actions { flex-wrap: wrap; }
.icon-btn { padding: 6px 9px; }
.lang-toggle { min-width: 36px; font-weight: 600; }
.login-lang { position: absolute; top: 16px; inset-inline-end: 16px; }

.quick-actions {
  max-width: 800px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px;
}
.qa-chip {
  font: 500 12.5px/1 var(--font);
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .2s;
}
.qa-chip:hover {
  color: #fff;
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 16px -6px var(--glow-violet);
}

.starters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
  max-width: 540px;
}
.starter-chip {
  font: 500 13px/1.35 var(--font);
  color: var(--ink);
  text-align: start;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .2s, transform .12s;
}
.starter-chip:hover {
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 22px -8px var(--glow-violet);
  transform: translateY(-1px);
}

.settings-sec {
  font-family: var(--display);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 22px 0 12px;
}
.modal-body .settings-sec:first-child { margin-top: 4px; }
.settings-field { display: block; margin-bottom: 14px; }
.settings-field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.settings-field select,
.settings-field textarea,
.settings-pw input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
}
.settings-field select:focus,
.settings-field textarea:focus,
.settings-pw input:focus { outline: none; border-color: rgba(139, 92, 246, 0.6); }
.settings-field select option { background: #14121f; }
.settings-btn { width: auto; margin: 0 0 8px; padding: 10px 16px; }
.settings-pw { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.settings-msg { font-size: 13px; color: var(--danger); margin: 8px 0 0; }
.settings-msg.ok { color: #4ade80; }

/* ---------- Persian font + RTL ---------- */
html[lang="fa"] body,
html[lang="fa"] input,
html[lang="fa"] textarea,
html[lang="fa"] button,
html[lang="fa"] select { font-family: "Vazirmatn", var(--font); }

@media (max-width: 760px) {
  html[dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  html[dir="rtl"] .menu-toggle { left: auto; right: 12px; }
  html[dir="rtl"] .chat-head { padding-left: 20px; padding-right: 60px; }
}
