/* PESARES Agent Hub - radar-style UI (Outfit, teal #00c8a0, dark/light + animated bg) */

:root {
  --bg: #0a0e1a;
  --panel: #12121c;
  --line: #2a2a3a;
  --text: #e8e8ee;
  --muted: #7a8599;
  --dim: #555566;
  --teal: #00c8a0;
  --teal-b: #00e6b8;
  --red: #e05555;
  --orange: #f5a623;
  --noise-opacity: .35;
  --mesh-1: rgba(0,200,160,.07);
  --mesh-2: rgba(0,230,184,.04);
  --mesh-3: rgba(245,166,35,.03);
  --shape-color: rgba(0,200,160,.06);
  --font-scale: 1;
}

:root[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #dbe2eb;
  --text: #1a1f2e;
  --muted: #5a6478;
  --dim: #8b94a3;
  --teal: #00a685;
  --teal-b: #00c8a0;
  --noise-opacity: .08;
  --mesh-1: rgba(0,166,133,.08);
  --mesh-2: rgba(0,200,160,.05);
  --mesh-3: rgba(245,166,35,.04);
  --shape-color: rgba(0,166,133,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
html { font-size: calc(16px * var(--font-scale)); }
body {
  font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  position: relative; overflow: hidden;
}

body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 30%, var(--mesh-1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, var(--mesh-2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, var(--mesh-3) 0%, transparent 50%);
}

body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/></svg>");
}

.shape {
  position: fixed; z-index: -1; pointer-events: none;
  border: 1px solid var(--shape-color); border-radius: 30%;
  animation: shapeFloat 20s infinite ease-in-out;
}
.shape--1 { width: 340px; height: 340px; top: -80px; left: -80px; animation-delay: 0s; }
.shape--2 { width: 240px; height: 240px; top: 60%; right: -60px; animation-delay: 5s; border-radius: 50%; }
.shape--3 { width: 180px; height: 180px; bottom: -40px; left: 30%; animation-delay: 10s; border-radius: 20%; }
.shape--4 { width: 280px; height: 280px; top: 20%; right: 15%; animation-delay: 15s; border-radius: 40%; }
@keyframes shapeFloat {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  25% { transform: translate(30px,-20px) rotate(90deg); }
  50% { transform: translate(-20px,40px) rotate(180deg); }
  75% { transform: translate(40px,20px) rotate(270deg); }
}
@media (max-width: 640px) {
  .shape--3,.shape--4 { display: none; }
  .shape--1 { width: 220px; height: 220px; }
  .shape--2 { width: 180px; height: 180px; }
}

/* ─── Login screen ─────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 5;
}
.login-card {
  max-width: 460px; width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 48px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.login-logo {
  font-size: 28px; font-weight: 700; letter-spacing: 3px;
  margin-bottom: 6px;
}
.brand-dot { color: var(--teal); }
.login-subtitle { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.login-blurb { color: var(--muted); margin-bottom: 32px; line-height: 1.55; }
.login-btn {
  display: inline-block; padding: 14px 30px;
  background: linear-gradient(135deg, var(--teal), var(--teal-b));
  color: #08080d; text-decoration: none; font-weight: 700;
  border-radius: 8px; letter-spacing: 0.3px;
  transition: transform 0.15s, box-shadow 0.2s;
}
.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,200,160,0.3);
}
.login-foot { margin-top: 24px; font-size: 12px; color: var(--dim); }
.login-foot a { color: var(--teal); text-decoration: none; }

/* ─── App layout ──────────────────────────────────────── */
.app-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app-header { flex-shrink: 0; }
.app-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(10,22,40,0.92) 0%, rgba(17,24,39,0.92) 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
:root[data-theme="light"] .app-header {
  background: linear-gradient(135deg, rgba(224,238,248,0.92) 0%, rgba(240,244,250,0.92) 100%);
}
.app-brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.wordmark { font-size: calc(18px * var(--font-scale)); font-weight: 700; letter-spacing: 2px; color: var(--text); }
.sub { font-size: calc(12px * var(--font-scale)); color: var(--muted); margin-left: 4px; }
.app-controls { display: flex; align-items: center; gap: 8px; }
.ctl-grp { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: rgba(0,0,0,0.25); }
:root[data-theme="light"] .ctl-grp,
:root[data-theme="light"] .ctl-btn--icon { background: rgba(255,255,255,0.7); }
.ctl-btn {
  background: transparent; border: 0; color: var(--muted);
  padding: 7px 11px; font-family: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.ctl-btn + .ctl-btn { border-left: 1px solid var(--line); }
.ctl-btn:hover { color: var(--teal); }
.ctl-btn--icon { border: 1px solid var(--line); border-radius: 6px; padding: 7px 11px; font-size: 14px; }
.ctl-btn--portal {
  border: 1px solid rgba(0,200,160,0.35);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--teal);
  text-decoration: none;
  background: rgba(0,200,160,0.05);
  letter-spacing: 0.3px;
  transition: background 0.15s, border-color 0.15s;
}
.ctl-btn--portal:hover { background: rgba(0,200,160,0.12); border-color: var(--teal); }
:root[data-theme="light"] .ctl-btn--portal { background: rgba(0,200,160,0.10); }
.me-chip {
  font-size: 12px; padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,200,160,0.10);
  border: 1px solid rgba(0,200,160,0.25);
  color: var(--teal); font-weight: 600;
}

