/* sla.css — SLA system styling: pills, strip, responder chain, log, settings.
   Ported from the Zerov2 Support+SLA design handoff. Scoped under .sla-* so
   it can never collide with other Flowboard surfaces. */

/* ── SLA pill (compact in tables) ──────────────────────── */
.sla-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.sla-pill .sla-dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.sla-pill.sla-ok       { background: #e8f3ff; color: #1660c8; border-color: #c7defb; }
.sla-pill.sla-warn     { background: #fff4e0; color: #b66f00; border-color: #f6dca6; }
.sla-pill.sla-at_risk  { background: #ffe6e0; color: #b6390e; border-color: #f4c1b1; }
.sla-pill.sla-breached { background: #ffd9d3; color: #9b1f00; border-color: #ec9d8b;
  animation: sla-pulse 1.6s ease-in-out infinite; }
.sla-pill.sla-met      { background: #e0f6ec; color: #0f7a45; border-color: #b7e3c8; }
.sla-pill.sla-missed   { background: #f0dfdf; color: #6f1414; border-color: #d6a8a8; }
.sla-pill .sla-paused {
  margin-left: 4px; padding: 1px 6px; border-radius: 6px;
  background: rgba(0,0,0,0.08); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
@keyframes sla-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 68, 92, 0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(226, 68, 92, 0); }
}

/* ── Agent badge ───────────────────────────────────────── */
.sla-agent {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-strong);
}
.sla-agent.is-empty { color: var(--ink-faint); font-style: italic; }
.sla-agent-avatar {
  position: relative;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 10.5px; font-weight: 700;
  flex-shrink: 0;
}
.sla-agent-sm .sla-agent-avatar { width: 22px; height: 22px; font-size: 10px; }
.sla-agent-md .sla-agent-avatar { width: 26px; height: 26px; font-size: 10.5px; }
.sla-presence {
  position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid white;
}
.presence-available { background: #00c875; }
.presence-busy      { background: #fdab3d; }
.presence-off_duty  { background: #9aa0ae; }
.presence-on_leave  { background: #e2445c; }

.sla-agent-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sla-agent-name { font-weight: 600; color: var(--ink-strong); white-space: nowrap; }
.sla-agent-role { font-size: 10.5px; color: var(--ink-muted); font-weight: 500; }

.sla-agent.status-on_leave .sla-agent-name,
.sla-agent.status-off_duty .sla-agent-name { color: var(--ink-muted); }

/* ── Responder chain ──────────────────────────────────── */
.sla-chain {
  display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.sla-chain-step {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1 1 180px; min-width: 0;
  padding: 8px 10px;
  background: white; border: 1px solid var(--border-row);
  border-radius: 8px;
}
.sla-chain-level {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--ink-muted); text-transform: uppercase;
}
.sla-chain-arrow {
  display: flex; align-items: center; color: var(--ink-faint);
  font-size: 18px; font-weight: 700;
}

/* ── SLA strip (drawer headline panel) ────────────────── */
.sla-strip {
  background: white;
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.sla-strip.sla-state-breached { border-left: 4px solid #d33; background: linear-gradient(to right, #fff7f5, white 30%); }
.sla-strip.sla-state-at_risk  { border-left: 4px solid #e88a40; background: linear-gradient(to right, #fff8ef, white 30%); }
.sla-strip.sla-state-warn     { border-left: 4px solid #d4a300; background: linear-gradient(to right, #fffaee, white 30%); }
.sla-strip.sla-state-met      { border-left: 4px solid #00c875; background: linear-gradient(to right, #f1faf3, white 30%); }
.sla-strip.sla-state-missed   { border-left: 4px solid #b6390e; background: linear-gradient(to right, #fff0eb, white 30%); }
.sla-strip.sla-state-ok       { border-left: 4px solid #0073ea; }

.sla-strip-head {
  display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; align-items: baseline;
}
.sla-strip-title { display: flex; flex-direction: column; gap: 2px; }
.sla-strip-state {
  font-size: 16px; font-weight: 800; color: var(--ink-strong);
  letter-spacing: -0.01em;
}
.sla-strip-desc { font-size: 12.5px; color: var(--ink-muted); }
.sla-strip-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-muted);
}
.sla-strip-meta-item b { color: var(--ink-strong); }
.sla-strip-sep { color: var(--ink-faint); }
.sla-paused-chip {
  margin-left: 8px; padding: 3px 8px; border-radius: 999px;
  background: #f0eaf8; color: #5a3aa3; font-size: 11px; font-weight: 600;
  border: 1px solid #d8c8f0;
}

/* Progress bar */
.sla-strip-bar { display: flex; flex-direction: column; gap: 4px; }
.sla-bar-track {
  position: relative;
  height: 12px; border-radius: 6px;
  background: #eef0f5;
  /* The marker label sits at top:-16px above the track, so we can't use
     overflow:hidden on the track itself without clipping it. We instead
     constrain the fill + overflow segments mathematically (see SlaStrip
     in sla.jsx) and rely on this max-width safety net to keep the
     hatched overflow from breaking out of the strip card if a caller
     ever feeds in an out-of-range value. */
  overflow: visible;
}
.sla-bar-fill, .sla-bar-overflow { max-width: 100%; }
.sla-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 6px;
  background: linear-gradient(to right, #0073ea, #579bfc);
  transition: width 0.3s ease;
}
.sla-state-warn  .sla-bar-fill { background: linear-gradient(to right, #e8a300, #fdab3d); }
.sla-state-at_risk .sla-bar-fill { background: linear-gradient(to right, #d4621a, #fb8c4d); }
.sla-state-breached .sla-bar-fill { background: linear-gradient(to right, #d33, #ec5a5a); }
.sla-state-met .sla-bar-fill { background: linear-gradient(to right, #00a25c, #25c97a); }
.sla-state-missed .sla-bar-fill { background: linear-gradient(to right, #8b1c00, #b6390e); }

.sla-bar-overflow {
  position: absolute; left: 66.66%; top: -1px; bottom: -1px;
  background: repeating-linear-gradient(45deg, #d33, #d33 4px, #b22 4px, #b22 8px);
  border-radius: 0 6px 6px 0;
  border: 1px solid #a00;
}
.sla-bar-marker {
  position: absolute; top: -1px; bottom: -1px;
  width: 2px; background: var(--ink-strong);
}
.sla-bar-marker-label {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 700; color: var(--ink-strong);
  white-space: nowrap; letter-spacing: 0.02em;
}
.sla-bar-legend {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-faint); font-weight: 500;
}

/* Simulator row */
.sla-strip-sim {
  display: flex; align-items: center; gap: 6px;
  padding-top: 10px; border-top: 1px dashed var(--border-row);
}
.sla-sim-label { font-size: 11.5px; color: var(--ink-muted); font-weight: 600; }
.sla-sim-now {
  padding: 2px 8px; background: #0f1729; color: white;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-right: 6px;
}
.sla-sim-btn { font-size: 11.5px; padding: 4px 10px; }

/* ── Notification log ──────────────────────────────────── */
.sla-log {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: white; overflow: hidden;
}
.sla-log-empty {
  padding: 16px; text-align: center; color: var(--ink-faint);
  font-size: 12.5px; font-style: italic;
  border: 1px dashed var(--border); border-radius: var(--r-md);
}
.sla-log-item {
  display: grid; grid-template-columns: 60px 12px 1fr; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-row);
  align-items: start;
}
.sla-log-item:last-child { border-bottom: none; }
.sla-log-item.kind-breach   { background: #fff5f3; }
.sla-log-item.kind-severe   { background: #ffe6e0; }
.sla-log-item.kind-replied  { background: #f1faf3; }
.sla-log-time {
  font-size: 11px; font-weight: 700; color: var(--ink-muted);
  font-variant-numeric: tabular-nums; padding-top: 2px;
  text-align: right;
}
.sla-log-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px;
  box-shadow: 0 0 0 3px white, 0 0 0 4px var(--border);
}
.sla-log-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sla-log-line1 {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px;
}
.sla-log-channel {
  padding: 1px 7px; border-radius: 6px; background: var(--bg-subtle);
  font-size: 11px; font-weight: 600; color: var(--ink-strong);
  border: 1px solid var(--border-row);
}
.sla-log-arrow { color: var(--ink-faint); }
.sla-log-agent { font-size: 12.5px; }
.sla-log-promoted {
  font-size: 10.5px; padding: 1px 6px;
  background: #fff4e0; color: #b66f00; border: 1px solid #f6dca6;
  border-radius: 6px; font-weight: 600;
}
.sla-log-reason { font-size: 11.5px; color: var(--ink-muted); }

/* ── Settings: Team & SLA tab ──────────────────────────── */
.sla-settings { padding: 14px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.sla-two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 1100px) { .sla-two-col { grid-template-columns: 1fr; } }

.sla-channel-row { display: flex; gap: 6px; flex-wrap: wrap; }
.sla-ch {
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--bg-subtle); color: var(--ink-faint);
  border: 1px solid var(--border-row);
  text-decoration: line-through;
}
.sla-ch.on {
  background: #e8f3ff; color: #1660c8; border-color: #c7defb;
  text-decoration: none;
}

.sla-status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
}
.sla-status-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.sla-status-pill.status-available { background: #e0f6ec; color: #0f7a45; border-color: #b7e3c8; }
.sla-status-pill.status-busy      { background: #fff4e0; color: #b66f00; border-color: #f6dca6; }
.sla-status-pill.status-off_duty  { background: #f0f1f4; color: #5f6473; border-color: #d8dbe2; }
.sla-status-pill.status-on_leave  { background: #ffe1e6; color: #9b1f3a; border-color: #f4b6c2; }

.sla-coverage-pill {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.sla-coverage-pill.mode-24x7     { background: #ffd9d3; color: #9b1f00; }
.sla-coverage-pill.mode-business { background: #e8f3ff; color: #1660c8; }

.sla-bh-card { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.sla-bh-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 4px 0;
  border-bottom: 1px dashed var(--border-row);
}
.sla-bh-row:last-of-type { border-bottom: none; }
.sla-bh-label { color: var(--ink-muted); font-weight: 500; }
.sla-weekdays { display: flex; gap: 4px; }
.sla-wd {
  width: 30px; padding: 4px 0; text-align: center;
  font-size: 11px; font-weight: 700;
  background: var(--bg-subtle); color: var(--ink-faint);
  border: 1px solid var(--border-row); border-radius: 6px;
}
.sla-wd.on { background: #e8f3ff; color: #0073ea; border-color: #c7defb; }
.sla-bh-note {
  margin-top: 4px; padding: 8px 10px;
  background: #fff8ef; border-left: 3px solid #fdab3d;
  border-radius: 6px; font-size: 11.5px; color: #6f4a00;
}

.sla-holiday-list {
  padding: 10px 14px; display: flex; flex-direction: column; gap: 4px;
  max-height: 280px; overflow: auto;
}
.sla-holiday {
  display: grid; grid-template-columns: 70px 1fr 22px;
  align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px;
}
.sla-holiday:hover { background: var(--bg-subtle); }
.sla-holiday-date { font-weight: 700; color: var(--ink-strong); }
.sla-holiday-label { color: var(--ink-muted); }
.sla-holiday-x {
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: transparent; color: var(--ink-faint);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.sla-holiday-x:hover { background: #ffe1e6; color: #9b1f3a; }

/* ── Drawer chrome (used by support.jsx ticket drawer) ── */
.sup-drawer-root {
  position: fixed; inset: 0; z-index: 80;
  display: flex; justify-content: flex-end;
}
.sup-drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.32);
  animation: sup-fade-in .15s ease-out;
}
.sup-drawer {
  position: relative; z-index: 1;
  width: min(720px, 92%);
  background: var(--bg-surface);
  box-shadow: -12px 0 32px rgba(15, 23, 42, .18);
  display: flex; flex-direction: column;
  overflow-y: auto;
  animation: sup-slide-in .22s cubic-bezier(.22, 1, .36, 1);
}
.sup-drawer-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: white;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-muted); cursor: pointer;
}
.sup-drawer-close:hover { background: var(--bg-app); color: var(--ink-strong); }
@keyframes sup-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sup-slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Drawer-specific tweaks for the existing detail panel.
   The base .sup-detail / .sup-thread were tuned for the old inline panel
   (max-height + their own internal scroll). Inside a drawer that traps
   the scroll — the drawer itself can't reach its overflow because the
   inner panel is overflow:hidden and the thread takes flex:1 with its
   own overflow:auto. Undo all of that so the drawer's overflow-y is
   the single scroll surface, and the natural document flow drives
   layout. */
.sup-drawer .sup-detail {
  position: static; box-shadow: none; border-radius: 0;
  display: block; max-height: none;
  overflow: visible;
}
.sup-drawer .sup-thread {
  flex: none;
  overflow: visible;
  max-height: none;
}
.sup-drawer .sup-detail-empty {
  box-shadow: none; border-radius: 0;
}

/* Pin the close button to the drawer's top-right corner so it stays
   reachable while the user scrolls the drawer body. position:absolute
   + a scrollable ancestor would scroll the button out of view; fixed
   positions it relative to the viewport (the drawer is already flush
   to the viewport's right edge via its container). */
.sup-drawer-close {
  position: fixed;
  z-index: 90;
}

/* Section header inside drawer (Responder chain / Notifications fired) */
.sup-detail-section {
  margin: 14px 18px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.sup-detail-section-head {
  display: flex; align-items: baseline; gap: 8px;
}
.sup-detail-section-title {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--ink-strong); text-transform: uppercase;
}
.sup-detail-section-sub { font-size: 11px; color: var(--ink-faint); }

/* Inline "credits" editor in the detail-controls row */
.sup-credits-edit input {
  font: inherit; font-size: 12.5px; padding: 4px 8px; width: 64px;
  border: 1px solid var(--border); border-radius: 6px; background: white;
  color: var(--ink-strong);
}
.sup-credits-edit input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.sup-credits-reset {
  font: inherit; font-size: 11px; padding: 2px 6px; margin-left: 4px;
  border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: var(--ink-faint); cursor: pointer;
}
.sup-credits-reset:hover { background: var(--bg-app); color: var(--ink-strong); }

/* Linked-task chip on the escalate bar */
.sup-escalate-linked {
  font-size: 12px; color: var(--brand-dark); font-weight: 600;
  background: var(--brand-soft); padding: 4px 10px; border-radius: 999px;
  font-family: ui-monospace, monospace;
}
