/* Dashboard-derived navigation shared across admin and merchant pages. */
#portal-sidebar .ps-slide-user-avatar, #portal-header .portal-avatar { position: relative; overflow: hidden; border-radius: 50% !important; }
#portal-sidebar .ps-slide-user-avatar img, #portal-header .portal-avatar img { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: cover; object-position: center; border-radius: 50%; display: block; }
/* The image stays round; allow the camera control to sit outside the badge. */
html[data-portal-shell="merchant"] .merchant-round-badge { overflow: visible !important; }
html[data-portal-shell="merchant"] .welcome-company-logo-img { width: 100% !important; height: 100% !important; object-fit: cover !important; object-position: center; border-radius: 50% !important; min-height: 0; }
html[data-portal-shell] body {
  --portal-width: 255px;
}

html[data-portal-shell] body .portal-legacy-sidebar,
html[data-portal-shell] body .portal-legacy-header,
html[data-portal-shell] body .sidebar-arrow-btn,
html[data-portal-shell] body .admin-sidebar-collapse-toggle,
html[data-portal-shell] body #adminSidebarArrowBtn,
html[data-portal-shell] body #sidebarArrowBtn,
html[data-portal-shell] body #slideCloseBtn,
html[data-portal-shell] body #slideBarBackdrop,
html[data-portal-shell] body .slide-bar-backdrop {
  display: none !important;
}

html[data-portal-shell] body .portal-main {
  margin-left: var(--portal-width) !important;
  width: calc(100% - var(--portal-width)) !important;
  max-width: none !important;
  min-width: 0 !important;
  transform: none !important;
  padding-top: 0 !important;
  flex: 1 !important;
  height: auto !important;
  min-height: 100vh !important;
}

html[data-portal-shell] body .dashboard-app-layout,
html[data-portal-shell] body .layout {
  display: block !important;
  height: auto !important;
  min-height: 100vh !important;
}

#portal-sidebar {
  box-sizing: border-box !important;
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  width: var(--portal-width) !important;
  height: 100dvh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  scroll-behavior: auto !important;
  background: #172554 !important;
  color: #fff !important;
  padding: 20px 14px !important;
  z-index: 100 !important;
  font-family: Inter, 'Segoe UI', Arial, sans-serif !important;
  line-height: 1.4 !important;
  text-align: left !important;
  scrollbar-width: auto;
  scrollbar-gutter: stable;
  overflow-anchor: none;
  touch-action: pan-y;
  scrollbar-color: #475b87 transparent;
}

#portal-sidebar * {
  box-sizing: border-box;
}

#portal-sidebar .ps-brand {
  font-size: 18px !important;
  font-weight: 900 !important;
  line-height: 1.35 !important;
  padding: 9px 10px 20px !important;
  border-bottom: 1px solid #33447a !important;
  white-space: normal !important;
  min-height: 96px !important;
}

#portal-sidebar .ps-brand span {
  display: block !important;
  color: #67e8f9 !important;
  font-size: 10px !important;
  letter-spacing: 1px !important;
  margin-top: 5px !important;
}

#portal-sidebar .ps-nav-title {
  font-size: 10px !important;
  font-weight: 800 !important;
  color: #9fb0d7 !important;
  margin: 19px 10px 8px !important;
  letter-spacing: 1px !important;
}

#portal-sidebar .ps-nav a,
#portal-sidebar .ps-nav .ps-admin-logout,
#portal-sidebar .ps-nav .ps-sample-card-action {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  text-decoration: none !important;
  color: #dbe5ff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  padding: 10px 11px !important;
  border-radius: 8px !important;
  margin: 2px 0 !important;
  line-height: 1.4 !important;
  background: transparent !important;
}

#portal-sidebar .ps-nav a:hover,
#portal-sidebar .ps-nav .ps-admin-logout:hover,
#portal-sidebar .ps-nav .ps-sample-card-action:hover,
#portal-sidebar .ps-nav a.ps-active {
  background: #7c3aed !important;
  color: #fff !important;
}

#portal-sidebar .ps-admin-logout {
  width: 100%;
  border: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

#portal-sidebar .ps-icon {
  width: 25px !important;
  height: 25px !important;
  flex: 0 0 25px !important;
  border-radius: 6px !important;
  background: #33447a !important;
  color: #dbe5ff !important;
  display: grid !important;
  place-items: center !important;
  font-size: 11px !important;
  font-style: normal !important;
}

#portal-sidebar .ps-active .ps-icon {
  background: #5b21b6 !important;
  color: white !important;
}