.app-body { flex: 1; display: grid; grid-template-columns: 240px 1fr; min-height: 0; position: relative; }

/* Hamburger samo na mobile */
.js-mobile-menu { display: none; }
.app-sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .js-mobile-menu { display: inline-flex; margin-right: 8px; }
  .app-body { grid-template-columns: 1fr; }
  .app-main { min-width: 0; overflow-x: hidden; width: 100%; }
  /* Sidebar postaje slide-in drawer */
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(85vw, 320px); max-width: 320px;
    z-index: 90; background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 2px 0 20px rgba(0,0,0,0.35);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 89; opacity: 0; pointer-events: none;
    transition: opacity 0.22s ease-out;
  }
  .app-sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

  /* Feed-first mod: composer NA VRH ispod headera, stream raste prema dnu */
  .app-main.feed-mode {
    display: flex; flex-direction: column;
  }
  .app-main.feed-mode .composer-tools,
  .app-main.feed-mode .reply-bar,
  .app-main.feed-mode .composer {
    order: 1;
  }
  .app-main.feed-mode .stream-header { order: 0; }
  .app-main.feed-mode .stream { order: 2; flex: 1; }
  .app-main.feed-mode .typing-bar { order: 3; }

  /* Composer scroll/grow protection na mobilnom */
  #composer-input { max-height: 30vh; }
}

.app-sidebar {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto;
}
.ws-switch { margin-bottom: 18px; }
.ws-switch label { display: block; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.ws-switch select {
  width: 100%; padding: 8px 10px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 13px;
}
.channels-title {
  font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.8px;
  margin: 18px 0 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.channel-list, .task-list-mini, .file-list { list-style: none; }
.channel-list li, .task-list-mini li, .file-list li {
  padding: 7px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s;
}
.channel-list li:hover, .task-list-mini li:hover, .file-list li:hover { background: rgba(0,200,160,0.06); }
.channel-list li.is-active { background: rgba(0,200,160,0.12); color: var(--teal); font-weight: 600; }
.channel-list li .ch-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-list li.has-unread .ch-label { font-weight: 600; color: var(--text); }
.channel-list li .unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: var(--teal);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  line-height: 1;
}
/* Agent typing dots u sidebar - per-channel indikator da agent radi.
   Jedan dot u boji agenta. Vise dot-ova ako >1 agent paralelno radi. */
.channel-list li .agent-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.channel-list li .agent-typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: agentTypingPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 currentColor;
}
@keyframes agentTypingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.75); }
}
.task-list-mini li {
  font-size: 12.5px; color: var(--muted);
  border-left: 2px solid var(--teal);
  padding-left: 8px; margin-bottom: 4px;
  border-radius: 3px;
}

/* Files sidebar section */
.files-mini { margin-top: 4px; }
.files-add-btn {
  background: transparent; border: 1px solid var(--line); color: var(--dim);
  width: 18px; height: 18px; border-radius: 4px; padding: 0;
  font-size: 14px; line-height: 1; cursor: pointer;
  transition: all .15s;
}
.files-add-btn:hover { color: var(--teal); border-color: var(--teal); }
.file-list { margin: 0; padding: 0; }
.file-list li {
  font-size: 12.5px; color: var(--text);
  position: relative; padding-left: 22px;
}
.file-list li::before {
  content: "📄"; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  font-size: 11px; opacity: .75;
}
.file-list li.is-global::before { content: "🌐"; }
.file-list .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { font-size: 10px; color: var(--dim); }

