/* =========================================================
   Blistavi Dom – Duralux-style Client Navigation (Bootstrap 5)

   What this does:
   - Desktop: fixed left sidebar (icons + collapsible submenus)
   - Mobile: offcanvas sidebar
   - Topbar: lightweight utilities + search

   Scope:
   - Global layout adjustments are only applied when <body> has
     the class .bd-duralux-layout (added by navigation.php)

   Notes:
   - Filename kept for backwards compatibility with existing loaders.
   ========================================================= */

/* =====================
   Layout + Tokens
   ===================== */

body.bd-duralux-layout{
  --bd-sidebar-w: 260px;

  --bd-bg: #f6f7fb;
  --bd-surface: #ffffff;
  --bd-surface-2: #f1f3f7;
  --bd-border: rgba(15, 23, 42, .10);
  --bd-shadow: 0 18px 40px rgba(2, 6, 23, .10);

  --bd-ink: #0f172a;
  --bd-text: #334155;
  --bd-muted: #64748b;

  --bd-primary: #2563eb;
  --bd-primary-weak: rgba(37, 99, 235, .12);

  --bd-radius: 14px;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  background: var(--bd-bg);
}

@media (min-width: 992px){
  body.bd-duralux-layout{
    padding-left: var(--bd-sidebar-w);
  }
}

@media (max-width: 991.98px){
  body.bd-duralux-layout{
    padding-left: 0;
  }
}

/* =====================
   Brand (shared)
   ===================== */

.bd-brand-link{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  white-space: nowrap;
}