html[data-portal-shell="merchant"] #portal-sidebar {
  background: #0b2149 !important;
  padding: 0 !important;
  overflow: hidden !important;
  scrollbar-gutter: auto;
}

#portal-sidebar-scroll {
  height: 100%;
  width: calc(100% - 16px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-width: none;
  scroll-behavior: auto;
  touch-action: pan-y;
}
#portal-sidebar-scroll::-webkit-scrollbar { display: none; }
#portal-sidebar .portal-scroll-track {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 100%;
  background: #071a38;
  touch-action: none;
}
#portal-sidebar .portal-scroll-track[hidden] { display: none; }
#portal-sidebar .portal-scroll-thumb {
  width: 12px;
  margin: 0 2px;
  border-radius: 6px;
  background: #7186a6;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
#portal-sidebar .portal-scroll-thumb:hover,
#portal-sidebar .portal-scroll-thumb:focus { background: #a7bad4; }
#portal-sidebar .portal-scroll-thumb:active { cursor: grabbing; }

#portal-sidebar .ps-slide-bar-header {
  padding: 22px 18px 18px;
  border-bottom: 1px solid #ffffff14;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#portal-sidebar .ps-slide-user-profile-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#portal-sidebar .ps-slide-user-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8327db, #ff2d60);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
}

#portal-sidebar .ps-slide-user-info {
  min-width: 0;
}

#portal-sidebar .ps-slide-user-name {
  font-size: 13.5px;
  font-weight: 800;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#portal-sidebar .ps-slide-user-id {
  font-size: 10.5px;
  color: #8c9eb5;
}

#portal-sidebar .ps-slide-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: background 0.15s ease;
}

#portal-sidebar .ps-slide-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#portal-sidebar .ps-slide-nav-menu {
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 4px;
}

#portal-sidebar .ps-slide-nav-menu > * {
  flex-shrink: 0;
}

#portal-sidebar .ps-slide-nav-group {
  display: block;
  position: relative;
}

#portal-sidebar .ps-slide-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: #b0c0d6;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}

#portal-sidebar svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: inherit;
}

#portal-sidebar .ps-slide-nav-item:hover {
  background: #ffffff0f;
  color: #fff;
}

#portal-sidebar .ps-slide-nav-item.ps-active {
  background: linear-gradient(90deg, #ff5722, #ff8a00);
  color: white;
}

#portal-sidebar .ps-slide-subnav-menu {
  padding-left: 30px;
}

#portal-sidebar .ps-slide-subnav-menu[hidden] {
  display: none !important;
}

#portal-sidebar .ps-slide-subnav-item {
  display: flex;
  gap: 9px;
  padding: 9px 4px;
  color: #b0c0d6;
  text-decoration: none;
  font-size: 12px;
}

#portal-sidebar .ps-slide-subnav-item:hover {
  color: #fff;
}

#portal-sidebar .ps-slide-subnav-item.ps-active {
  color: #ff8a00;
  font-weight: 800;
}

#portal-sidebar .ps-slide-collapse-icon {
  margin-left: auto;
}

#portal-sidebar .ps-logout {
  color: #fb7185;
}

#portal-sidebar a:focus-visible,
#portal-sidebar button:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: -2px;
}

#portal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(11, 33, 73, 0.65) !important;
  backdrop-filter: blur(2px) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: opacity 0.28s ease, visibility 0.28s ease !important;
  z-index: 99998 !important;
  pointer-events: none !important;
}

#portal-backdrop.portal-backdrop-open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

#portal-header {
  box-sizing: border-box !important;
  height: 68px !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 50 !important;
  background: #fff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  padding: 0 24px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  font-family: Inter, 'Segoe UI', Arial, sans-serif !important;
  color: #172554 !important;
  width: 100% !important;
  margin: 0 !important;
}

#portal-header .portal-search {
  width: min(430px, 48%) !important;
  min-width: 0 !important;
  border: 1px solid #d6dee9 !important;
  border-radius: 8px !important;
  padding: 11px 13px !important;
  font-size: 12px !important;
  height: 40px !important;
  background: #fff !important;
  color: #172554 !important;
}

#portal-header .portal-account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

#portal-header strong {
  font-size: 12px;
  font-weight: 800;
  display: block;
}

#portal-header small {
  font-size: 10px;
  color: #64748b;
  display: block;
}

#portal-header .portal-avatar {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #7c3aed;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

#portal-header .portal-logout {
  border: 0 !important;
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border-radius: 7px !important;
  padding: 10px 13px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  width: auto !important;
}