/* File modal */
/* Setting edit modal mora biti iznad settings modala (koji ga otvara) */
#setting-edit-modal { z-index: 200; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex;
         align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative; z-index: 1;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 24px;
  width: 100%; max-width: 800px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}
.modal__close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: none; color: var(--dim);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.modal__close:hover { color: var(--text); }
.modal__panel h3 { margin: 0 0 16px 0; font-size: 16px; color: var(--text); }

.file-modal__meta { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.file-modal__row { display: flex; align-items: center; gap: 10px; }
.file-modal__row label { width: 80px; color: var(--muted); font-size: 12.5px; flex-shrink: 0; }
.file-modal__row input, .file-modal__row select {
  flex: 1; padding: 6px 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); border-radius: 6px;
  font: inherit; font-size: 13px;
}
.file-modal__row input:focus, .file-modal__row select:focus {
  outline: none; border-color: var(--teal);
}
#file-modal-content {
  flex: 1; min-height: 280px;
  padding: 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text);
  font: 13px ui-monospace, "SF Mono", Menlo, monospace; line-height: 1.5;
  resize: vertical;
}
#file-modal-content:focus { outline: none; border-color: var(--teal); }
.file-modal__actions {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
}
.file-modal__info { flex: 1; font-size: 11.5px; color: var(--dim); }
.btn { padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; border: 1px solid var(--line); background: transparent; color: var(--text); transition: all .15s; }
.btn:hover { border-color: var(--teal); }
.btn--primary { background: var(--teal); color: var(--bg); border-color: var(--teal); font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--secondary { color: var(--muted); }
.btn--danger { color: #e05555; border-color: rgba(224,85,85,.4); }
.btn--danger:hover { background: rgba(224,85,85,.1); }

/* Channel instructions modal textareas */
#ci-system-prompt, #ci-agent-prompt {
  width: 100%; min-height: 220px; margin-top: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text);
  font: 13px ui-monospace, "SF Mono", Menlo, monospace; line-height: 1.5;
  resize: vertical;
}
#ci-system-prompt:focus, #ci-agent-prompt:focus { outline: none; border-color: var(--teal); }

/* Help modal */
.modal__panel--wide { max-width: 920px; }
.help-tabs {
  display: flex; gap: 4px; margin: -8px -8px 16px -8px; padding: 4px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.help-tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 6px 6px 0 0; cursor: pointer;
  font: inherit; font-size: 12.5px;
  transition: all .15s;
}
.help-tab:hover { color: var(--text); background: rgba(0,200,160,0.04); }
.help-tab.is-active {
  color: var(--teal); border-color: var(--line); border-bottom-color: var(--surface);
  font-weight: 600;
}
.help-body { overflow-y: auto; max-height: 65vh; padding: 4px 6px 8px 6px; }
.help-pane { display: none; }
.help-pane.is-active { display: block; }
.help-pane h4 { margin: 18px 0 8px 0; color: var(--text); font-size: 14px; }
.help-pane h4:first-child { margin-top: 4px; }
.help-pane p { margin: 8px 0; line-height: 1.6; color: var(--text); font-size: 13.5px; }
.help-pane ol, .help-pane ul { margin: 8px 0; padding-left: 22px; line-height: 1.7; font-size: 13px; }
.help-pane code { background: rgba(0,200,160,0.10); color: var(--teal); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }
.help-pane kbd {
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px;
  padding: 1px 6px; border-radius: 4px; font-size: 11.5px; font-family: ui-monospace, Menlo;
}
.help-dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: 13px; }
.help-dl dt { font-weight: 600; color: var(--teal); }
.help-dl dd { margin: 0; color: var(--text); line-height: 1.55; }

/* Reply bar iznad composer-a */
.reply-bar {
  display: none; align-items: center; gap: 10px;
  padding: 6px 14px; background: rgba(0,200,160,0.06);
  border-left: 3px solid var(--teal); margin: 0 14px;
  font-size: 12.5px; color: var(--muted);
}
.reply-bar.is-active { display: flex; }
.reply-bar__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar__cancel {
  background: transparent; border: none; color: var(--dim);
  cursor: pointer; font-size: 18px; padding: 0 4px;
}
.reply-bar__cancel:hover { color: var(--text); }

