@font-face{font-family:'Vazirmatn';src:url('/fonts/Vazirmatn.woff2') format('woff2');font-style:normal;font-weight:100 900;font-display:swap}:root{font-family:'Vazirmatn',Tahoma,"Segoe UI",sans-serif;color:#122334;background:#f5f8fa;font-synthesis:none}*{box-sizing:border-box}body{margin:0;min-height:100dvh}button,input{font:inherit}button{cursor:pointer}button:disabled{cursor:not-allowed}button:focus-visible,input:focus-visible{outline:3px solid #a2dcdb;outline-offset:2px}[hidden]{display:none!important}.shell{height:100dvh;display:flex;flex-direction:column;overflow:hidden}.topbar{height:72px;min-height:72px;background:#fff;border-bottom:1px solid #e8eef0;display:flex;align-items:center;justify-content:space-between;padding:0 clamp(20px,3.5vw,58px)}.brand{display:flex;align-items:center;gap:12px}.brand-icon{height:39px;width:39px;border-radius:12px;background:#006d73;color:#fff;display:grid;place-items:center;font-weight:800;font-size:23px}.brand strong{display:block;font-size:18px}.brand span{display:block;color:#77919a;font-size:11px;margin-top:3px}.header-actions{display:flex;align-items:center;gap:17px}.lab-label{color:#55838b;font-size:12px;display:flex;align-items:center;gap:8px}.pulse{height:7px;width:7px;border-radius:50%;background:#2a9f96}.secondary{padding:8px 14px;border:1px solid #dae5e8;background:#fff;border-radius:8px;color:#37556a}.login-view{min-height:0;flex:1;display:grid;grid-template-columns:1fr 1fr;align-items:stretch}.login-panel{width:min(420px,90%);margin:auto}.eyebrow{font-family:'Vazirmatn',Tahoma,sans-serif;font-size:11px;font-weight:700;color:#2a8f91;letter-spacing:2.2px}.login-panel h1{font-size:27px;line-height:1.5;margin:9px 0 8px}.login-panel p{line-height:1.9;color:#6c8490;font-size:14px;margin-bottom:35px}.login-panel form{display:flex;flex-direction:column;gap:11px}.login-panel label{font-weight:700;font-size:13px;color:#3a5662;margin-top:5px}.login-panel input,.sidebar-controls input{border:1px solid #dce6e9;background:#fff;border-radius:10px;padding:13px 15px;color:#1a333f;width:100%;min-width:0}.login-panel input::placeholder{color:#a5b5bd}.primary{background:#006d73;border:0;color:#fff;padding:14px 16px;border-radius:10px;font-weight:700}.primary:hover{background:#005e63}.full{margin-top:17px;width:100%}.form-error{min-height:20px;font-size:12px;color:#bf3b46}.login-note{font-size:12px;color:#8b9fa8;border-top:1px solid #e2eaed;padding-top:22px;line-height:1.9;margin-top:25px}.login-art{overflow:hidden;position:relative;background:linear-gradient(135deg,#0d686d,#093c53);display:flex;align-items:center;justify-content:center;flex-direction:column;gap:23px}.abstract-orb{position:absolute;border:1px solid #ffffff30;border-radius:50%;width:360px;height:360px;left:-110px;top:-120px}.abstract-orb.two{width:460px;height:460px;left:auto;right:-250px;top:auto;bottom:-250px}.art-message{position:relative;display:flex;gap:16px;align-items:center;padding:23px 29px;border:1px solid #ffffff50;background:#ffffff23;backdrop-filter:blur(12px);color:white;border-radius:18px;width:min(360px,75%);box-shadow:0 12px 40px #073c412b}.art-message.light{transform:translateX(-32px);background:#ffffffec;color:#224955}.art-avatar{width:44px;height:44px;border-radius:14px;background:#ffffff38;display:grid;place-items:center;font-size:21px;font-weight:700}.art-avatar.team{background:#d6f3ef;color:#147780}.art-message b{display:block;font-size:15px}.art-message small{display:block;font-size:12px;opacity:.72;margin-top:8px}.workspace{display:grid;grid-template-columns:minmax(280px,370px) minmax(0,1fr);flex:1;min-height:0;max-height:calc(100dvh - 72px)}.sidebar{border-left:1px solid #e4ebef;background:#fff;display:flex;flex-direction:column;min-height:0}.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:28px 25px 15px}.sidebar-head h1{margin:5px 0 0;font-size:22px}.icon-button{width:35px;height:35px;border:1px solid #e5ecef;border-radius:10px;background:#fff;font-size:23px;color:#57737d;display:grid;place-items:center}.icon-button:hover{background:#eef6f5}.sidebar-controls{padding:0 20px 15px}.sidebar-controls input{background:#f5f8f9;padding:11px 12px;font-size:13px}.filter-row{display:flex;gap:7px;margin-top:13px}.filter{border:1px solid #e5ecef;background:#fff;color:#708991;font-size:12px;padding:8px 15px;border-radius:18px}.filter.active{background:#e7f4f1;color:#08777a;border-color:#d7ebe7;font-weight:700}.conversation-list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:6px 11px}.conversation-item{border:0;border-radius:11px;background:transparent;width:100%;text-align:right;display:flex;gap:12px;align-items:flex-start;padding:15px 12px;color:#213745;margin-bottom:4px}.conversation-item:hover{background:#f5f8f8}.conversation-item.selected{background:#e8f4f3}.avatar{height:43px;width:43px;min-width:43px;border-radius:14px;background:#e1eeee;color:#1e7980;font-weight:800;display:grid;place-items:center}.list-copy{min-width:0;flex:1}.list-head{display:flex;justify-content:space-between;gap:6px;align-items:center}.list-head strong{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.list-head time{font-size:10px;color:#9baeb6;white-space:nowrap}.list-copy p{margin:8px 0 5px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;color:#718892;font-size:12px}.list-meta{display:flex;gap:7px;color:#a0afb6;font-size:10px}.chip{background:#f0f4f5;border-radius:4px;padding:3px 6px;color:#71868e}.chip.test{color:#a47922;background:#fff4d9}.sidebar-footer{padding:15px 20px;display:flex;gap:8px;align-items:center;font-size:10px;color:#8ca1aa;border-top:1px solid #e7eef0}.sidebar-footer .dot{height:6px;width:6px;background:#35a79b;border-radius:50%}.conversation-area{min-width:0;min-height:0;display:flex;flex-direction:column;background:#f7fafa}.empty-state{margin:auto;text-align:center;color:#81979f;padding:20px}.empty-state h2{color:#334c58;font-size:19px}.empty-state p{line-height:1.8;font-size:13px}.empty-icon{font-size:39px;display:grid;place-items:center;margin:auto;width:87px;height:87px;border:1px solid #dce9e9;border-radius:28px;background:#e9f3f2;color:#33888c}.conversation-content{flex:1;display:flex;flex-direction:column;min-height:0}.chat-header{height:86px;min-height:86px;background:#fff;border-bottom:1px solid #e6eced;display:flex;gap:13px;align-items:center;padding:0 28px}.chat-title{flex:1;min-width:0}.chat-title strong{font-size:16px}.chat-subtitle{display:flex;align-items:center;gap:8px;font-size:11px;color:#8297a1;margin-top:8px}.test-badge{font-size:11px;color:#a47a24;background:#fff6df;padding:6px 10px;border-radius:8px}.mobile-back{display:none}.messages{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:25px clamp(18px,6vw,72px);display:flex;flex-direction:column;gap:16px}.message{max-width:min(650px,78%);align-self:flex-start;background:#fff;border:1px solid #e5edef;border-radius:16px 16px 16px 4px;padding:14px 17px;box-shadow:0 3px 13px #1f3d4c08;white-space:pre-wrap;overflow-wrap:anywhere}.message.agent{align-self:flex-end;background:#e2f3ef;border-color:#cfeae5;border-radius:16px 16px 4px 16px}.message .body{font-size:13px;line-height:2;color:#263f4d}.message .meta{display:flex;gap:10px;margin-top:10px;color:#8aa1a8;font-size:10px;direction:ltr;justify-content:flex-end}.reply-locked{background:#fff;border-top:1px solid #e6edef;display:flex;align-items:center;gap:12px;padding:18px 28px}.reply-icon{height:37px;width:37px;min-width:37px;display:grid;place-items:center;border-radius:11px;background:#f1f5f6;color:#99abb2}.reply-locked strong{font-size:12px;color:#4b6570}.reply-locked p{font-size:11px;color:#98abb2;margin:7px 0 0}.reply-locked>div:nth-child(2){flex:1}.reply-locked button{background:#e1e8ea;border:0;color:#97a9b1;padding:10px 18px;border-radius:10px;font-size:12px}.placeholder{padding:25px 20px;text-align:center;font-size:13px;color:#8ba0a9;line-height:2}.toast{position:fixed;bottom:20px;left:20px;color:#fff;background:#375864;padding:12px 18px;border-radius:10px;font-size:12px;opacity:0;pointer-events:none;transition:opacity .2s;z-index:10}.toast.show{opacity:1}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:900px){.login-view{grid-template-columns:1fr}.login-art{display:none}}@media(max-width:680px){.topbar{height:62px;min-height:62px;padding:0 14px}.brand span{display:none}.lab-label{font-size:10px}.workspace{display:block;max-height:calc(100dvh - 62px)}.sidebar,.conversation-area{height:100%;width:100%}.workspace.chat-open .sidebar{display:none}.workspace:not(.chat-open) .conversation-area{display:none}.mobile-back{display:grid}.chat-header{padding:0 14px}.messages{padding:20px 14px}.message{max-width:88%}.reply-locked{padding:13px}.reply-locked p{line-height:1.7}.reply-locked button{display:none}}

.channels-dialog{width:min(770px,calc(100vw - 24px));max-height:92dvh;overflow:auto;border:1px solid #e1eaeb;box-shadow:0 30px 95px #12354835;border-radius:18px;padding:24px;color:#183341;background:#fff}
.channels-dialog::backdrop{background:#0b263e89;backdrop-filter:blur(4px)}
.channels-head{display:flex;justify-content:space-between;align-items:start;gap:12px}.channels-head h2{margin:9px 0 5px;font-size:21px}.channels-head p{font-size:12px;color:#71909c;line-height:1.9;margin:0}
.channel-options{display:flex;flex-wrap:wrap;gap:7px;margin:15px 0 16px}.channel-form{display:grid;grid-template-columns:1fr;gap:9px;padding:17px;background:#f7faf9;border:1px solid #e5efed;border-radius:13px}.channel-form h3{margin:0 0 5px}.channel-form label{font-size:12px;font-weight:700;color:#3d6170}
.channel-form input,.channel-form select{width:100%;min-width:0;border-radius:9px;border:1px solid #d4e1e4;padding:11px;background:white;color:#234356}
.channel-note{font-size:11px;line-height:1.8;color:#718f9a}.channel-form button{justify-self:start}.channels-list-head{display:flex;align-items:center;justify-content:space-between;margin-top:24px}.channels-list-head h3{font-size:16px}
.channels-list{display:flex;flex-direction:column;gap:10px}.channel-card{border:1px solid #e5eeee;padding:15px;border-radius:12px;background:#fff}.channel-card strong{display:block;font-size:14px}.channel-meta,.channel-status{font-size:11px;color:#77939c;margin-top:8px;overflow-wrap:anywhere}.channel-status{color:#a27b2c}.channel-buttons{display:flex;flex-wrap:wrap;gap:9px;margin-top:14px}.channels-dialog button{font-size:12px}
@media(max-width:680px){.channels-dialog{padding:14px;max-height:95dvh}.channels-head h2{font-size:17px}.header-actions{gap:7px}.header-actions .secondary{padding:7px 8px;font-size:11px}}

.pilot-reply{border-top:1px solid #dce7e9;padding:12px 16px;background:#f7fbfb}.pilot-reply label{display:block;font-size:12px;margin-bottom:7px;color:#496675}.pilot-reply textarea{display:block;width:100%;min-height:48px;max-height:120px;border:1px solid #cadadd;border-radius:9px;padding:8px 10px;resize:vertical;font-family:inherit}.pilot-reply-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:7px}.pilot-reply-actions p{color:#78909a;font-size:11px;margin:0}.pilot-reply-actions button{white-space:nowrap}.pilot-reply[hidden],.reply-locked[hidden]{display:none!important}@media(max-width:650px){.pilot-reply-actions{align-items:stretch;flex-direction:column}}

.channel-error{color:#b24343;margin-top:6px}.channel-ok{color:#2c7b70;margin-top:6px}

/* v6 scoped conversation workflow */
.workflow-panel{background:#fff;border-bottom:1px solid #e2e9e9;padding:10px 18px;}
.workflow-panel[hidden]{display:none!important}
.workflow-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.workflow-actions strong{font-size:12px;color:#47646e;font-weight:600}
.workflow-buttons{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.workflow-assign-box{display:flex;align-items:center;gap:6px;font-size:12px;color:#57717b}
.workflow-assign-box[hidden]{display:none!important}
.workflow-assign-box select{max-width:180px;border:1px solid #d7e3e5;border-radius:8px;padding:8px;background:#fff}
.workflow-buttons button{padding:7px 11px;font-size:12px}
@media(max-width:680px){.workflow-panel{padding:10px}.workflow-buttons{width:100%}.workflow-assign-box{max-width:100%;flex-wrap:wrap}}


/* FILIVO UI REDESIGN V1 — visual layer and responsive navigation */
:root {
  --filivo-navy: #1B365D;
  --filivo-blue: #005A9C;
  --filivo-sky: #60C1E5;
  --filivo-pale: #A0E0EF;
  --filivo-bg: #F3F7FB;
  --filivo-border: #DCE7F0;
  --filivo-muted: #6D8298;
  color: var(--filivo-navy);
  background: var(--filivo-bg);
}

body { background: var(--filivo-bg); color: var(--filivo-navy); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--filivo-sky);
  outline-offset: 2px;
}

.topbar {
  position: relative;
  z-index: 12;
  background: var(--filivo-navy);
  border-bottom: 1px solid #29486F;
  color: #fff;
  box-shadow: 0 3px 14px #10274418;
}
.brand-icon { background: var(--filivo-blue); color: #fff; }
.brand strong { color: #fff; }
.brand span, .lab-label { color: var(--filivo-pale); }
.pulse { background: var(--filivo-sky); box-shadow: 0 0 0 4px #60C1E526; }
.topbar .secondary {
  background: transparent;
  border-color: #FFFFFF55;
  color: #fff;
}
.topbar .secondary:hover { background: #FFFFFF18; border-color: var(--filivo-pale); }

.primary {
  background: var(--filivo-blue);
  color: #fff;
  border: 1px solid var(--filivo-blue);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.primary:hover { background: var(--filivo-navy); border-color: var(--filivo-navy); }
.secondary {
  background: #fff;
  color: var(--filivo-blue);
  border: 1px solid #C8D9E8;
  transition: background .18s ease, border-color .18s ease;
}
.secondary:hover { background: #EDF7FC; border-color: var(--filivo-sky); }
.eyebrow { color: var(--filivo-blue); }

.workspace {
  --nav-width: 248px;
  grid-template-columns: var(--nav-width) minmax(285px, 350px) minmax(0, 1fr);
  background: var(--filivo-bg);
}
.app-sidebar {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 13px;
  overflow: hidden;
  color: #fff;
  background: var(--filivo-navy);
  border-left: 1px solid #29486F;
}
.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 0 7px;
}
.app-brand-mark {
  width: 37px;
  height: 37px;
  flex: 0 0 37px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--filivo-blue);
  font-size: 21px;
  font-weight: 800;
}
.app-brand-name { flex: 1; color: #fff; font-size: 15px; font-weight: 800; white-space: nowrap; }
.nav-collapse {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid #FFFFFF38;
  border-radius: 9px;
  color: var(--filivo-pale);
  background: transparent;
  font-size: 22px;
  line-height: 1;
}
.nav-collapse:hover { background: #FFFFFF18; }
.app-nav { display: flex; flex-direction: column; gap: 8px; }
.app-nav-item {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #EAF5FC;
  background: transparent;
  text-align: right;
  font-size: 13px;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.app-nav-item:hover { background: #FFFFFF12; }
.app-nav-item[aria-current="page"] {
  color: #fff;
  background: var(--filivo-blue);
  border-color: #60C1E566;
  box-shadow: inset -3px 0 0 var(--filivo-sky);
}
.nav-glyph {
  width: 25px;
  min-width: 25px;
  display: inline-grid;
  place-items: center;
  color: var(--filivo-pale);
  font-size: 19px;
}
.app-nav-item[aria-current="page"] .nav-glyph { color: #fff; }
.app-nav-label { white-space: nowrap; }
.app-sidebar-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 13px 9px 3px;
  border-top: 1px solid #FFFFFF24;
  color: #C7D9E9;
  font-size: 10px;
  white-space: nowrap;
}
.sidebar-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--filivo-sky);
}
.nav-backdrop { display: none; }

.workspace.nav-collapsed {
  --nav-width: 76px;
  grid-template-columns: 76px minmax(285px, 350px) minmax(0, 1fr);
}
.workspace.nav-collapsed .app-sidebar { padding-inline: 10px; }
.workspace.nav-collapsed .app-sidebar-brand { position: relative; justify-content: center; padding: 0; }
.workspace.nav-collapsed .app-brand-name,
.workspace.nav-collapsed .app-nav-label { display: none; }
.workspace.nav-collapsed .nav-collapse {
  display: grid;
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}
.workspace.nav-collapsed .app-nav { margin-top: 24px; }
.workspace.nav-collapsed .app-nav-item { justify-content: center; padding-inline: 5px; }
.workspace.nav-collapsed .app-sidebar-footer { justify-content: center; padding-inline: 0; }

#conversation-pane { grid-column: 2; grid-row: 1; }
.conversation-area { grid-column: 3; grid-row: 1; }
.sidebar { border-left-color: var(--filivo-border); }
.sidebar-head { border-bottom: 1px solid #EAF0F5; }
.sidebar-head h1 { color: var(--filivo-navy); }
.icon-button { color: var(--filivo-blue); border-color: var(--filivo-border); }
.icon-button:hover { background: #EAF6FC; }
.sidebar-controls input { border-color: var(--filivo-border); background: #F8FBFD; }
.filter { border-color: var(--filivo-border); color: var(--filivo-muted); }
.filter.active { color: var(--filivo-blue); background: #E6F5FB; border-color: #B9E5F4; }
.conversation-item { color: var(--filivo-navy); }
.conversation-item:hover { background: #F1F7FB; }
.conversation-item.selected { background: #E4F4FA; box-shadow: inset -3px 0 0 var(--filivo-blue); }
.avatar { background: #DFF2F9; color: var(--filivo-blue); }
.chip { background: #EDF3F8; color: #536D86; }
.sidebar-footer { border-top-color: var(--filivo-border); }
.sidebar-footer .dot { background: var(--filivo-sky); }
.conversation-area { background: #F5F8FC; }
.chat-header { border-bottom-color: var(--filivo-border); }
.empty-state h2 { color: var(--filivo-navy); }
.empty-icon { color: var(--filivo-blue); background: #E8F6FB; border-color: #CBEAF5; }
.message { border-color: var(--filivo-border); }
.message.agent { background: #E8F6FB; border-color: #C7EAF5; }
.workflow-panel { border-bottom-color: var(--filivo-border); }
.reply-locked, .pilot-reply { border-top-color: var(--filivo-border); }
.login-art { background: linear-gradient(135deg, var(--filivo-navy), var(--filivo-blue)); }
.art-avatar.team { background: #DFF5FB; color: var(--filivo-blue); }
.toast { background: var(--filivo-navy); }

/* Full-workspace connection management page */
.workspace.channels-open {
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
}
.workspace.channels-open #conversation-pane,
.workspace.channels-open #chat-pane { display: none !important; }
.workspace.channels-open #channels-view {
  grid-column: 2;
  grid-row: 1;
  display: flex;
}
.channels-view {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 19px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 2.2vw, 32px);
  background: var(--filivo-bg);
}
.channels-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.channels-head-copy { min-width: 0; }
.channels-head-copy h1 {
  margin: 7px 0 6px;
  color: var(--filivo-navy);
  font-size: clamp(20px, 2vw, 26px);
}
.channels-head-copy p {
  max-width: 900px;
  margin: 0;
  color: var(--filivo-muted);
  font-size: 12px;
  line-height: 1.95;
}
.channels-page-header > button { flex: 0 0 auto; }
.channel-options { margin: 0; }
.channels-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(300px, .88fr) minmax(0, 1.12fr);
  align-items: start;
  gap: 20px;
}
.channel-form {
  min-width: 0;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 12px 14px;
  padding: 21px;
  border: 1px solid var(--filivo-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 24px #1B365D0A;
}
.channel-form h3 {
  grid-column: 1 / -1;
  margin: 0 0 3px;
  color: var(--filivo-navy);
  font-size: 16px;
}
.channel-form label { align-self: center; color: #48627D; }
.channel-form input, .channel-form select {
  min-width: 0;
  min-height: 43px;
  border: 1px solid #D2E0EC;
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--filivo-navy);
  background: #fff;
}
.channel-form input:focus, .channel-form select:focus {
  border-color: var(--filivo-sky);
}
.channel-note, #channel-error, .channel-form button { grid-column: 1 / -1; }
.channel-note { color: var(--filivo-muted); }
.channel-form button { justify-self: start; }
.channels-registered {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--filivo-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 24px #1B365D0A;
}
.channels-list-head { margin: 0 0 15px; }
.channels-list-head h3 { margin: 0; color: var(--filivo-navy); }
.channels-list { gap: 12px; }
.channel-card {
  border-color: var(--filivo-border);
  border-radius: 13px;
  box-shadow: 0 3px 12px #1B365D08;
}
.channel-card strong { color: var(--filivo-navy); }
.channel-meta, .channel-status { color: var(--filivo-muted); line-height: 1.8; }
.channel-status { color: #8B682B; }
.channel-ok { color: var(--filivo-blue); }
.channel-buttons { gap: 8px; }
.channel-buttons button { min-height: 36px; }

/* Tablet and mobile */
.nav-toggle { display: none; }
@media (max-width: 1050px) {
  .channels-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 761px) and (max-width: 1050px) {
  .workspace:not(.nav-expanded) {
    --nav-width: 76px;
    grid-template-columns: 76px minmax(250px, 300px) minmax(0, 1fr);
  }
  .workspace:not(.nav-expanded).channels-open { grid-template-columns: 76px minmax(0, 1fr); }
  .workspace:not(.nav-expanded) .app-sidebar-brand { position: relative; justify-content: center; padding: 0; }
  .workspace:not(.nav-expanded) .app-brand-name,
  .workspace:not(.nav-expanded) .app-nav-label { display: none; }
  .workspace:not(.nav-expanded) .nav-collapse {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
  }
  .workspace:not(.nav-expanded) .app-nav { margin-top: 24px; }
  .workspace:not(.nav-expanded) .app-nav-item { justify-content: center; padding-inline: 5px; }
  .workspace:not(.nav-expanded) .app-sidebar-footer { justify-content: center; padding-inline: 0; }

  .workspace.nav-expanded {
    --nav-width: 248px;
    grid-template-columns: 248px minmax(250px, 300px) minmax(0, 1fr);
  }
  .workspace.nav-expanded.channels-open { grid-template-columns: 248px minmax(0, 1fr); }
  .workspace.nav-expanded .app-sidebar-brand { justify-content: flex-start; padding: 0 7px; }
  .workspace.nav-expanded .app-brand-name,
  .workspace.nav-expanded .app-nav-label { display: initial; }
  .workspace.nav-expanded .nav-collapse { position: static; transform: none; }
  .workspace.nav-expanded .app-nav { margin-top: 0; }
  .workspace.nav-expanded .app-nav-item { justify-content: flex-start; padding: 0 13px; }
  .workspace.nav-expanded .app-sidebar-footer { justify-content: flex-start; padding: 13px 9px 3px; }
}
@media (max-width: 760px) {
  .topbar { height: 62px; min-height: 62px; padding: 0 12px; }
  .brand { gap: 8px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand strong { font-size: 16px; }
  .header-actions { gap: 8px; }
  .lab-label { display: none; }
  .nav-toggle {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #FFFFFF55;
    border-radius: 10px;
    color: #fff;
    background: #FFFFFF12;
    font-size: 20px;
  }
  .workspace {
    position: relative;
    display: block;
    max-height: calc(100dvh - 62px);
    overflow: hidden;
  }
  .app-sidebar {
    position: absolute;
    z-index: 42;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 290px);
    height: 100%;
    transform: translateX(105%);
    transition: transform .22s ease;
    box-shadow: -12px 0 32px #10274430;
  }
  .workspace.nav-open .app-sidebar { transform: translateX(0); }
  .nav-backdrop:not([hidden]) {
    position: absolute;
    z-index: 40;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: #0B1E34A6;
  }
  .workspace.nav-collapsed .app-sidebar { padding: 18px 13px; }
  .workspace.nav-collapsed .app-brand-name,
  .workspace.nav-collapsed .app-nav-label { display: initial; }
  .workspace.nav-collapsed .app-sidebar-brand { position: relative; justify-content: flex-start; padding: 0 7px; }
  .workspace.nav-collapsed .nav-collapse { display: grid; position: static; transform: none; }
  .workspace.nav-collapsed .app-nav { margin-top: 0; }
  .workspace.nav-collapsed .app-nav-item { justify-content: flex-start; padding: 0 13px; }
  .workspace.nav-collapsed .app-sidebar-footer { justify-content: flex-start; padding: 13px 9px 3px; }
  .sidebar, .conversation-area { height: 100%; width: 100%; }
  .workspace.chat-open .sidebar { display: none; }
  .workspace:not(.chat-open) .conversation-area { display: none; }
  .mobile-back { display: grid; }
  .chat-header { padding: 0 14px; }
  .messages { padding: 18px 13px; }
  .message { max-width: 90%; }
  .reply-locked { padding: 13px; }
  .reply-locked p { line-height: 1.7; }
  .reply-locked button { display: none; }

  .workspace.channels-open #channels-view {
    position: absolute;
    z-index: 5;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    padding: 15px;
  }
  .workspace.channels-open #conversation-pane,
  .workspace.channels-open #chat-pane { display: none !important; }
  .channels-view { gap: 14px; }
  .channels-page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .channels-page-header > button { align-self: flex-start; }
  .channels-head-copy h1 { font-size: 19px; }
  .channels-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .channel-form { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 15px; }
  .channel-form h3, .channel-note, #channel-error, .channel-form button { grid-column: 1; }
  .channel-form label { margin-top: 5px; }
  .channel-form button { justify-self: stretch; }
  .channels-registered { padding: 15px; }
  .channel-buttons { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}


/* FILIVO UI REDESIGN V2 — viewport fit, readability, sidebar and Persian controls */
:root {
  --filivo-navy: #1B365D;
  --filivo-blue: #005A9C;
  --filivo-sky: #60C1E5;
  --filivo-pale: #A0E0EF;
  --filivo-bg: #F3F7FB;
  --filivo-border: #DCE7F0;
  --filivo-muted: #536B84;
}

/* Keep the application viewport fixed; scrolling belongs to content lists only. */
html, body {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
body { height: 100dvh; }
.shell {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
}
.topbar {
  flex: 0 0 72px;
  width: 100%;
  min-width: 0;
}
.workspace {
  flex: 1 1 auto;
  width: 100%;
  height: calc(100dvh - 72px);
  min-width: 0;
  min-height: 0;
  max-height: none;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
}
.workspace.channels-open {
  height: calc(100dvh - 72px);
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}
.app-sidebar {
  grid-row: 1;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}
#conversation-pane,
.conversation-area,
#channels-view {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

/* Clearer conversation separation and stronger text contrast. */
.conversation-list {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.conversation-item {
  border: 0;
  border-bottom: 1px solid #DCE6F0;
  border-radius: 0;
  margin: 0;
  padding: 15px 12px;
}
.conversation-item:last-child { border-bottom-color: transparent; }
.conversation-item:hover { background: #EDF5FB; }
.conversation-item.selected {
  background: #E2F1FA;
  box-shadow: inset -3px 0 0 var(--filivo-blue);
}
.list-head strong { color: #1B365D; font-size: 14px; }
.list-head time { color: #536B84; font-size: 11px; }
.list-copy p { color: #435C75; font-size: 13px; }
.list-meta { color: #536B84; font-size: 11px; }
.chip { color: #405A74; }
.chat-subtitle { color: #536B84; font-size: 12px; }
.message .body { color: #1B365D; font-size: 14px; line-height: 1.95; }
.message .meta { color: #536B84; font-size: 11px; }
.empty-state { color: #536B84; }
.empty-state h2 { color: #1B365D; }
.empty-state p { color: #536B84; font-size: 14px; }
.placeholder { color: #536B84; font-size: 14px; }
.workflow-actions strong,
.workflow-assign-box { color: #354F6B; font-size: 13px; }
.workflow-assign-box label { color: #354F6B; }

/* Apply the installed Persian font to native select controls and option menus. */
select,
option,
select *,
.workflow-assign-box select,
#workflow-assignee,
#channel-provider {
  font-family: 'Vazirmatn', Tahoma, "Segoe UI", sans-serif !important;
  font-size: 14px;
}
.workflow-assign-box select {
  min-height: 38px;
  color: #1B365D;
  border-color: #C8D9E8;
}
select:focus-visible {
  outline: 3px solid var(--filivo-sky);
  outline-offset: 2px;
}

/* The connections page and its navigation rail occupy the complete workspace. */
.workspace.channels-open .app-sidebar {
  grid-column: 1;
  grid-row: 1;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}
.workspace.channels-open #channels-view {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.channels-view {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
.channels-layout {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  align-items: stretch;
  overflow: hidden;
}
.channels-registered {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.channels-list {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.channel-card,
.channel-form,
.channels-registered { min-width: 0; }
.channel-meta,
.channel-status { color: #435C75; font-size: 12px; }
.channel-note { color: #435C75; font-size: 12px; }
.channels-head-copy p { color: #435C75; font-size: 13px; }
.channels-list-head h3,
.channel-form h3 { color: #1B365D; }

/* Slightly compact the connection workspace on shorter desktop screens. */
@media (min-width: 761px) and (max-height: 760px) {
  .channels-view { gap: 11px; padding: 14px; }
  .channels-head-copy h1 { margin: 3px 0 4px; font-size: 21px; }
  .channels-head-copy p { font-size: 11px; line-height: 1.65; }
  .channel-options { gap: 5px; }
  .channels-layout { gap: 12px; }
  .channel-form { padding: 13px; gap: 8px 10px; }
  .channels-registered { padding: 13px; }
  .channel-card { padding: 11px; }
}

/* Tablet: compact navigation rail, with no outer page scrolling. */
@media (min-width: 761px) and (max-width: 1050px) {
  .workspace,
  .workspace.channels-open {
    height: calc(100dvh - 72px);
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }
  .workspace.channels-open .app-sidebar { height: 100%; }
  .workspace.channels-open #channels-view { height: 100%; }
  .channels-view { padding: 14px; gap: 11px; }
  .channels-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
  }
  .channel-form {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 7px 10px;
    padding: 12px;
  }
  .channel-form h3,
  .channel-note,
  #channel-error,
  .channel-form button { grid-column: 1 / -1; }
  .channel-form input,
  .channel-form select { min-height: 36px; padding: 7px 9px; }
  .channels-registered { padding: 12px; }
}

/* Mobile: compact stacked form/list; only the connection list can scroll internally. */
@media (max-width: 760px) {
  .topbar {
    flex: 0 0 62px;
    height: 62px;
    min-height: 62px;
  }
  .workspace,
  .workspace.channels-open {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 62px);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }
  .app-sidebar {
    top: 0;
    bottom: 0;
    height: 100%;
    min-height: 0;
  }
  .workspace.channels-open #channels-view {
    position: absolute;
    z-index: 5;
    inset: 0;
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 10px;
    overflow: hidden;
  }
  .channels-view { gap: 8px; padding: 10px; }
  .channels-page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .channels-head-copy { flex: 1; }
  .channels-head-copy .eyebrow,
  .channels-head-copy p,
  .channel-options { display: none; }
  .channels-head-copy h1 {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
  }
  .channels-page-header > button {
    align-self: center;
    padding: 7px 9px;
    white-space: nowrap;
    font-size: 11px;
  }
  .channels-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }
  .channel-form {
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    gap: 5px 8px;
    padding: 9px;
    border-radius: 11px;
  }
  .channel-form h3 {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 13px;
  }
  .channel-form label {
    margin: 0;
    font-size: 10px;
  }
  .channel-form input,
  .channel-form select {
    min-height: 32px;
    padding: 5px 7px;
    font-size: 11px;
  }
  .channel-note { display: none; }
  .channel-form button {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-height: 34px;
    padding: 7px 9px;
    font-size: 11px;
  }
  #channel-error {
    grid-column: 1 / -1;
    min-height: 0;
    font-size: 10px;
  }
  .channels-registered {
    padding: 9px;
    border-radius: 11px;
  }
  .channels-list-head { margin: 0 0 7px; }
  .channels-list-head h3 { font-size: 13px; }
  .channels-list-head button { padding: 6px 9px; font-size: 10px; }
  .channel-card { padding: 9px; }
  .channel-card strong { font-size: 12px; }
  .channel-meta,
  .channel-status { margin-top: 5px; font-size: 10px; }
  .channel-buttons { gap: 5px; margin-top: 8px; }
  .channel-buttons button { min-height: 29px; padding: 5px 7px; font-size: 10px; }
  .conversation-list,
  .messages { min-height: 0; }
}

/* Very short mobile viewports: reduce decorative spacing, preserve all controls. */
@media (max-width: 760px) and (max-height: 680px) {
  .channels-view { gap: 5px; padding: 7px; }
  .channels-layout { gap: 5px; }
  .channel-form { gap: 3px 6px; padding: 7px; }
  .channel-form input,
  .channel-form select { min-height: 29px; }
  .channels-registered { padding: 7px; }
  .channels-list-head { margin-bottom: 4px; }
}


/* FILIVO UI REDESIGN V3 — structural channels page layout */
@media (min-width: 761px) {
  .workspace.channels-open {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    width: 100%;
    height: calc(100dvh - 72px);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .workspace.channels-open > .app-sidebar {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1;
    width: auto;
    height: 100%;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    transform: none;
    z-index: auto;
  }

  .workspace.channels-open > #channels-view {
    position: relative;
    inset: auto;
    grid-column: 2;
    grid-row: 1;
    display: flex;
    width: auto;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    z-index: auto;
  }
}

/* Mobile retains the right-side drawer; the management page fills the workspace. */
@media (max-width: 760px) {
  .workspace.channels-open {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 62px);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .workspace.channels-open > .app-sidebar {
    position: absolute;
    z-index: 42;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 290px);
    height: 100%;
    min-height: 0;
    transform: translateX(105%);
  }

  .workspace.channels-open.nav-open > .app-sidebar {
    transform: translateX(0);
  }

  .workspace.channels-open > #channels-view {
    position: absolute;
    z-index: 5;
    inset: 0;
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }
}

/* Keep the page itself fixed; long connection lists scroll inside their own panel. */
.workspace.channels-open,
.workspace.channels-open > #channels-view,
.workspace.channels-open .channels-layout {
  min-width: 0;
  min-height: 0;
}

.workspace.channels-open > #channels-view {
  overscroll-behavior: none;
}

.workspace.channels-open .channels-layout {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.workspace.channels-open .channels-registered {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.workspace.channels-open .channels-list {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}


/* FILIVO MOBILE CHAT V4 — conversation-first responsive layout */
.workflow-mobile-toggle {
  display: none;
}

.workflow-details {
  display: block;
}

@media (max-width: 760px) {
  /* The app header remains fixed; the conversation uses the full remaining viewport. */
  .workspace:not(.channels-open) {
    height: calc(100dvh - 62px);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .workspace.chat-open {
    display: block;
    position: relative;
    height: calc(100dvh - 62px);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .workspace.chat-open #conversation-pane {
    display: none !important;
  }

  .workspace.chat-open #chat-pane {
    display: flex !important;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .workspace.chat-open #conversation-content:not([hidden]) {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #conversation-content[hidden],
  #pilot-reply[hidden],
  #reply-locked[hidden] {
    display: none !important;
  }

  /* Compact contact header. */
  .workspace.chat-open .chat-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    min-height: 62px;
    padding: 6px 11px;
    overflow: hidden;
  }

  .workspace.chat-open .chat-header .avatar {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .workspace.chat-open .chat-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  .workspace.chat-open .chat-title strong {
    display: block;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace.chat-open .chat-subtitle {
    font-size: 11px;
    line-height: 1.45;
  }

  /* Workflow controls are collapsed by default on phones, not removed. */
  .workspace.chat-open #workflow-panel:not([hidden]) {
    display: block;
    flex: 0 0 auto;
    max-height: 38dvh;
    min-height: 0;
    margin: 0;
    padding: 5px 9px;
    overflow: hidden;
  }

  .workflow-mobile-toggle {
    display: flex;
    width: 100%;
    min-height: 36px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 8px;
    border: 1px solid #D7E5EF;
    border-radius: 9px;
    background: #F4F9FC;
    color: #1B365D;
    text-align: right;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 11px;
    cursor: pointer;
  }

  .workflow-mobile-title {
    flex: 0 0 auto;
    font-weight: 600;
  }

  .workflow-mobile-toggle strong {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: #334D68;
    font-size: 10px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workflow-mobile-chevron {
    flex: 0 0 auto;
    font-size: 17px;
    line-height: 1;
    transition: transform .18s ease;
  }

  .workflow-panel:not(.workflow-expanded) .workflow-details {
    display: none !important;
  }

  .workflow-panel.workflow-expanded .workflow-details {
    display: block;
    max-height: 29dvh;
    padding-top: 7px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .workflow-panel.workflow-expanded .workflow-mobile-chevron {
    transform: rotate(180deg);
  }

  .workflow-panel.workflow-expanded .workflow-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .workflow-panel.workflow-expanded .workflow-buttons {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 7px;
  }

  .workflow-panel.workflow-expanded .workflow-assign-box {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    gap: 7px;
  }

  .workflow-panel.workflow-expanded .workflow-assign-box select {
    flex: 1 1 130px;
    min-width: 0;
    max-width: none;
  }

  .workflow-panel.workflow-expanded .workflow-details button {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 11px;
  }

  #workflow-action-error {
    margin-top: 5px;
    font-size: 11px;
  }

  /* The message history receives all height left between header and composer. */
  .workspace.chat-open #messages {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 10px 11px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .workspace.chat-open #messages .message {
    flex: 0 0 auto;
    max-width: 91%;
  }

  /* Compact, permanently visible reply composer. */
  .workspace.chat-open #pilot-reply:not([hidden]) {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    margin: 0;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #D8E5EC;
    background: #F7FBFD;
  }

  .workspace.chat-open #pilot-reply label {
    margin: 0;
    color: #354F6B;
    font-size: 11px;
    line-height: 1.4;
  }

  .workspace.chat-open #reply-text {
    display: block;
    width: 100%;
    min-width: 0;
    height: 58px;
    min-height: 54px;
    max-height: 104px;
    padding: 8px 10px;
    border-radius: 10px;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
  }

  .workspace.chat-open .pilot-reply-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }

  .workspace.chat-open .pilot-reply-actions p {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 2.8em;
    margin: 0;
    overflow: hidden;
    color: #718596;
    font-size: 9px;
    line-height: 1.4;
  }

  .workspace.chat-open #reply-submit {
    flex: 0 0 auto;
    min-width: 112px;
    min-height: 43px;
    padding: 7px 13px;
    border-radius: 9px;
    font-size: 13px;
    white-space: nowrap;
  }

  .workspace.chat-open #reply-error {
    margin: 0;
    font-size: 11px;
  }

  /* If replying is unavailable, keep the explanation compact too. */
  .workspace.chat-open #reply-locked:not([hidden]) {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    max-height: 104px;
    min-width: 0;
    margin: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
  }

  .workspace.chat-open #reply-locked .reply-icon {
    flex: 0 0 auto;
  }

  .workspace.chat-open #reply-locked > div:not(.reply-icon) {
    flex: 1 1 auto;
    min-width: 0;
  }

  .workspace.chat-open #reply-locked strong {
    font-size: 11px;
  }

  .workspace.chat-open #reply-locked p {
    margin: 2px 0 0;
    font-size: 10px;
    line-height: 1.45;
  }
}

/* Short phones: preserve a useful message viewport and avoid oversized controls. */
@media (max-width: 760px) and (max-height: 680px) {
  .workspace.chat-open .chat-header {
    min-height: 54px;
  }

  .workspace.chat-open .chat-header .avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  .workspace.chat-open #reply-text {
    height: 50px;
    min-height: 48px;
  }

  .workspace.chat-open #pilot-reply {
    gap: 4px;
    padding-top: 5px;
  }
}


/* FILIVO CHANNELS UNREAD / CHAT UX V5.3 */
.unread-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-inline-start: auto;
  padding: 3px 8px;
  border: 1px solid #B42318;
  border-radius: 999px;
  background: #D92D20;
  color: #FFFFFF;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 1px 3px #7A271A25;
}
.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.list-head strong { min-width: 0; }
.list-head time {
  flex: 0 0 auto;
  direction: rtl;
  white-space: nowrap;
}
/* Customer bubbles stay on the physical left; operator bubbles on the right. */
#messages {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  direction: ltr;
  padding-bottom: 28px !important;
  scroll-padding-bottom: 28px;
}
#messages .message {
  align-self: flex-start;
  direction: rtl;
  width: fit-content;
  max-width: min(78%, 680px);
  margin-inline: 0;
}
#messages .message.agent { align-self: flex-end; }
#messages .message:last-child { margin-bottom: 18px; }
@media (max-width: 760px) {
  #messages .message { max-width: 91%; }
}
