/* ============================================================
   SMART REFER HUB — Shared widgets
   Mobile navigation drawer, compact top bar,
   WhatsApp chat + assistant chat floating buttons.
============================================================ */

:root {
  --srh-blue: #1a3c6e;
  --srh-blue-dark: #122c52;
  --srh-gold: #f4a51e;
  --srh-wa: #25d366;
  --srh-wa-dark: #128c7e;
  --srh-wa-deep: #075e54;
  --srh-ink: #1b2a41;
  --srh-muted: #6b7a90;
  --srh-line: #e3e9f2;
}

/* ---------- Back-to-top moves left so it never collides with the chat buttons ---------- */
#back-top {
  left: 20px !important;
  right: auto !important;
  bottom: 20px !important;
}

/* ============================================================
   MOBILE TOP BAR — one compact row
============================================================ */
@media (max-width: 640px) {
  #top-bar { padding: 6px 0 !important; font-size: .74rem !important; }
  #top-bar .container { justify-content: center !important; gap: 0 !important; }
  #top-bar .top-bar-left { display: none !important; }
  #top-bar .top-bar-right { gap: 16px !important; flex-wrap: nowrap !important; justify-content: center; }
  #top-bar .top-bar-item { white-space: nowrap; }
}
@media (max-width: 350px) {
  #top-bar .top-bar-right a[href^="mailto:"] { display: none !important; }
}

/* ============================================================
   MOBILE NAVIGATION DRAWER
============================================================ */
.srh-nav-backdrop,
.srh-drawer-head,
.srh-drawer-meta { display: none; }

@media (max-width: 860px) {
  .nav-inner { padding: 10px 18px !important; }
  .nav-logo-img { height: 46px !important; }

  /* Hamburger button */
  #nav-toggle {
    display: flex !important;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    gap: 5px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    background: #f2f5fa !important;
    transition: background .2s;
  }
  #nav-toggle:hover { background: #e6ecf5 !important; }
  #nav-toggle span { width: 20px !important; transition: transform .25s ease, opacity .2s ease !important; }
  #nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  #nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  #nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Drawer panel */
  .nav-links {
    display: flex !important;
    position: fixed !important;
    top: 0 !important; right: 0 !important; bottom: 0 !important; left: auto !important;
    width: min(86vw, 340px) !important;
    height: 100vh; height: 100dvh;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 0 16px 20px !important;
    background: #fff !important;
    border: 0 !important;
    box-shadow: -20px 0 50px rgba(10, 30, 60, .2) !important;
    overflow-y: auto;
    z-index: 1000 !important;
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .32s;
  }
  .nav-links.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s;
  }
  .nav-links > li { width: 100%; list-style: none; }

  /* Drawer header: logo + close button */
  .srh-drawer-head {
    display: flex !important;
    align-items: center; justify-content: space-between;
    padding: 14px 2px 14px;
    margin: 0 0 8px;
    border-bottom: 1px solid var(--srh-line);
    position: sticky; top: 0; background: #fff; z-index: 1;
  }
  .srh-drawer-head img { height: 42px; width: auto; display: block; }
  .srh-drawer-close {
    width: 40px; height: 40px; border-radius: 12px; border: 0;
    background: #f2f5fa; color: var(--srh-blue);
    display: grid; place-items: center; cursor: pointer;
    transition: background .2s;
  }
  .srh-drawer-close:hover { background: #e6ecf5; }

  /* Drawer links */
  .nav-links a {
    display: flex !important;
    align-items: center; justify-content: space-between;
    width: 100% !important;
    padding: 14px 16px !important;
    border: 0 !important;
    border-radius: 12px;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--srh-ink) !important;
    transition: background .18s, color .18s !important;
  }
  .nav-links a:not(.nav-cta)::after {
    content: "";
    width: 8px; height: 8px;
    border-right: 2px solid #b4c0d3; border-top: 2px solid #b4c0d3;
    transform: rotate(45deg);
    flex-shrink: 0;
    transition: border-color .18s;
  }
  .nav-links a:not(.nav-cta):hover,
  .nav-links a:not(.nav-cta).active {
    background: #f1f5fb;
    color: var(--srh-blue) !important;
  }
  .nav-links a:not(.nav-cta).active { box-shadow: inset 3px 0 0 var(--srh-gold); }
  .nav-links a:not(.nav-cta):hover::after,
  .nav-links a:not(.nav-cta).active::after { border-color: var(--srh-blue); }

  /* Contact CTA inside drawer */
  .nav-links .nav-cta {
    justify-content: center !important;
    margin: 12px 0 0 !important;
    width: 100% !important;
    padding: 15px 16px !important;
    border-radius: 12px !important;
    font-size: 1rem !important;
    color: #fff !important;
  }

  /* Quick contact block at drawer bottom */
  .srh-drawer-meta {
    display: block !important;
    margin-top: auto;
    padding: 18px 4px 4px;
    border-top: 1px solid var(--srh-line);
    font-size: .85rem;
    color: var(--srh-muted);
  }
  .srh-drawer-meta a {
    display: flex !important; align-items: center; gap: 10px;
    justify-content: flex-start !important;
    padding: 8px 0 !important;
    font-size: .9rem !important; font-weight: 600 !important;
    color: var(--srh-ink) !important;
    background: none !important; box-shadow: none !important;
  }
  .srh-drawer-meta a::after { display: none !important; }
  .srh-drawer-meta svg { color: var(--srh-blue); flex-shrink: 0; }
  .srh-drawer-meta p { margin: 8px 0 0; line-height: 1.5; }

  /* Backdrop */
  .srh-nav-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(9, 22, 45, .45);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden;
    transition: opacity .3s, visibility 0s linear .3s;
    z-index: 99;
  }
  body.srh-nav-open .srh-nav-backdrop {
    opacity: 1; visibility: visible;
    transition: opacity .3s, visibility 0s;
  }
  body.srh-nav-open { overflow: hidden; }
}