/* Time grupisanje + msg-author hover (click-to-tag) */
.msg.is-grouped { padding-top: 2px; }
.msg.is-grouped .msg-head { display: none; }
.msg-author { cursor: pointer; }
.msg-author:hover { text-decoration: underline; }

/* @all + reply dugme u msg actions */
.msg { position: relative; }
.msg-actions {
  display: none; gap: 4px; align-items: center;
}
.msg:hover .msg-actions { display: flex; }
.msg-action {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 2px 8px; border-radius: 4px; font-size: 11px; cursor: pointer;
  transition: all .12s;
}
.msg-action:hover { color: var(--teal); border-color: var(--teal); }

/* Msg attachments u stream-u */
.msg-attachments {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 8px;
}
.msg-attach {
  display: inline-block; max-width: 240px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--bg); text-decoration: none; color: var(--text);
  transition: border-color .15s;
}
.msg-attach:hover { border-color: var(--teal); }
.msg-attach--img { padding: 0; line-height: 0; }
.msg-attach--img img { max-width: 240px; max-height: 240px; display: block; }
.msg-attach--file { padding: 6px 12px; font-size: 12.5px; }

/* Mention dugmadi pored Task checkbox-a */
.composer-mentions {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.composer-tools__btn {
  background: rgba(0,200,160,0.05); border: 1px solid var(--line);
  color: var(--muted); padding: 3px 9px; border-radius: 12px;
  font-size: 11.5px; cursor: pointer; transition: all .12s;
  font-family: inherit;
}
.composer-tools__btn:hover { color: var(--teal); border-color: var(--teal); }
.composer-tools__btn[data-mention="all"] {
  font-weight: 700; color: var(--teal); border-color: rgba(0,200,160,.3);
}

/* Composer pasted image previews */
.composer-attachments {
  display: flex; gap: 8px; padding: 0 14px;
  flex-wrap: wrap;
}
.composer-attachments:empty { display: none; }
.composer-attachment {
  position: relative;
  width: 96px; height: 96px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg);
}
.composer-attachment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.composer-attachment__remove {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; padding: 0;
  background: rgba(0,0,0,.7); color: #fff;
  border: none; border-radius: 50%;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.composer-attachment__remove:hover { background: rgba(224,85,85,.85); }

/* ─── Main pane ──────────────────────────────────────── */
.app-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-x: hidden; }
/* Feed mod: composer ide na vrh, stream raste odgore prema dolje */
.app-main.feed-mode { flex-direction: column; }
.app-main.feed-mode .composer { order: -2; border-top: none; border-bottom: 1px solid var(--line); }
.app-main.feed-mode .typing-bar { order: -1; border-bottom: 1px dashed var(--line); }
.stream-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.channel-name { font-size: 16px; font-weight: 700; }
.stream-status {
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: rgba(224,85,85,0.10); color: var(--red);
  border: 1px solid rgba(224,85,85,0.25);
}
.stream-status.is-online { background: rgba(0,200,160,0.10); color: var(--teal); border-color: rgba(0,200,160,0.25); }
#stay-in-channel-btn.is-active { color: var(--teal); border-color: rgba(0,200,160,0.5); background: rgba(0,200,160,0.12); }