#portal-header .portal-header-title {
  font-size: 12px;
  font-weight: 800;
}

#portal-sidebar a[hidden] {
  display: none !important;
}

/* ================= Mobile Breakpoint (<= 900px) ================= */
@media (max-width: 900px) {
  /* MERCHANT PANEL ON MOBILE: Sidebar is HIDDEN offscreen until profile click */
  html[data-portal-shell="merchant"] body {
    --portal-width: 0px !important;
  }

  html[data-portal-shell="merchant"] body .portal-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  html[data-portal-shell="merchant"] #portal-sidebar {
    width: 285px !important;
    max-width: 85vw !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 99999 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  html[data-portal-shell="merchant"] #portal-sidebar.portal-sidebar-open {
    transform: translateX(0) !important;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.45) !important;
  }

  html[data-portal-shell="merchant"] #portal-sidebar .ps-slide-close-btn {
    display: flex !important;
  }

  /* Merchant header on mobile */
  html[data-portal-shell="merchant"] #portal-header {
    padding: 0 12px !important;
     display: none !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-header-title {
    display: none !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-search {
    width: 38% !important;
  }

  /* Profile chip in header: Visible, styled, and clickable to open sidebar */
  html[data-portal-shell="merchant"] #portal-header .portal-account {
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 4px 8px !important;
    border-radius: 20px !important;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    user-select: none !important;
    transition: background 0.15s ease, border-color 0.15s ease !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-account:hover {
    background: #e2e8f0 !important;
    border-color: #94a3b8 !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-avatar {
    display: grid !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #8327db 0%, #ff2d60 100%) !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-account > div {
    display: block !important;
    max-width: 95px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-account strong {
    font-size: 11px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-account small {
    display: none !important;
  }

  html[data-portal-shell="merchant"] #portal-header .portal-logout {
    padding: 5px 8px !important;
    font-size: 11px !important;
    border-radius: 6px !important;
  }

  /* ADMIN PANEL ON MOBILE: Maintain compact admin view */
  html[data-portal-shell="admin"] body {
    --portal-width: 190px !important;
  }

  html[data-portal-shell="admin"] #portal-sidebar {
    padding: 14px 8px !important;
  }

  html[data-portal-shell="admin"] #portal-sidebar .ps-brand {
    font-size: 15px !important;
  }

  html[data-portal-shell="admin"] #portal-sidebar .ps-nav a,
  html[data-portal-shell="admin"] #portal-sidebar .ps-nav .ps-admin-logout,
#portal-sidebar .ps-nav .ps-sample-card-action {
    padding: 9px 6px !important;
    font-size: 11px !important;
  }

  html[data-portal-shell="admin"] #portal-header {
    padding: 0 12px !important;
  }

  html[data-portal-shell="admin"] #portal-header .portal-header-title {
    display: none !important;
  }

  html[data-portal-shell="admin"] #portal-header .portal-search {
    width: 40% !important;
  }

  html[data-portal-shell="admin"] #portal-header .portal-avatar {
    display: none !important;
  }
}

/* Hide the shared page header on desktop and mobile. */
html[data-portal-shell="merchant"] #portal-sidebar [data-original-id="slideNavReferral"] {
  background: transparent !important;
  border: none !important;
}
html[data-portal-shell="merchant"] #portal-sidebar [data-original-id="slideNavReferral"] > span {
  color: #6ee7b7 !important;
}
html[data-portal-shell] #portal-header {
  display: none !important;
}

html[data-portal-shell="merchant"] #portal-sidebar a[href*="referral_earn"] > span,
html[data-portal-shell="merchant"] #portal-sidebar [data-original-id="slideNavReferral"] > span {
  font-size: 17px !important;
  font-weight: 800 !important;
}

