/* ===========================================================
   SereniBroker — Tabler theme overrides
   Brand colors layered on top of Tabler's base variables.
=========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  --tblr-primary: #0B7D91;
  --tblr-primary-rgb: 11, 125, 145;
  --sb-teal: #0B7D91;
  --sb-teal-light: #60AAB7;
  --sb-teal-tint: #EAF4F3;
  --sb-dark-teal: #183C66;
  --sb-font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Unified radius + shadow scale — every card/button/input pulls from
     these instead of hand-picked pixel values per component. */
  --sb-radius-sm: 10px;
  --sb-radius-md: 14px;
  --sb-radius-lg: 20px;
  --sb-shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --sb-shadow-md: 0 8px 24px rgba(15,23,42,0.06), 0 2px 6px rgba(15,23,42,0.04);
  --sb-shadow-lg: 0 16px 40px rgba(15,23,42,0.10), 0 4px 10px rgba(15,23,42,0.05);
}

body {
  background: #FAFBFC;
}

/* Tabler paints its own background on .page-wrapper/.page (via its own
   CSS variables), which was sitting on top of and muting the body
   gradient above — that's why the live page read grayer/bluer than the
   mockup even though body itself was already set correctly. */
html, .page, .page-wrapper {
  background-color: #FAFBFC !important;
}

h1, h2, h3, h4, h5, h6,
.page-title, .card-title, .navbar-brand,
.btn-brand, .btn-outline-brand {
  font-family: var(--sb-font-display);
}

h1, h2, h3, .page-title { letter-spacing: -0.01em; }