.stream-wrap { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stream {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 20px;
  display: flex; flex-direction: column-reverse; gap: 10px;
}
.stream[data-mode="feed"] { flex-direction: column; }
.stream-pill {
  position: absolute; right: 16px;
  background: var(--teal); color: #0a1612;
  border: none; border-radius: 999px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,200,160,.35);
  cursor: pointer; z-index: 5;
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease;
}
.stream-pill:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,200,160,.45); }
.stream-pill--newmsgs { bottom: 18px; }
.gate-passed-hint {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; margin: 2px 0;
  color: var(--muted); font-size: 11.5px; font-style: italic;
  opacity: 0; animation: gpFade 4s ease-out forwards;
}
.gate-passed-hint .gpdot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
@keyframes gpFade {
  0% { opacity: 0; transform: translateY(4px); }
  10%, 80% { opacity: 0.7; transform: translateY(0); }
  100% { opacity: 0; }
}
/* Settings modal tabs */
.settings-tab {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; transition: all .15s ease;
}
.settings-tab:hover { color: var(--fg); background: rgba(0,200,160,.05); }
.settings-tab.is-active { color: var(--teal); border-bottom-color: var(--teal); }
.settings-section { display: none; }
.settings-section.is-active { display: block; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.settings-table th, .settings-table td {
  padding: 6px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.05);
}
.settings-table th { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.settings-table tr:hover { background: rgba(0,200,160,.04); }
.settings-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10.5px; font-weight: 600;
}
.settings-badge--active { background: rgba(0,200,160,.18); color: var(--teal); }
.settings-badge--inactive { background: rgba(255,107,107,.12); color: #ff6b6b; }
.settings-kb-scope-chip {
  display: inline-block; padding: 2px 8px; margin: 2px 3px;
  background: rgba(124,92,255,.15); color: #c4b3ff;
  border-radius: 10px; font-size: 10.5px;
}
.me-chip { cursor: pointer; user-select: none; transition: background .15s ease, color .15s ease; }
.me-chip:hover { background: rgba(0,200,160,.22); color: var(--teal); }
.me-chip:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.msg--highlight {
  animation: msgHighlightPulse 1.5s ease-out;
}
@keyframes msgHighlightPulse {
  0%   { background: rgba(0,200,160,.30); }
  50%  { background: rgba(0,200,160,.18); }
  100% { background: rgba(0,200,160,.02); }
}
.msg {
  background: rgba(0,200,160,.02);
  border: 1px solid rgba(0,200,160,.08);
  border-left: 3px solid var(--msg-accent, rgba(0,200,160,.4));
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0; width: 100%; box-sizing: border-box;
}
/* User vs agent vizuelno različito: user dobija blagi teal background tint */
.msg--user {
  background: linear-gradient(90deg, rgba(0,200,160,.06) 0%, rgba(0,200,160,.02) 60%);
}
.msg--agent {
  background: rgba(255,255,255,.015);
}
.msg-head { display: flex; align-items: center; gap: 8px; font-size: calc(12.5px * var(--font-scale, 1)); }
.msg-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--msg-accent, var(--teal));
  color: #0b1018; font-size: 11.5px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
.msg-author { font-weight: 700; color: var(--text); }
.msg-author--agent { color: var(--msg-accent); }
.msg-author--user { color: var(--msg-accent); }
.msg-ts { color: var(--dim); font-size: calc(11px * var(--font-scale, 1)); }
.msg-id {
  margin-left: auto;
  background: transparent; border: 1px solid var(--line); color: var(--dim);
  font: inherit; font-size: calc(10.5px * var(--font-scale, 1)); font-family: ui-monospace, "SF Mono", Menlo, monospace;
  padding: 1px 7px; border-radius: 4px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.msg-id:hover { color: var(--teal); border-color: var(--teal); }
.msg-id--copied { background: var(--teal); color: var(--bg); border-color: var(--teal); }
.msg-type { font-size: calc(10.5px * var(--font-scale, 1)); padding: 1px 7px; border-radius: 4px; background: rgba(0,200,160,0.12); color: var(--teal); text-transform: uppercase; letter-spacing: 0.5px; }
.msg-type--task { background: rgba(245,166,35,0.12); color: var(--orange); }
.msg-type--status { background: rgba(122,133,153,0.12); color: var(--muted); }
.msg-body { font-size: 0.875rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-width: 100%; overflow-x: hidden; }

/* ─── Composer ──────────────────────────────────────── */
/* Typing indikator iznad composer-a */
.typing-bar {
  flex-shrink: 0;
  padding: 0 20px;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--teal);
  background: linear-gradient(to top, rgba(0,200,160,0.05), transparent);
  transition: height 0.18s ease;
}
.typing-bar.is-active { height: 26px; }
.typing-label { letter-spacing: 0.2px; font-weight: 500; opacity: 0.88; }
.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 5px; height: 5px;
  background: var(--teal);
  border-radius: 50%;
  display: inline-block;
  opacity: 0.35;
  animation: typing-dot 1.1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.18s; }