/* ============================================================
   FLOATING ACTION BUTTONS
============================================================ */
.srh-fabs {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 900;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  transition: opacity .2s;
}
body.srh-nav-open .srh-fabs { opacity: 0; visibility: hidden; pointer-events: none; }

.srh-fab {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(10, 30, 60, .25);
  transition: transform .2s ease, box-shadow .2s ease, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.srh-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(10, 30, 60, .3); }
.srh-fab:focus-visible { outline: 3px solid rgba(244, 165, 30, .7); outline-offset: 3px; }
.srh-fab--wa { background: var(--srh-wa); }
.srh-fab--wa:hover { background: #20bd5a; }
.srh-fab--bot { background: var(--srh-blue); }
.srh-fab--bot:hover { background: var(--srh-blue-dark); }

.srh-fab .srh-ico-close { display: none; }
.srh-fab[aria-expanded="true"] .srh-ico-open { display: none; }
.srh-fab[aria-expanded="true"] .srh-ico-close { display: block; }

/* Pulse ring on WhatsApp button */
.srh-fab--wa::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--srh-wa);
  animation: srh-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
.srh-fab--wa[aria-expanded="true"]::before { display: none; }
@keyframes srh-pulse {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* Hover label (desktop) */
.srh-fab-label {
  position: absolute;
  right: calc(100% + 12px); top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: var(--srh-ink);
  color: #fff;
  font-size: .8rem; font-weight: 600;
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
@media (hover: hover) {
  .srh-fab:hover .srh-fab-label { opacity: 1; transform: translateY(-50%) translateX(0); }
  .srh-fab[aria-expanded="true"] .srh-fab-label { opacity: 0 !important; }
}

/* Unread badge on assistant */
.srh-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px;
  background: #e5484d; color: #fff;
  font-size: .7rem; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid #fff;
}

/* ============================================================
   CHAT PANELS (shared)
============================================================ */
.srh-panel {
  position: fixed;
  right: 20px; bottom: 92px;
  width: 372px;
  max-width: calc(100vw - 24px);
  height: min(580px, calc(100vh - 120px));
  height: min(580px, calc(100dvh - 120px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(10, 30, 60, .28), 0 2px 8px rgba(10, 30, 60, .08);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 950;
  font-family: inherit;
  transform-origin: bottom right;
  opacity: 0; visibility: hidden;
  transform: translateY(14px) scale(.97);
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.srh-panel.open {
  opacity: 1; visibility: visible;
  transform: none;
  transition: opacity .22s ease, transform .22s ease, visibility 0s;
}
body.srh-nav-open .srh-panel { opacity: 0 !important; pointer-events: none; }

.srh-panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 16px;
  color: #fff;
  flex-shrink: 0;
}
.srh-avatar {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.srh-avatar img { width: 36px; height: 36px; object-fit: contain; }
.srh-avatar--bot { color: var(--srh-blue); }
.srh-online {
  position: absolute; right: 1px; bottom: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #31d17c; border: 2px solid #fff;
}
.srh-head-text { flex: 1; min-width: 0; line-height: 1.25; }
.srh-head-text strong { display: block; font-size: .98rem; font-weight: 700; }
.srh-head-text span { display: block; font-size: .76rem; opacity: .85; }
.srh-panel-close {
  width: 34px; height: 34px; border-radius: 10px; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: background .2s;
}
.srh-panel-close:hover { background: rgba(255, 255, 255, .26); }

.srh-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex; flex-direction: column; gap: 8px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.srh-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: srh-in .22s ease;
}
.srh-msg p { margin: 0 0 6px; }
.srh-msg p:last-child { margin-bottom: 0; }
.srh-msg ul { margin: 6px 0; padding-left: 18px; }
.srh-msg li { margin: 2px 0; }
.srh-msg a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.srh-msg-time { display: block; margin-top: 4px; font-size: .68rem; opacity: .6; text-align: right; }
@keyframes srh-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.srh-typing {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 12px 14px !important;
}
.srh-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9aa6b8;
  animation: srh-dot 1.2s infinite ease-in-out;
}
.srh-typing i:nth-child(2) { animation-delay: .15s; }
.srh-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes srh-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

.srh-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 2px 0 4px;
  animation: srh-in .22s ease;
}
.srh-chip {
  border: 1px solid;
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: .8rem; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s, color .18s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.srh-chip:active { transform: scale(.97); }

.srh-panel-foot {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--srh-line);
  background: #fff;
  flex-shrink: 0;
}
.srh-input {
  flex: 1;
  width: auto !important;
  height: 44px;
  min-height: 44px !important; max-height: 120px;
  margin: 0 !important;
  resize: none;
  border: 1px solid var(--srh-line);
  border-radius: 22px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  line-height: 1.35;
  color: var(--srh-ink);
  background: #f6f8fb;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.srh-input:focus { background: #fff; }
.srh-send {
  width: 44px; height: 44px;
  border-radius: 50%; border: 0;
  display: grid; place-items: center;
  color: #fff; cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s, background .2s, opacity .2s;
}
.srh-send:active { transform: scale(.94); }
.srh-send:disabled { opacity: .45; cursor: not-allowed; }
.srh-powered {
  text-align: center;
  font-size: .68rem;
  color: var(--srh-muted);
  padding: 0 0 8px;
  background: #fff;
  flex-shrink: 0;
}
.srh-shake { animation: srh-shake .35s; }
@keyframes srh-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- WhatsApp theme ---------- */
.srh-panel--wa .srh-panel-head { background: linear-gradient(135deg, var(--srh-wa-deep), var(--srh-wa-dark)); }
.srh-panel--wa .srh-panel-body {
  background-color: #efeae2;
  background-image: radial-gradient(rgba(7, 94, 84, .07) 1px, transparent 1px);
  background-size: 14px 14px;
}
.srh-panel--wa .srh-msg--in {
  align-self: flex-start;
  background: #fff;
  color: var(--srh-ink);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
.srh-panel--wa .srh-msg--out {
  align-self: flex-end;
  background: #d9fdd3;
  color: var(--srh-ink);
  border-top-right-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
.srh-panel--wa .srh-chip { border-color: #b7e4c7; color: var(--srh-wa-deep); }
.srh-panel--wa .srh-chip:hover { background: #e7f8ec; }
.srh-panel--wa .srh-input:focus { border-color: var(--srh-wa); box-shadow: 0 0 0 3px rgba(37, 211, 102, .15); }
.srh-panel--wa .srh-send { background: var(--srh-wa); }
.srh-panel--wa .srh-send:hover:not(:disabled) { background: #20bd5a; }
.srh-day {
  align-self: center;
  background: rgba(255, 255, 255, .85);
  color: var(--srh-muted);
  font-size: .72rem; font-weight: 600;
  padding: 4px 10px; border-radius: 8px;
  margin-bottom: 4px;
}

/* ---------- Assistant theme ---------- */
.srh-panel--bot .srh-panel-head { background: linear-gradient(135deg, var(--srh-blue-dark), var(--srh-blue)); }
.srh-panel--bot .srh-panel-body { background: #f5f7fb; }
.srh-panel--bot .srh-msg--in {
  align-self: flex-start;
  background: #fff;
  color: var(--srh-ink);
  border: 1px solid var(--srh-line);
  border-top-left-radius: 4px;
}
.srh-panel--bot .srh-msg--out {
  align-self: flex-end;
  background: var(--srh-blue);
  color: #fff;
  border-top-right-radius: 4px;
}
.srh-panel--bot .srh-chip { border-color: #c9d5e8; color: var(--srh-blue); }
.srh-panel--bot .srh-chip:hover { background: var(--srh-blue); color: #fff; border-color: var(--srh-blue); }
.srh-panel--bot .srh-chip--wa { border-color: #b7e4c7; color: var(--srh-wa-deep); }
.srh-panel--bot .srh-chip--wa:hover { background: var(--srh-wa); border-color: var(--srh-wa); color: #fff; }
.srh-panel--bot .srh-input:focus { border-color: var(--srh-blue); box-shadow: 0 0 0 3px rgba(26, 60, 110, .12); }
.srh-panel--bot .srh-send { background: var(--srh-blue); }
.srh-panel--bot .srh-send:hover:not(:disabled) { background: var(--srh-blue-dark); }

/* ---------- Small screens: panels become bottom sheets ---------- */
@media (max-width: 480px) {
  .srh-fabs { right: 14px; bottom: 14px; gap: 10px; }
  .srh-fab { width: 54px; height: 54px; }
  #back-top { left: 14px !important; bottom: 14px !important; }

  .srh-panel {
    left: 10px; right: 10px; bottom: 82px;
    width: auto; max-width: none;
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px);
    max-height: 640px;
    border-radius: 18px;
    transform-origin: bottom center;
  }
  .srh-msg { max-width: 90%; }
  /* While a chat is open, show only that chat's button (as the close control) */
  .srh-fabs.srh-has-open .srh-fab[aria-expanded="false"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .srh-fab--wa::before { animation: none; }
  .srh-panel, .nav-links, .srh-msg, .srh-chips { transition: none !important; animation: none !important; }
}

/* ============================================================
   SMALL LAYOUT FIXES
============================================================ */
/* Each phone number / email on its own line in contact blocks */
.cd-text a, .cb-body a { display: block; }

/* Keep footer text clear of the floating buttons on phones */
@media (max-width: 640px) {
  #footer .footer-bottom { padding-bottom: 88px; }
}