.bd-brand-mark{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: #fff;
  font-weight: 900;
  letter-spacing: -.5px;

  background: linear-gradient(135deg, #111827, #334155);
  box-shadow: 0 12px 24px rgba(2, 6, 23, .16);
}

.bd-brand-mark-img{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: contain;

  background: transparent;
  padding: 0;

  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 10px 18px rgba(2, 6, 23, .10);
}

.bd-brand-name{
  font-size: 14px;
  font-weight: 900;
  color: var(--bd-ink);
  letter-spacing: -.2px;
}

/* Mobile topbar: hide company name next to the mark (name stays visible inside the hamburger/offcanvas) */
.bd-duralux-topbar .bd-brand-link.d-lg-none .bd-brand-name{display:none;}

/* Prevent theme hover overrides on brand */
.bd-brand-link,
.bd-brand-link:hover,
.bd-brand-link:focus,
.bd-brand-link:active{
  color: var(--bd-ink) !important;
  text-decoration: none !important;
}

/* =====================
   Desktop Sidebar
   ===================== */

.bd-duralux-sidebar{
  width: var(--bd-sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;

  background: var(--bd-surface-2);
  border-right: 1px solid var(--bd-border);

  z-index: 1040;
}

.bd-sidebar-inner{
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;

  padding: 16px 12px;
}

.bd-sidebar-brand{
  padding: 6px 8px 8px;
}

.bd-sidebar-nav{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  padding-right: 6px;
}

.bd-sidebar-nav::-webkit-scrollbar{ width: 8px; }
.bd-sidebar-nav::-webkit-scrollbar-thumb{
  background: rgba(15,23,42,.16);
  border-radius: 999px;
}

.bd-sidebar-section-title{
  padding: 8px 10px;
  margin: 0 0 6px;

  font-size: 11px;
  font-weight: 900;
  color: var(--bd-muted);
  text-transform: uppercase;
  letter-spacing: .10em;
}

.bd-side-menu{
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bd-side-item{ margin: 0; }

.bd-side-link{
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 11px 12px;
  border-radius: 10px;

  color: var(--bd-ink) !important;
  font-weight: 750;
  font-size: 14px;

  text-decoration: none !important;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.bd-side-left{
  display: inline-flex;
  align-items: center;
  gap: 10px;

  min-width: 0;
  flex: 1 1 auto;
}

.bd-side-text{
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-side-icon{
  font-size: 18px;
  color: var(--bd-muted);
  line-height: 1;
}

.bd-side-chevron{
  font-size: 18px;
  color: var(--bd-muted);
  line-height: 1;
  transition: transform .18s ease, color .18s ease;
}

.bd-side-link:hover{
  background: rgba(15, 23, 42, .06);
  color: var(--bd-ink) !important;
  transform: translateY(-1px);
}

.bd-side-link:hover .bd-side-icon,
.bd-side-link:hover .bd-side-chevron{
  color: var(--bd-ink);
}

.bd-side-link.active{
  background: var(--bd-surface);
  box-shadow: 0 10px 24px rgba(2, 6, 23, .10);
  color: var(--bd-primary) !important;
}

.bd-side-link.active .bd-side-icon,
.bd-side-link.active .bd-side-chevron{
  color: var(--bd-primary) !important;
}

/* Rotate chevron when expanded */
.bd-side-link-parent[aria-expanded="true"] .bd-side-chevron{
  transform: rotate(90deg);
  color: var(--bd-primary) !important;
}

/* Submenu */
.bd-side-submenu{
  margin: 6px 0 10px;
  padding: 6px 0 6px 40px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bd-side-sublink{
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 9px 10px;
  border-radius: 10px;

  color: var(--bd-ink) !important;
  text-decoration: none !important;
  font-weight: 650;
  font-size: 13.5px;

  transition: background .15s ease, color .15s ease;
}

.bd-side-subicon{
  font-size: 16px;
  color: var(--bd-muted);
}

.bd-side-sublink:hover{
  background: rgba(15, 23, 42, .06);
  color: var(--bd-ink) !important;
}

.bd-side-sublink.active{
  background: var(--bd-primary-weak);
  color: var(--bd-primary) !important;
}

.bd-side-sublink.active .bd-side-subicon{
  color: var(--bd-primary) !important;
}

/* Sidebar footer card (Duralux-like callout) */
.bd-sidebar-footer{ padding: 0 6px 6px; }

.bd-help-card{
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(2, 6, 23, .08);

  padding: 14px;
}

.bd-help-title{
  font-size: 13px;
  font-weight: 900;
  color: var(--bd-ink);
  margin-bottom: 4px;
}

.bd-help-text{
  font-size: 12.5px;
  color: var(--bd-muted);
  margin-bottom: 12px;
}

.bd-help-actions{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* =====================
   Topbar
   ===================== */

.bd-duralux-topbar{
  position: sticky;
  top: 0;
  z-index: 1030;
}

.bd-topbar{
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);

  border-bottom: 1px solid var(--bd-border);
}

.bd-topbar-inner{
  padding: 10px 16px;
  gap: 12px;
}

/* Hamburger */
.bd-hamburger{
  width: 46px;
  height: 46px;
  border-radius: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: transparent;
  border: 0;
  box-shadow: none;

  padding: 0;
}

.bd-hamburger:active{ transform: translateY(1px); }

.bd-hamburger:focus-visible{
  outline: 0;
  box-shadow: 0 0 0 .22rem rgba(37,99,235,.18), 0 10px 18px rgba(2,6,23,.06);
}

.bd-hamburger-box{
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
}

.bd-hamburger-line{
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--bd-ink);
  opacity: .90;
}

/* Search (topbar) */
.bd-topbar-search{
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

.bd-search-form{
  width: min(520px, 100%);

  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 0 14px;
  border-radius: 999px;

  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.07);
}

.bd-search-icon{
  color: var(--bd-muted);
  font-size: 18px;
}

.bd-search-input{
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;

  font-weight: 650;
  color: var(--bd-ink);
  font-size: 14px;
}

.bd-search-input::placeholder{
  color: rgba(100,116,139,.95);
  font-weight: 650;
}

/* Topbar actions */
/* Prevent unwanted list markers ("dots") */
.bd-topbar-actions,
.bd-topbar-actions li,
.bd-dropdown.dropdown-menu,
.bd-dropdown.dropdown-menu li,
.bd-lang-menu,
.bd-lang-menu li{
  list-style: none;
}

.bd-topbar-actions{
  padding-left: 0;
  margin: 0;
}

.bd-dropdown.dropdown-menu,
.bd-lang-menu{
  padding-left: 0;
}

.bd-topbar-actions{
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.bd-topbar-actions .nav-item{ margin: 0 !important; }
.bd-topbar-actions .nav-link{ padding: 0 !important; }

.bd-icon-link{
  width: 44px;
  height: 44px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  color: var(--bd-ink) !important;
  font-size: 1.35rem;

  text-decoration: none !important;
  transition: background .15s ease, color .15s ease;
}


.bd-icon-link i{ color: inherit !important; }

.bd-icon-link:hover{
  background: rgba(15,23,42,.06);
  color: var(--bd-primary) !important;
}

/* Badge */
.bd-badge{
  position: absolute;
  top: 3px;
  right: 3px;

  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;

  padding: 2px 6px;
  box-shadow: 0 8px 16px rgba(239,68,68,.24);
}

/* User avatar */
.bd-avatar-img,
.bd-avatar-initials{
  width: 44px;
  height: 44px;
  border-radius: 10px;

  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: rgba(37,99,235,.12);
  color: var(--bd-primary) !important;
  font-weight: 900;
  border: 1px solid rgba(15,23,42,.08);
}

.bd-user-trigger{ padding: 0 !important; }

/* Dropdown styling */
.bd-dropdown{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(2,6,23,.16);
  overflow: hidden;
}

.bd-dropdown-wide{
  width: 340px;
  max-width: 92vw;
}

.bd-dropdown .dropdown-item{
  padding: 10px 14px;
  font-weight: 650;
  color: var(--bd-ink) !important;
}

.bd-dropdown .dropdown-item:hover{
  background: rgba(37,99,235,.10);
  color: var(--bd-ink);
}

.bd-dropdown .dropdown-item.active{
  background: rgba(37,99,235,.14);
  color: var(--bd-primary) !important;
}


/* Language dropdown (flag + name only) */
.bd-lang-trigger-flag{
  font-size: 18px;
  line-height: 1;
  color: var(--bd-ink);
}

.bd-lang-menu .dropdown-item{
  display: flex;
  align-items: center;
  gap: 10px;

  font-size: 13.5px;
  padding: 9px 12px;
}

.bd-lang-flag{
  width: 22px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}

.bd-lang-name{
  font-weight: 750;
}

.bd-lang-code{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,.22);
  background: rgba(37,99,235,.08);
  color: var(--bd-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}



/* =====================
   Offcanvas (Mobile)
   ===================== */

.bd-duralux-offcanvas{
  --bs-offcanvas-width: 320px;
  background: var(--bd-surface-2);
  border-right: 1px solid var(--bd-border);
  height: 100dvh;
  max-height: 100dvh;
}

.bd-offcanvas-header{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15,23,42,.08);
}

.bd-offcanvas-body{
  padding: 14px 14px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: calc(100dvh - 72px);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.bd-offcanvas-top{
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(180deg, rgba(241,243,247,.98) 0%, rgba(241,243,247,.92) 100%);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.bd-offcanvas-profile{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(15,23,42,.08);
  margin: 0 0 8px;
}

.bd-offcanvas-profile-avatar{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}

.bd-offcanvas-profile-meta{
  min-width: 0;
  line-height: 1.2;
}

.bd-offcanvas-profile-name{
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--bd-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-offcanvas-profile-status{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(37,99,235,.10);
  color: var(--bd-primary);
}

.bd-offcanvas-profile-status::before{
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

/* ==========================================
   P0: Client sidebar scroll reliability fix
   ========================================== */
.bd-duralux-sidebar{
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.bd-sidebar-inner{
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.bd-sidebar-nav{
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.bd-duralux-offcanvas{
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.bd-offcanvas-body{
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: calc(100dvh - 72px);
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.bd-mobile-nav,
.bd-side-menu-mobile{
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.bd-offcanvas-close{
  width: 36px;
  height: 36px;
  border-radius: 10px;
  padding: 0;
  margin: 0;

  background-color: transparent !important;
  opacity: .75 !important;
}

.bd-offcanvas-close:hover{
  background-color: rgba(15,23,42,.06) !important;
  opacity: 1 !important;
}

/* Mobile search (inside offcanvas) */
.bd-mobile-search-form{ margin: 0 0 12px; }

.bd-mobile-search{
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 8px 10px;
  border-radius: 10px;

  background: rgba(255,255,255,.88);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 12px 24px rgba(2,6,23,.06);
}

.bd-mobile-search-icon{
  color: var(--bd-muted);
  font-size: 18px;
}

.bd-mobile-search-input{
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;

  font-weight: 750;
  color: var(--bd-ink);
  font-size: 14px;
}

.bd-mobile-search-input::placeholder{
  color: rgba(100,116,139,.95);
  font-weight: 650;
}

.bd-mobile-search-btn{
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;

  background: var(--bd-primary);
  color: #fff;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 12px 22px rgba(37,99,235,.22);
}

/* Mobile menu tweaks */
.bd-side-menu-mobile .bd-side-link{ background: rgba(255,255,255,.70); border: 1px solid rgba(15,23,42,.06); }
.bd-side-menu-mobile .bd-side-link:hover{ background: rgba(255,255,255,.92); }

.bd-help-card-mobile{ margin-top: 14px; }

/* =====================
   Small screens polish
   ===================== */

@media (max-width: 575.98px){
  .bd-topbar{
    flex-wrap: nowrap !important;
  }

  .bd-topbar-inner{
    padding: 10px 12px;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between !important;
    gap: 6px;
    overflow: visible;
  }

  .bd-topbar-actions{
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    margin-left: auto !important;
    width: auto !important;
    min-width: max-content;
    flex: 0 0 auto !important;
  }

  .bd-topbar-actions .nav-item{
    display: block !important;
    flex: 0 0 auto !important;
    width: auto !important;
  }

  .bd-icon-link{
    width: 44px;
    height: 44px;
    font-size: 1.35rem;
  }

  .bd-hamburger{
    width: 46px;
    height: 46px;
  }

  .bd-brand-name{ font-size: 15px; }
}

/* ==========================================
   P1: Mobile sidebar header polish (client)
   ========================================== */
@media (max-width: 991.98px){
  .bd-offcanvas-top{
    background: transparent;
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  .bd-offcanvas-profile{
    gap: 8px;
    padding: 6px 8px;
    margin: 0 0 8px;
    border-radius: 10px;
    border: 1px solid rgba(15,23,42,.10);
    background: rgba(255,255,255,.60);
    box-shadow: none;
  }

  .bd-offcanvas-profile-avatar,
  .bd-offcanvas-profile .bd-avatar-initials{
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .bd-offcanvas-profile-name{
    font-size: 12px;
    line-height: 1.15;
  }

  .bd-offcanvas-profile-email{
    display: block;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.2;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bd-mobile-search-form{
    margin: 0 0 10px;
  }

  .bd-mobile-search-group{
    position: relative;
    display: block;
  }

  .bd-mobile-search-icon{
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: #94a3b8;
    pointer-events: none;
  }

  .bd-mobile-search-input{
    width: 100%;
    height: 38px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
    font-size: 13px;
    font-weight: 650;
    color: #0f172a;
    padding: 0 12px 0 34px;
  }

  .bd-mobile-search-input::placeholder{
    color: #64748b;
    font-weight: 600;
  }
}