.card {
  background-color: #ffffff !important;
  box-shadow: var(--sb-shadow-md);
  border: 1px solid #f1f3f6;
  border-radius: var(--sb-radius-md);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.text-brand { color: var(--sb-dark-teal); font-weight: 700; }
.bg-brand-lt { background-color: var(--sb-teal-tint) !important; }
.text-brand { color: var(--sb-teal); }

.btn-brand {
  background: var(--sb-teal);
  border-color: var(--sb-teal);
  color: #fff;
  border-radius: var(--sb-radius-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-brand:hover {
  background: var(--sb-teal);
  border-color: var(--sb-teal);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(11, 125, 145, 0.35);
}
.btn-brand:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 3px rgba(11, 125, 145, 0.25);
}
.btn-brand:disabled {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #64748b;
  opacity: 1;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-outline-brand {
  background-color: transparent;
  border-color: var(--sb-teal);
  color: var(--sb-teal);
  border-radius: var(--sb-radius-sm);
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-outline-brand:hover {
  background-color: var(--sb-teal);
  border-color: var(--sb-teal);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(11, 125, 145, 0.25);
}
.btn-outline-brand:active {
  transform: translateY(0) scale(0.98);
}

/* Branded loading indicator — three bouncing dots in brand teal, replaces
   plain "Updating…" text-only states or the generic gray Bootstrap spinner.
   Usage: <span class="sb-dots"><span></span><span></span><span></span></span>
   Sized to sit inline next to button text via font-size/vertical-align. */
.sb-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  vertical-align: middle;
}
.sb-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: sbDotsBounce 1s ease-in-out infinite;
}
.sb-dots span:nth-child(2) { animation-delay: 0.15s; }
.sb-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sbDotsBounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* Stat cards — colored left border per urgency, matches original design */
.stat-card {
  border-left: 4px solid var(--tblr-border-color);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--sb-shadow-lg); transform: translateY(-2px); }
.stat-card.active { outline: 2px solid var(--sb-teal); outline-offset: -1px; }

.list-group-item-action:hover {
  background-color: #f6faf9;
}

.stat-card.coral { border-left-color: #e8590c; }
.stat-card.amber { border-left-color: #ca8a04; }
.stat-card.teal-card { border-left-color: #0f8a7a; }
.stat-card.blue-card { border-left-color: #1c4c9e; }
.stat-card.gray { border-left-color: #666; }

/* Urgency tier tag + pulse — sits above the stat-card number so "Query
   Raised" reads as action-required at a glance, not just another card
   with the rest at equal visual weight. */
.tier-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.tier-tag.action { background: #FBEAE8; color: #C0392B; }
.tier-tag.wait { background: #FBF3D8; color: #8a6d0f; }
.tier-tag.pipeline { background: #E7EDF9; color: #1c4c9e; }
.stat-card { position: relative; }
.stat-card .tier-pulse {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #C0392B;
  box-shadow: 0 0 0 0 rgba(192,57,43,0.5);
  animation: sbPulse 1.8s infinite;
}
@keyframes sbPulse {
  0% { box-shadow: 0 0 0 0 rgba(192,57,43,0.45); }
  70% { box-shadow: 0 0 0 8px rgba(192,57,43,0); }
  100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); }
}

/* Segmented breakdown bar — replaces the Chart.js donuts on the dashboard
   (Document Processing / Clearance) and the client portal's "Shipments at
   a Glance". Each segment is a clickable filter, same as a chart slice was. */
.breakdown-total { font-weight: 800; font-size: 1.25rem; }
.breakdown-total .unit { font-size: 0.75rem; font-weight: 600; color: var(--tblr-secondary, #6c7a91); margin-left: 4px; }
.seg-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef0f3;
  margin: 12px 0 12px;
}
.seg-bar-segment {
  height: 100%;
  width: 0%; /* animated to its real width via JS after mount */
  cursor: pointer;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1), filter 0.15s ease, opacity 0.15s ease;
}
.seg-bar-segment:hover { filter: brightness(0.92); }
.seg-bar-segment.dimmed { opacity: 0.35; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; }
.seg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--tblr-secondary, #6c7a91);
  transition: opacity 0.15s ease;
  background: none;
  border: none;
  padding: 0;
}
.seg-legend-item.dimmed { opacity: 0.4; }
.seg-legend-item.selected { color: #1A2130; font-weight: 600; }
.seg-legend-item .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Sparkline trend lines in the Performance sidebar KPI cards. The stroke
   "draws in" on load via a dash-offset animation rather than just appearing. */
.kpi-trend-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-delta { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.kpi-delta.up { color: #1e7e63; }
.kpi-delta.down { color: #C0392B; }
.kpi-delta.flat { color: var(--tblr-secondary, #6c7a91); }
.sparkline-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Status pills reuse Tabler's badge component with custom color mapping */
.status-pill {
  text-transform: capitalize;
  padding: 0.35rem 0.75rem !important;
  border-radius: 12px !important;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

#history-list .list-group-item {
  border-bottom: 1px solid #e9ecef !important;
}
#history-list .list-group-item:last-child {
  border-bottom: none !important;
}
.status-pill.query_raised { background-color: #fde4d3; color: #e8590c; } /* label-only, not a real declaration status */
.status-pill.draft { background-color: #eee; color: #666; }
.status-pill.awaiting_arrival { background-color: #d3ede9; color: #0f8a7a; }
.status-pill.vessel_arrived { background-color: #cfeef7; color: #0891b2; }
.status-pill.submitted { background-color: #e3ecfb; color: #1c4c9e; }
.status-pill.approved { background-color: #fff3cd; color: #8a6d0f; }
.status-pill.awaiting_payment { background-color: #f7e7b8; color: #ca8a04; }
.status-pill.payment_received { background-color: #eef3d0; color: #6b7f1f; }
.status-pill.paid_at_customs { background-color: #fdf0c7; color: #92620a; }
.status-pill.delivery_received { background-color: #ede3fb; color: #5b2fa8; }
.status-pill.lodged_for_clearance { background-color: #f3e0f7; color: #8e24aa; }
.status-pill.under_examination { background-color: #fce4ec; color: #ad1457; }
.status-pill.cleared { background-color: #e3f6e3; color: #2b7a2b; }
.status-pill.ready_for_collection { background-color: #dcf5ec; color: #157a52; }
.status-pill.out_for_delivery { background-color: #ffe4d1; color: #c2410c; }

/* Message thread bubbles — used on both the client portal and the broker
   declaration-detail page, styled by "mine" vs "theirs" relative to the
   currently logged-in user, not by role, so the same CSS works for both. */
.message-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 2px;
}
.message-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(15,23,42,0.08);
}
.message-bubble.mine {
  align-self: flex-end;
  background: #dde1e6;
  color: #222;
  border-bottom-right-radius: 2px;
}
.message-bubble.theirs {
  align-self: flex-start;
  background: #f1f3f5;
  color: #222;
  border-bottom-left-radius: 2px;
}
.message-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}
.message-attachment {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  text-decoration: underline;
  color: inherit;
}

/* Notification bell badge — force a true circle (fixed equal width/height)
   rather than relying on Bootstrap's default badge padding, which only
   looks round for single characters and turns pill-shaped otherwise. */
#notif-badge {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  color: #fff;
}

/* Notification dropdown — the width itself is set inline per page (kept
   viewport-safe there); this just caps how tall the list can grow and lets
   it scroll instead of pushing content off-screen when there are many
   notifications. */
#notif-list {
  max-height: 60vh;
  overflow-y: auto;
}
#notif-list .notif-item {
  white-space: normal;
}
.status-pill.lodged_for_ces { background-color: #e6e0f7; color: #4527a0; }
.status-pill.awaiting_ces_decision { background-color: #f0e0f0; color: #7b1fa2; }
.status-pill.examination_scheduled { background-color: #efe4dc; color: #6d4c41; }
.status-pill.released,
.status-pill.completed { background-color: #d8f0e8; color: #1e7e63; }
.status-pill.port_release_arranged { background-color: #e2f0d8; color: #4a7a1f; }

.declaration-row {
  text-decoration: none;
  color: inherit;
  display: block;
}
.declaration-row:hover { text-decoration: none; color: inherit; }
/* Fallback for the mobile nav toggle (js/mobileMenu.js). Guarantees the
   collapsed menu actually shows/hides on narrow screens even if Tabler's
   own CSS or JS bundle behaves unexpectedly for any reason. */
@media (max-width: 991.98px) {
  .navbar-collapse:not(.show) { display: none; }
  .navbar-collapse.show {
    display: block;
    width: 100%;
  }
}

/* Client-facing shipment progress timeline. Milestone positions only ever
   change on page load/refresh (when the underlying status actually changed)
   — the gentle bounce on the current node is ambient motion, not a claim of
   live real-time tracking, since status updates are broker-entered, not
   automatic. */
.timeline-track {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding: 10px 0 4px;
}
.timeline-line {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  z-index: 0;
}
.timeline-line-fill {
  position: absolute;
  top: 24px;
  left: 24px;
  height: 4px;
  width: calc(var(--progress, 0) * 100%);
  background: var(--sb-teal, #1F9E92);
  border-radius: 2px;
  z-index: 1;
  transition: width 0.6s ease;
}
.timeline-node {
  flex: 1;
  position: relative;
  z-index: 2;
  text-align: center;
}
.timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 3px solid #fff;
  margin: 0 auto 8px;
  box-shadow: 0 0 0 2px #e5e7eb;
}
.timeline-node.done .timeline-dot {
  background: var(--sb-teal, #1F9E92);
  box-shadow: 0 0 0 2px var(--sb-teal, #1F9E92);
}
.timeline-node.current .timeline-dot {
  background: var(--sb-teal, #1F9E92);
  box-shadow: 0 0 0 2px var(--sb-teal, #1F9E92);
  animation: timeline-pulse 1.8s ease-in-out infinite;
}
.timeline-label {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.3;
}
.timeline-node.current .timeline-label {
  color: var(--sb-teal, #1F9E92);
  font-weight: 600;
}
.timeline-package {
  position: absolute;
  top: -8px;
  left: calc(var(--progress, 0) * 100%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #E8590C;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(232, 89, 12, 0.35), 0 0 0 3px #fff;
  transform: translateX(-50%);
  transition: left 0.6s ease, top 0.6s ease;
  animation: timeline-bounce 1.6s ease-in-out infinite;
  z-index: 3;
}

@keyframes timeline-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--sb-teal, #1F9E92); }
  50% { box-shadow: 0 0 0 6px rgba(31, 158, 146, 0.25); }
}
@keyframes timeline-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -5px); }
}

/* Narrow screens: stack vertically instead of squeezing 4 nodes horizontally.
   Widened past the old 480px cutoff to also catch larger phones in portrait
   (many report 480–600px of logical width) that were still hitting the
   cramped horizontal layout. */
@media (max-width: 600px) {
  .timeline-track { flex-direction: column; align-items: stretch; padding: 4px 0; }
  .timeline-line, .timeline-line-fill {
    top: 0; bottom: 0; left: 9px; right: auto; width: 4px; height: auto;
  }
  .timeline-line-fill {
    height: calc(var(--progress, 0) * 100%);
    width: 4px;
    transition: height 0.6s ease;
  }
  .timeline-node { display: flex; align-items: center; text-align: left; padding: 10px 0; }
  .timeline-dot { margin: 0 12px 0 0; flex-shrink: 0; }
  .timeline-package {
    left: -4px !important;
    top: calc(var(--progress, 0) * 100%);
    transform: translateY(-50%);
  }
  @keyframes timeline-bounce {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(5px); }
  }
}

/* Top nav icons sit slightly high/tight against their labels by Tabler's
   default — nudge down a touch and add a hair more spacing before the text. */
.navbar-nav .nav-link-icon {
  margin-right: 0.3rem;
  position: relative;
  top: 2px;
}

/* Dashboard's Performance sidebar: the 4 KPI cards dashboard.js generates
   are sized (col-sm-6 col-lg-3) to sit 4-across in a full-width row.
   Nested in the narrower sidebar column instead, that same math would
   quarter an already-narrow parent — override to stack single-column
   here specifically, without touching dashboard.js's card-generation code. */
.performance-sidebar #kpi-cards > div {
  flex: 0 0 100%;
  max-width: 100%;
}

/* Universal button feel — applies to every button on every page, not just
   .btn-brand. Tabler's own outline variants (danger/primary/secondary etc.)
   had no lift/press feedback before; this gives all of them the same
   subtle modern feel without needing to hand-color each variant's shadow.
   Excludes the brand classes since they already define their own
   color-matched shadow, and being defined earlier in this file would
   otherwise get silently overridden by this later, equal-specificity rule. */
.btn:not(.btn-brand):not(.btn-outline-brand):not(.btn-brand-solid):not(.btn-brand-outline) {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:not(.btn-brand):not(.btn-outline-brand):not(.btn-brand-solid):not(.btn-brand-outline):hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}
.btn:not(.btn-brand):not(.btn-outline-brand):not(.btn-brand-solid):not(.btn-brand-outline):active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}
.btn:disabled,
.btn.disabled {
  transform: none;
  box-shadow: none;
}

/* Top nav: icon-only, no text labels. Kept as a stylesheet rule (not removed
   from each page's markup) so it survives future edits/reverts to the HTML. */
.navbar-nav .nav-link-title {
  display: none !important;
}
@media (max-width: 767.98px) {
  /* Tooltips don't work on mobile, so keep the text labels there */
  .navbar-nav .nav-link-title {
    display: inline !important;
  }
}
.navbar-nav .nav-link-icon {
  margin-right: 0 !important;
  font-size: 1.5rem !important;
  width: 1.5rem !important;
  height: 1.5rem !important;
}
.navbar-nav .nav-link {
  padding-left: 0.85rem !important;
  padding-right: 0.85rem !important;
}
.navbar-nav .nav-item {
  margin-right: 0.65rem;
}
/* Center the main icon nav (dashboard/new/clients/scan) in the header,
   independent of the bell and profile menu on either side, and give the
   icons themselves more breathing room. */
@media (min-width: 768px) {
  .navbar .container-xl {
    position: relative;
  }
  .navbar-nav:not(.flex-row) {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    gap: 0.5rem !important;
    transition: top 0.2s ease, bottom 0.2s ease, transform 0.2s ease;
  }
}

/* Once scrolled, drop the icon nav to a fixed bar at the bottom of the
   screen instead of sitting in the header. Toggled by js/mobileMenu.js.
   Desktop only (md+) — on narrow phones this ended up overlapping page
   content near the bottom of the screen, and the normal collapsible top
   nav already works fine there, so mobile just keeps that instead. */
@media (min-width: 768px) {
  body.nav-bottom {
    padding-bottom: 4.25rem;
  }
  body.nav-bottom .navbar-nav:not(.flex-row) {
    position: fixed !important;
    top: auto !important;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none !important;
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin: 0;
    padding: 0.6rem 0.5rem;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: 1030;
  }
  body.nav-bottom .navbar-nav:not(.flex-row) .nav-item {
    margin-right: 0;
  }
}
/* Notification bell + icon nav group: more breathing room, bigger bell */
.navbar > .container-xl > div.d-flex.align-items-center.ms-auto > .nav-item.dropdown.me-2 {
  margin-right: 1.75rem !important;
}
.navbar > .container-xl > div.d-flex.align-items-center.ms-auto .ti-bell {
  font-size: 1.5rem !important;
}
@media (min-width: 768px) {
  #navbar-menu {
    margin-left: 1rem;
  }
}