/* Keep the same six merchant destinations on every mobile bottom bar. */
html[data-portal-shell="merchant"] .tab-icon-circle.whatsapp {
  background:linear-gradient(135deg,#25d366,#128c7e);
  color:#fff;
}
@media (max-width:899px) {
  html[data-portal-shell="merchant"] .bottom-nav-bar {
    display:grid;
    grid-template-columns:repeat(6,minmax(0,1fr));
  }
  html[data-portal-shell="merchant"] .bottom-tab-item { min-width:0; padding-left:0; padding-right:0; }
  html[data-portal-shell="merchant"] .bottom-tab-item .tab-text-label { font-size:clamp(8px,2.4vw,11px); white-space:nowrap; }
}

/* One size and spacing system for every merchant mobile tab bar. */
@media (max-width:899px) {
  html[data-portal-shell="merchant"] .bottom-nav-bar {
    --merchant-tab-icon:44px;
    --merchant-tab-svg:22px;
    --merchant-tab-label:clamp(8px,2.4vw,11px);
    box-sizing:border-box;
    position:fixed;
    bottom:0;
    display:grid !important;
    width:100%;
    max-width:100%;
    left:0;
    right:0;
    transform:none;
    padding:8px 10px calc(10px + env(safe-area-inset-bottom,0px));
    align-items:start;
    gap:8px;
  }
  html[data-portal-shell="merchant"] .bottom-nav-bar .bottom-tab-item {
    box-sizing:border-box;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    width:100%;
    height:calc(var(--merchant-tab-icon) + var(--merchant-tab-label) + 9px);
    margin:0;
    padding:0;
    gap:4px;
  }
  html[data-portal-shell="merchant"] .bottom-nav-bar .tab-icon-circle {
    box-sizing:border-box;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    flex:none;
    width:var(--merchant-tab-icon);
    height:var(--merchant-tab-icon);
  }
  html[data-portal-shell="merchant"] .bottom-nav-bar .tab-icon-circle svg {
    width:var(--merchant-tab-svg);
    height:var(--merchant-tab-svg);
  }
  html[data-portal-shell="merchant"] .bottom-nav-bar .tab-text-label {
    font-family:'Plus Jakarta Sans',sans-serif;
    font-size:var(--merchant-tab-label);
    font-weight:800;
    line-height:1;
  }
  html[data-portal-shell="merchant"] .bottom-nav-bar .active-tab-indicator {
    position:absolute;
    bottom:0;
    width:40px;
    height:3px;
    margin:0;
    border-radius:2px;
  }
}
@media (max-width:400px) {
  html[data-portal-shell="merchant"] .bottom-nav-bar { --merchant-tab-icon:41px; --merchant-tab-svg:20px; }
}
@media (max-width:340px) {
  html[data-portal-shell="merchant"] .bottom-nav-bar { --merchant-tab-icon:36px; --merchant-tab-svg:18px; padding:8px 6px calc(10px + env(safe-area-inset-bottom,0px)); }
  html[data-portal-shell="merchant"] .bottom-nav-bar .active-tab-indicator { width:28px; height:2px; }
}
@media (min-width:900px) {
  html[data-portal-shell="merchant"] .bottom-nav-bar { display:none !important; }
}

/* Keep the Super Admin identity and WhatsApp control visible while navigation scrolls. */
html[data-portal-shell="admin"] #portal-sidebar .ps-brand{position:sticky;top:-20px;z-index:5;background:#172554}
.portal-whatsapp-trigger{display:inline-flex;align-items:center;justify-content:center;background:#25d366;color:white;border:0;border-radius:50%;width:38px;height:38px;flex-shrink:0;cursor:pointer;margin:8px}
.portal-whatsapp-trigger svg{width:24px;height:24px}
@media(max-width:900px){html[data-portal-shell="admin"] #portal-sidebar .ps-brand{top:-14px}}

/* Match the dashboard's WhatsApp icon position on every Super Admin page. */
#portal-sidebar .ps-brand:has(.admin-whatsapp-icon)>span{padding-right:36px!important}
#portal-sidebar .admin-whatsapp-icon{position:absolute;right:8px;bottom:15px;width:30px;height:30px;display:grid;place-items:center;border:1px solid #86efac;border-radius:9px;background:#15803d;color:#fff;padding:5px;cursor:pointer;margin:0}
#portal-sidebar .admin-whatsapp-icon svg{width:20px;height:20px}
#portal-sidebar .admin-whatsapp-icon:hover{background:#166534}
#businessRegistrationModal{width:680px;max-width:calc(100vw - 24px);height:90dvh;max-height:90dvh;padding:36px 0 0;margin:auto;border:0;border-radius:16px;background:#fff;overflow:hidden}
#businessRegistrationModal::backdrop{background:#071630a6}
#businessRegistrationModal iframe{width:100%;height:100%;border:0;display:block}
.business-registration-close{position:absolute;right:10px;top:4px;border:0;background:#fff;color:#172554;font:28px system-ui;cursor:pointer;width:32px;height:32px}

#portal-sidebar .ps-sample-card-action{display:flex;align-items:center;gap:10px;width:100%;padding:11px 10px;border:0;border-radius:9px;background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer}
#portal-sidebar .ps-sample-card-action:hover{background:#ffffff14}#portal-sidebar .ps-sample-card-action[hidden]{display:none!important}