.typing-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.composer { border-top: 1px solid var(--line); padding: 12px 20px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--panel); flex-shrink: 0; }
#composer-input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 14px;
  min-height: 44px; max-height: 30vh; overflow-y: auto; line-height: 1.4;
  outline: none; transition: border-color 0.15s;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text; cursor: text; box-sizing: border-box;
}
#composer-input:focus { border-color: var(--teal); }
#composer-input:empty::before {
  content: attr(data-placeholder); color: var(--muted); pointer-events: none; display: block;
}
/* Grid layout: Task | mentions (rastruje) | assignee | Posalji (uvek u desnoj koloni, nikad ne nestane) */
.composer-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.composer-mentions {
  min-width: 0;       /* dozvoli grid items da se skupi ispod content size */
  overflow-x: auto;   /* horizontalni scroll umjesto wrap-a kad ima previse dugmadi */
  scrollbar-width: thin;
}
.composer-send {
  flex-shrink: 0;
  margin-left: 0 !important;   /* override stari margin-left: auto */
}
@media (max-width: 640px) {
  /* Na uskom: 2 reda - Task+mentions u prvom, assignee+Posalji u drugom */
  .composer-actions {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "task     mentions"
      "assignee send";
  }
  .composer-task-toggle { grid-area: task; }
  .composer-mentions    { grid-area: mentions; }
  .composer-assignee    { grid-area: assignee; max-width: none; }
  .composer-send        { grid-area: send; justify-self: end; }
}
.composer-task-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.composer-assignee {
  padding: 6px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 12.5px;
  flex: 1; max-width: 220px;
}
.composer-assignee:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-send {
  margin-left: auto; padding: 8px 22px;
  background: linear-gradient(135deg, var(--teal), var(--teal-b));
  color: #08080d; border: 0; border-radius: 6px;
  font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: opacity 0.15s;
}
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-send:hover:not(:disabled) { opacity: 0.92; }

/* .app-footer rules removed 17.05.2026 - footer pomjeren u .sidebar-version (vidi dno fajla) */

/* ─── Toasts ─────────────────────────────────────────── */
#toasts { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--teal); color: var(--teal); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ─── Channel members modal ──────────────────────────── */
.cm-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 280px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px;
  background: rgba(0,0,0,0.15);
  flex: 1;
}
.cm-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.cm-list li:last-child { border-bottom: 0; }
.cm-list .cm-icon { font-size: 14px; opacity: 0.7; width: 18px; flex-shrink: 0; }
.cm-list .cm-name { color: var(--text); flex: 1; }
.cm-list .cm-slug { color: var(--muted); font-size: 11.5px; }
.cm-list .cm-remove {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer;
  transition: all 0.15s;
}
.cm-list .cm-remove:hover { color: var(--red); border-color: var(--red); }
.cm-list .is-empty { color: var(--muted); font-style: italic; padding: 16px; text-align: center; }
#channel-members-btn { display: inline-flex; align-items: center; gap: 4px; }
#channel-members-btn #member-count { font-size: 11px; color: var(--muted); }

/* ─── Markdown rendering in messages ─────────────────── */
.msg-body strong { font-weight: 700; color: var(--text); }
.msg-body em { font-style: italic; }
.msg-body del { opacity: 0.7; text-decoration: line-through; }
.msg-body a { color: var(--teal); text-decoration: underline; }
.msg-body a:hover { color: var(--teal-b); }
.msg-body .md-inline-code {
  background: rgba(0,0,0,0.25); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}
.msg-body .md-code {
  background: rgba(0,0,0,0.25); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 6px; margin: 6px 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: calc(12px * var(--font-scale, 1)); line-height: 1.5;
  overflow-x: auto; white-space: pre;
  max-width: 100%; box-sizing: border-box;
}
.msg-body .md-list { margin: 4px 0 4px 20px; padding: 0; }
.msg-body .md-list li { margin: 2px 0; }

/* ─── Sidebar settings section ───────────────────────── */
.app-sidebar {
  display: flex;
  flex-direction: column;
}
.sidebar-settings {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sidebar-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sidebar-setting-label {
  font-size: 12px;
  color: var(--dim);
}
.sidebar-help-btn,
.sidebar-portal-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  text-align: center;
  text-decoration: none;
  display: flex;
}
/* Verzija + link na pesares.com - kraj sidebar-a (na desktopu i u hamburger meniju na mobilnom).
   Footer iz dna app-screen-a pomjeren ovdje 17.05.2026. */
.sidebar-version {
  padding: 10px 0 4px;
  font-size: 11.5px;
  color: var(--dim);
  text-align: center;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}
.sidebar-version a {
  color: var(--teal);
  text-decoration: none;
}
.sidebar-version a:hover {
  text-decoration: underline;
}

