/* ==========================================================================
   sidebar.css — Sidebar: head, quick actions, agents, sessions, tooltips.
   Part of منصة عقاب dashboard styles. Split from the former app.css.
   Cascade order is significant; see docs/flows/INDEX.md.
   ========================================================================== */
/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 49; backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }
#sidebar {
  width: var(--sw); flex-shrink: 0;
  background: var(--s1);
  border-left: 1px solid var(--b1);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .28s var(--ease), background .25s, border-color .25s;
}
.sb-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--b1); flex-shrink: 0;
}
.sb-header-img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 10px;
  border-radius: var(--r1);
  mix-blend-mode: screen;
  filter: invert(1) brightness(0.88);
}
[data-theme="light"] .sb-header-img {
  mix-blend-mode: multiply;
  filter: none;
}
/* Hide text fallback when image is present */
.sb-head:has(.sb-header-img) .sb-firm,
.sb-head:has(.sb-header-img) .sb-firm-sub { display: none; }
.sb-firm {
  font-family: var(--fh); font-size: 15px; font-weight: 900;
  color: var(--g); line-height: 1.3;
}
.sb-firm-sub { font-size: 10.5px; color: var(--t2); margin-top: 2px; }
.sb-user {
  display: flex; align-items: center; gap: 9px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--b0);
}
.sb-uav {
  width: 28px; height: 28px; border-radius: var(--rf);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fh); font-size: 9.5px; font-weight: 900; flex-shrink: 0;
}
.sb-uname { font-size: 12.5px; color: var(--t1); flex: 1; min-width: 0; font-weight: 500; }
.sb-logout {
  font-size: 11px; color: var(--t2); padding: 3px 7px;
  border-radius: var(--r1); transition: color .15s, background .15s;
}
.sb-logout:hover { color: var(--red); background: rgba(232,96,96,.1); }

/* Quick actions */
.sb-quick { padding: 12px 14px; border-bottom: 1px solid var(--b0); flex-shrink: 0; }
.sb-section-label {
  font-size: 10px; font-weight: 700; color: var(--t2);
  letter-spacing: .8px; text-transform: uppercase; margin-bottom: 9px;
}
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick-btn {
  border: 1px solid var(--b2); color: var(--t1);
  font-size: 11px; font-weight: 500;
  padding: 7px 8px; border-radius: var(--r1); text-align: center;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--s2);
}
.quick-btn:hover { background: var(--gd); border-color: var(--gb); color: var(--g); }

/* Scrollable body */
.sb-body { flex: 1; overflow-y: auto; padding-bottom: 12px; }

/* Agents */
.sb-agents { padding: 12px 14px 6px; }
/* Collapsible header for the agents section */
.sb-collapse-hdr {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.sb-collapse-hdr:hover { color: var(--t1); }
.sb-count {
  font-size: 9px; font-weight: 700; color: var(--t2);
  background: var(--s2); border: 1px solid var(--b2);
  border-radius: 999px; padding: 1px 6px; line-height: 1.4;
}
.sb-chevron {
  width: 13px; height: 13px; margin-inline-start: auto;
  transition: transform .2s ease; color: var(--t2);
}
.sb-agents.collapsed .sb-chevron { transform: rotate(-90deg); }
.sb-agents.collapsed #agents-list { display: none; }
/* Conversations (chat history) section — same collapse idea as the agents section */
.sb-chevron-sess { margin-inline-start: 4px; }
.sb-sessions.collapsed .sb-chevron-sess { transform: rotate(-90deg); }
.sb-sessions.collapsed #sessions-list { display: none; }
.agent-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r2); cursor: pointer;
  transition: background .15s; position: relative;
}
.agent-row:hover { background: var(--s2); }
.agent-row.viewing { background: var(--gd); border-inline-start: 2px solid var(--g); }
.agent-av {
  width: 32px; height: 32px; border-radius: var(--rf);
  display: flex; align-items: center; justify-content: center;
  background: var(--s3); border: 1px solid var(--b2);
  color: var(--g); font-family: var(--fh); font-size: 10.5px; font-weight: 900;
  flex-shrink: 0;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-family: var(--fh); font-size: 13px; font-weight: 700; color: var(--t1); }
.agent-role { font-size: 10.5px; color: var(--t2); margin-top: 1px; }
.sdot { width: 6px; height: 6px; border-radius: var(--rf); flex-shrink: 0; }
.sdot.active { background: var(--green); }
.sdot.idle { background: var(--t3); }

/* Live dispatch indicator: pulsing Logo.svg on an agent whose scheduled job
   is running right now — mirrors the .sess-rlogo treatment on live chat rows. */
.agent-rlogo {
  width: 18px; height: 18px; flex-shrink: 0;
  display: none; object-fit: contain;
  filter: invert(73%) sepia(30%) saturate(700%) hue-rotate(2deg) brightness(105%);
}
[data-theme="dark"] .agent-rlogo {
  filter: invert(1) sepia(30%) saturate(700%) hue-rotate(2deg) brightness(90%);
}
.agent-rlogo.active { display: block; animation: dotPulse 1.4s ease infinite; }
/* While running: hide the static dot (the pulsing logo takes its place) and
   tint the name gold so the row reads as "live, click to watch". */
