/* ==========================================================================
   CMS-4955 (v3.0) — Authority Matrix deviation UI. Reusable across Quote &
   Booking. ALL selectors are prefixed `authority-` so nothing here can affect
   existing quote-dashboard / design-system styles. Colours reproduced from the
   approved mockup (Screen 2 - Quote Dashboard - Full Updated.html). Styling only.
   ========================================================================== */

/* ---- Authority banner (shows the user's level + allowed range) ---- */
.authority-banner {
  background: #e3f2fd; border: 1px solid #90caf9; border-radius: 4px;
  padding: 8px 14px; margin: 8px 0; display: flex; align-items: center;
  gap: 12px; font-size: 11px; flex-wrap: wrap;
}
.authority-banner-badge {
  background: #1565c0; color: #fff; padding: 2px 10px; border-radius: 10px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.authority-banner-range { font-weight: 700; color: #1565c0; }
.authority-banner-note { margin-left: auto; font-size: 10px; color: #757575; }

/* ---- Live deviation banner ---- */
.authority-deviation-banner {
  border-radius: 4px; padding: 10px 14px; margin: 8px 0;
  display: flex; align-items: flex-start; gap: 10px;
}
.authority-deviation-ok      { background: #e8f5e9; border: 1px solid #a5d6a7; }
.authority-deviation-warning { background: #fff8e1; border: 1px solid #ffe082; }
.authority-deviation-danger  { background: #ffebee; border: 1px solid #ef9a9a; }
.authority-deviation-percent { font-size: 18px; font-weight: 800; min-width: 60px; }
.authority-deviation-text { font-size: 11px; line-height: 1.4; }
.authority-deviation-text strong { display: block; margin-bottom: 2px; }

/* ---- Sell-rate input border states (applied via ng-class on the rate field) ---- */
.authority-rate-ok      { border: 2px solid #43a047 !important; }
.authority-rate-warning { border: 2px solid #ff8f00 !important; }
.authority-rate-danger  { border: 2px solid #b71c1c !important; }

/* ---- Deviation value colours (deviation field / edit-grid cell + RES grid Deviation column) ---- */
.authority-deviation-value-ok      { color: #2e7d32; font-weight: 700; }
.authority-deviation-value-warning { color: #e65100; font-weight: 700; }
.authority-deviation-value-danger  { color: #b71c1c; font-weight: 700; }
.authority-deviation-value-neutral { color: #757575; font-weight: 700; }

/* ---- AM Status pills (RES grid) — one uniform system: same shape/size, colour by state ----
   .authority-badge-ok (green) / -pending (amber) / -hold (red) / -rejected (grey). */
.authority-badge-ok,
.authority-badge-pending,
.authority-badge-hold,
.authority-badge-rejected {
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700;
  display: inline-block; white-space: nowrap;
}
.authority-badge-ok       { background: #e8f5e9; color: #2e7d32; }  /* Within Authority / Approved / Revised */
.authority-badge-pending  { background: #fff3e0; color: #e65100; }  /* Pending L* (amber) */
.authority-badge-hold     { background: #ffebee; color: #c62828; }  /* On Hold — SLA (red) */
.authority-badge-rejected { background: #f5f5f5; color: #757575; }  /* Rejected (grey) */
.authority-badge-icon     { margin-right: 4px; font-weight: 700; }
.authority-kpi-pending-count { color: #e65100; }
/* Neutral note when a matrix is active but the lane has no tariff to check against */
.authority-no-tariff-note {
  background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 4px;
  padding: 6px 12px; margin: 8px 0; font-size: 11px; color: #757575;
}
/* "PENDING APPROVAL" is the longest KPI label; keep it on ONE line (the extra 6th card
   narrows every card, wrapping the two words). Specificity beats `.dashboard-filter-box .heading`. */
.dashboard-filter-box .heading.authority-kpi-heading { white-space: nowrap; font-size: 11px; }
/* Grid status-cell tint for the On Hold "Awaiting Approval" state (blue, per mockup "Pending Approval") */
.status-bg.authority-status-pending { background: #e3f2fd; color: #1565c0; }

/* ---- Approval modal (single global overlay) ---- */
.authority-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.authority-modal-box {
  background: #fff; border-radius: 8px; width: 560px; max-width: 96vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); overflow: hidden;
  font-family: inherit; color: #333;
}
.authority-modal-top {
  padding: 18px 20px 14px; display: flex; align-items: flex-start; gap: 14px;
  border-bottom: 1px solid #e0e0e0;
}
.authority-modal-top-warning { background: #fff8e1; }
.authority-modal-top-danger  { background: #ffebee; }
.authority-modal-top-icon {
  width: 44px; height: 44px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.authority-modal-icon-warning { background: #ffe082; color: #e65100; }
.authority-modal-icon-danger  { background: #ef9a9a; color: #b71c1c; }
.authority-modal-title { font-size: 14px; font-weight: 800; margin-bottom: 3px; }
.authority-modal-subtitle { font-size: 11px; color: #757575; }
.authority-modal-source-tag {
  margin-left: auto; background: #e3f2fd; color: #1565c0; padding: 3px 10px;
  border-radius: 10px; font-size: 9px; font-weight: 700; white-space: nowrap; align-self: flex-start;
}
.authority-modal-info-bar { display: flex; align-items: stretch; border-bottom: 1px solid #e0e0e0; }
.authority-modal-info-cell { flex: 1; padding: 12px 14px; text-align: center; border-right: 1px solid #e0e0e0; }
.authority-modal-info-cell:last-child { border-right: none; }
.authority-modal-info-label {
  font-size: 9px; text-transform: uppercase; font-weight: 700; color: #757575;
  letter-spacing: 0.4px; margin-bottom: 4px;
}
.authority-modal-info-value { font-size: 15px; font-weight: 800; }
.authority-value-red   { color: #d32f2f; }
.authority-value-amber { color: #ff8f00; }
.authority-modal-info-sub { font-size: 9px; color: #757575; margin-top: 2px; }
.authority-modal-escalation {
  background: #e3f2fd; border-left: 4px solid #1565c0; padding: 10px 14px;
  margin: 14px 18px 0; border-radius: 0 4px 4px 0; font-size: 11px; color: #1565c0;
  display: flex; align-items: flex-start; gap: 8px;
}
.authority-modal-escalation-icon { flex-shrink: 0; font-weight: 800; line-height: 1.3; }
.authority-modal-body { padding: 14px 18px 0; }
.authority-modal-remarks-label { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.authority-required { color: #d32f2f; }
.authority-modal-remarks-hint { font-size: 10px; color: #757575; margin-bottom: 6px; }
.authority-modal-textarea {
  width: 100%; border: 1px solid #e0e0e0; border-radius: 3px; padding: 8px 10px;
  font-size: 11px; font-family: inherit; resize: vertical; min-height: 75px; box-sizing: border-box;
}
.authority-modal-char-count { font-size: 10px; color: #757575; text-align: right; margin-top: 3px; }
.authority-modal-email-note { font-size: 10px; color: #757575; margin-top: 8px; display: flex; align-items: center; gap: 5px; }
.authority-modal-footer {
  padding: 12px 18px; border-top: 1px solid #e0e0e0; display: flex;
  align-items: center; justify-content: space-between; background: #fafafa; margin-top: 14px;
}
.authority-modal-btn-cancel {
  background: #fff; border: 1px solid #e0e0e0; color: #333; padding: 7px 16px;
  border-radius: 3px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.authority-modal-btn-submit {
  background: #ff8f00; color: #fff; border: none; padding: 7px 20px;
  border-radius: 3px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.authority-modal-btn-submit:hover { background: #e65100; }
.authority-modal-btn-submit[disabled] { background: #ccc; cursor: not-allowed; }

/* ---- RES/Booking dashboard KPI row (net-new; the list has no KPI cards) ---- */
.authority-kpi-row { display: flex; gap: 8px; margin: 8px 0; }
.authority-kpi-card {
  flex: 1; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px;
  padding: 8px 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.authority-kpi-card:hover { border-color: var(--ds-color-primary); }
.authority-kpi-card.selected { border-color: var(--ds-color-primary); box-shadow: 0 0 0 2px rgba(var(--ds-color-primary-rgb), .15); }
.authority-kpi-value { font-size: 20px; font-weight: 800; color: #212121; }
.authority-kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: #757575; font-weight: 600; }

/* ---- RES/Booking dashboard "pending approval" alert banner ---- */
.authority-list-alert {
  display: flex; align-items: center; gap: 10px; margin: 0 0 8px;
  padding: 8px 12px; border-radius: 4px; font-size: 11px;
  background: #fff8e1; color: #f57f17; border: 1px solid #ffe082;
}
.authority-list-alert-btn {
  margin-left: auto; background: #fff; border: 1px solid #f9a825; color: #e65100;
  padding: 4px 12px; border-radius: 3px; font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* ---- Booking View AM Status Bar (amber strip below the header) ---- */
.authority-am-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  background: #fff8e1; border: 1px solid #ffe082; border-radius: 4px;
  padding: 6px 12px; margin: 8px 0; font-size: 11px;
}
.authority-am-bar .authority-am-item { color: #212121; }
.authority-am-bar .authority-am-item strong { font-weight: 700; }
.authority-am-bar-btn {
  margin-left: auto; background: #fff; border: 1px solid #1565c0; color: #1565c0;
  padding: 3px 10px; border-radius: 3px; font-size: 10px; font-weight: 700; cursor: pointer;
}

/* ---- Approval Chain modal (read-only L1→L4 pipeline) ---- */
.authority-chain-row { display: flex; gap: 0; align-items: stretch; margin: 10px 0; }
.authority-chain-step {
  flex: 1; padding: 10px; border: 1px solid #e0e0e0; background: #fafafa; text-align: center;
}
.authority-chain-step:first-child { border-radius: 4px 0 0 4px; }
.authority-chain-step:last-child { border-radius: 0 4px 4px 0; }
.authority-chain-step.done    { border-color: #a5d6a7; background: #f1f8e9; }
.authority-chain-step.current { border-color: #ffe082; background: #fffde7; box-shadow: 0 0 0 2px rgba(249,168,37,.2); }
.authority-chain-step.waiting { opacity: .7; }
/* CMS-4955: the modal used to only recognize done/current/waiting — escalated/approved/rejected/withdrawn
   silently fell through to the unstyled base card above. Palette matches the already-correct pipeline
   renderer (design-system-v1.css .ap-pipe-*): approved reuses .done's green, escalated blue, rejected red.
   withdrawn ("Revised") is styled as a resolved-green outcome, matching .authority-badge-ok's convention
   for this same status elsewhere on this screen (PricingDashboardController.amRowStatusClass). Any future/
   unrecognized state string falls back to the plain, unstyled card above — neutral, not broken. */
.authority-chain-step.approved   { border-color: #a5d6a7; background: #f1f8e9; }
.authority-chain-step.escalated  { border-color: #90caf9; background: #e3f2fd; }
.authority-chain-step.rejected   { border-color: #ef9a9a; background: #ffebee; }
.authority-chain-step.withdrawn  { border-color: #a5d6a7; background: #f1f8e9; }
.authority-chain-level { font-size: 9px; text-transform: uppercase; font-weight: 700; color: #757575; }
.authority-chain-name  { font-size: 11px; font-weight: 700; margin: 3px 0; }
.authority-chain-role  { font-size: 10px; color: #757575; }
.authority-chain-state { font-size: 10px; font-weight: 700; margin-top: 4px; }
.authority-chain-state.done, .authority-chain-state.approved, .authority-chain-state.withdrawn { color: #2e7d32; }
.authority-chain-state.escalated { color: #1565c0; }
.authority-chain-state.current   { color: #f9a825; }
.authority-chain-state.rejected  { color: #c62828; }

/* ---- Edit-mode banner (shown when a saved quote is opened) ---- */
.authority-edit-mode-banner {
  background: #fff3e0; border: 1px solid #ffcc80; border-radius: 4px;
  padding: 8px 14px; margin: 0 0 10px; display: flex; align-items: center;
  justify-content: space-between; font-size: 11px; font-weight: 700; color: #e65100;
}