/* ─── Stream mode toggle ──────────────────────────────── */
.stream-mode-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.smt-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.smt-btn:hover { color: var(--text); }
.smt-btn.is-active {
  background: var(--teal);
  color: var(--bg);
  font-weight: 600;
}

/* ─── Light mode overrides for dark rgba backgrounds ─── */
:root[data-theme="light"] .cm-list {
  background: rgba(0,0,0,0.04);
}
:root[data-theme="light"] .msg-body .md-inline-code,
:root[data-theme="light"] .msg-body .md-code {
  background: rgba(0,0,0,0.05);
}
:root[data-theme="light"] .composer-attachment__remove {
  background: rgba(0,0,0,0.55);
}
:root[data-theme="light"] #cm-channel-name {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

/* Touch devices: reply/fork kao apsolutno pozicioniran red ispod poruke */
@media (hover: none) {
  .msg { padding-bottom: 28px; }
  .msg-actions {
    display: flex !important;
    position: absolute;
    bottom: 5px; right: 6px;
    gap: 4px;
  }
  .msg-action {
    padding: 3px 10px;
    font-size: 10.5px;
    min-height: 24px;
  }
  .msg-head { flex-wrap: nowrap; }
}
/* msg-head no-wrap so ID never gets pushed off */
.msg-head { flex-wrap: nowrap; overflow: hidden; }
.msg-author { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* Members modal + opsti modali na mobilnom */
@media (max-width: 600px) {
  .modal { padding: 12px; align-items: flex-end; }
  .modal__panel {
    max-height: 92vh; border-radius: 12px 12px 0 0;
    padding: 20px 16px 24px;
  }
  #channel-members-modal .file-modal__row {
    flex-direction: column; align-items: stretch; gap: 8px;
  }
  #channel-members-modal .file-modal__row label { width: auto; }
  #channel-members-modal .file-modal__row > div { width: 100%; }
  #cm-rename-btn, #cm-add-btn { width: 100%; padding: 10px; }
  #cm-channel-type { max-width: 100% !important; width: 100%; }
  #cm-type-hint { display: block; margin-top: 4px; }
  .cm-list { max-height: 180px; }
  .cm-list li { padding: 10px 12px; }
  .cm-list .cm-remove { padding: 6px 14px; font-size: 12px; }
  .file-modal__actions { flex-direction: column; }
  .file-modal__actions .btn { width: 100%; justify-content: center; padding: 10px; }
}

/* iOS Safari: suppress inline credential/contact autofill icons inside inputs */
input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
}
input::-webkit-textfield-decoration-container {
  display: none !important;
}

/* Channel tools dropdown (jedno ⚙ dugme + meni) */
.channel-tools-menu button:hover {
  background: rgba(255,255,255,0.06) !important;
}
.channel-tools-menu button.is-active {
  background: rgba(0,200,160,0.12) !important;
  color: var(--accent);
}

/* Click-to-copy hint na <code> u help/help-pane */
.help-body code, .help-pane code {
  cursor: copy;
  transition: background 0.15s, color 0.15s;
}
.help-body code:hover, .help-pane code:hover {
  background: rgba(0,200,160,0.18) !important;
  color: var(--text) !important;
}

/* Block double-tap zoom na mobilnom bez blokade normalnih tap-ova */
html, body { touch-action: manipulation; }

/* Mobile: code/long URL u help modalu ne smije curiti horizontalno */
@media (max-width: 640px) {
  .help-body code, .help-pane code,
  .help-body a, .help-pane a {
    word-break: break-all;
    overflow-wrap: anywhere;
  }
  .help-body pre, .help-pane pre {
    overflow-x: auto;
    max-width: 100%;
  }
  /* Modal sadrzaj ne dira modal__close X dugme u gornjem desnom uglu */
  .modal__panel {
    padding-right: 12px;
  }
  /* Edit forma dugmad u agents modalu ne sme prelaziti modal-close */
  .am-edit-form {
    padding-right: 8px;
  }
}

/* #383 D — online/offline status indikator po članu kanala (Bojan 03.06.2026) */
.cm-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}
.cm-status--online {
  background: #34d399;
  box-shadow: 0 0 4px rgba(52, 211, 153, 0.6);
}
.cm-status--offline {
  background: #6b7280;
  opacity: 0.5;
}