.agent-row.running .sdot { display: none; }
.agent-row.running .agent-name { color: var(--g); }

/* Sessions */
.sb-sessions { padding: 12px 14px 6px; border-top: 1px solid var(--b0); }
.sb-sess-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.new-sess-btn {
  display: flex; align-items: center; gap: 3px;
  font-size: 11.5px; color: var(--g); padding: 2px 7px;
  border-radius: var(--r1); transition: background .15s;
}
.new-sess-btn:hover { background: var(--gd); }
.new-sess-btn svg { width: 10px; height: 10px; }
/* "تحديد" — enter multi-select mode to reference past conversations */
.sess-select-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 24px; margin-inline-start: auto; margin-inline-end: 4px;
  color: var(--t2); border-radius: var(--r1);
  background: none; border: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.sess-select-btn svg { width: 14px; height: 14px; }
.sess-select-btn:hover { background: var(--gd); color: var(--g); }
.sess-select-btn.active { background: var(--gd); color: var(--g); }

/* Selection checkbox shown on each row in select mode */
.sess-check {
  flex-shrink: 0; width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--b2); color: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
.sess-check.on { background: var(--g); border-color: var(--g); color: #fff; }
.sess-row.selectable { cursor: pointer; }
.sess-row.selected { background: var(--gd); border-inline-start-color: var(--g); }
.sess-row.selectable:hover .sess-time { opacity: 1; }   /* keep time; del hidden in select mode */
#sessions-list.selecting .sess-del { display: none; }

/* Action bar under the list while selecting */
.sess-ctx-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 7px;
  background: var(--s2); border: 1px solid var(--gb); border-radius: var(--r2);
}
.sess-ctx-bar[hidden] { display: none; }
.sess-ctx-start {
  flex: 1; font-size: 12px; font-weight: 600; font-family: var(--fh);
  color: #fff; background: var(--g); border: none; cursor: pointer;
  padding: 7px 10px; border-radius: var(--r1);
  transition: background .15s, opacity .15s;
}
.sess-ctx-start:hover:not(:disabled) { background: var(--gl); }
.sess-ctx-start:disabled { opacity: .55; cursor: default; }
.sess-ctx-cancel {
  font-size: 11.5px; color: var(--t2); background: none; border: none;
  cursor: pointer; padding: 7px 8px; border-radius: var(--r1);
}
.sess-ctx-cancel:hover { color: var(--t1); background: var(--s3); }
.sess-row {
  display: flex; align-items: center; padding: 8px 10px;
  border-radius: var(--r2); cursor: pointer;
  border-inline-start: 2px solid transparent;
  transition: background .15s, border-color .15s;
  gap: 6px;
}
.sess-row:hover { background: var(--s2); }
.sess-row.active { background: var(--s3); border-inline-start-color: var(--g); }
.sess-preview { font-size: 12.5px; color: var(--t1); min-width: 0; flex: 1; font-weight: 400; }
/* Right-side meta: time + delete stacked in the same space */
.sess-right {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  min-width: 28px;
}
.sess-time {
  font-size: 10.5px; color: var(--t2); white-space: nowrap;
  transition: opacity .12s;
}
.sess-del {
  position: absolute; inset: 50% 0 auto; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: var(--r1);
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--t3); padding: 0;
  opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.sess-del svg { pointer-events: none; }
.sess-row:hover .sess-time { opacity: 0; }
.sess-row:hover .sess-del,
.sess-del:focus { opacity: 1; }
.sess-del:hover { color: var(--red); background: rgba(232,96,96,.12); }
/* Running indicator: Logo.svg on active session rows */
.sess-rlogo {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: none;
  object-fit: contain;
  image-rendering: auto;
  /* SVG stroke is dark — make it gold in both themes */
  filter: invert(73%) sepia(30%) saturate(700%) hue-rotate(2deg) brightness(105%);
}
[data-theme="dark"] .sess-rlogo {
  filter: invert(1) sepia(30%) saturate(700%) hue-rotate(2deg) brightness(90%);
}
.sess-rlogo.active { display: block; animation: dotPulse 1.4s ease infinite; }
/* Full-preview tooltip (fixed, escapes sidebar overflow) */
.sess-tooltip {
  position: fixed; z-index: 300;
  background: var(--s4, var(--s3));
  border: 1px solid var(--b2);
  border-radius: var(--r2);
  color: var(--t1);
  font-size: 12.5px;
  font-family: var(--fh);
  padding: 8px 12px;
  max-width: 260px;
  white-space: normal; word-break: break-word; line-height: 1.55;
  pointer-events: none;
  opacity: 0; transform: translateX(6px);
  transition: opacity .15s, transform .15s;
  box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
.sess-tooltip.visible { opacity: 1; transform: translateX(0); }
.no-sess { font-size: 12px; color: var(--t2); padding: 6px 10px; }

