/* ============================================================
   BIYAPOINT — App Layout (Sidebar + Topbar + Shell)
   ============================================================ */

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--gray-50);
}

/* ────────────────────────────────────
   SIDEBAR
──────────────────────────────────── */
/* Rendered from one definition in kudistack.js (renderSidebar), so every
   page gets the same nav. The static markup in each page is only a no-JS
   fallback and stays invisible until the real sidebar is drawn. */
.sidebar {
  --sidebar-bg: #F5F7FA;
  --sidebar-hover: rgba(11, 37, 69, 0.05);
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: transform var(--transition-slow), width 0.2s var(--ease);
  z-index: 50;
}
.sidebar > * { flex-shrink: 0; }
.sidebar:not(.is-rendered) > * { visibility: hidden; }

/* Brand */
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 0 4px 14px 6px; }
.sidebar-brand-link { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; text-decoration: none; }
/* The "K" text is kept as a fallback but hidden behind the SVG mark. */
.sidebar-brand-logo {
  width: 28px; height: 28px;
  background: url('../img/logo-mark.svg') center / contain no-repeat;
  color: transparent;
  font-size: 0;
  flex-shrink: 0;
}
/* Wordmark: lowercase, tight. The brand is still "Biyapoint" in prose. */
.sidebar-brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.035em;
  text-transform: lowercase;
  white-space: nowrap;
}
.sidebar-collapse-btn {
  width: 28px; height: 28px;
  border: none; border-radius: 7px;
  background: none;
  color: var(--gray-400);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: var(--gray-700); }
.sidebar-collapse-btn svg { width: 17px; height: 17px; transition: transform 0.2s var(--ease); }

/* Business switcher */
.biz-switch-wrap { position: relative; }
.biz-switch {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition);
}
.biz-switch:hover, .biz-switch[aria-expanded="true"] { border-color: var(--gray-300); }
.biz-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.biz-avatar img { width: 100%; height: 100%; object-fit: cover; }
.biz-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.biz-name { font-size: 13px; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-sub { font-size: 11.5px; color: var(--gray-500); display: flex; align-items: center; gap: 5px; }
.biz-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-400); }
.biz-dot.verified { background: var(--success); }
.biz-dot.pending { background: var(--orange); }
.biz-chevron { width: 15px; height: 15px; color: var(--gray-400); flex-shrink: 0; }
.biz-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 300;
}
.biz-menu[hidden] { display: none; }
.biz-menu-label { font-size: 11.5px; color: var(--gray-400); padding: 6px 8px 4px; }
.biz-opt {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border: none; border-radius: 7px; background: none;
  font-family: var(--font); font-size: 13px; color: var(--gray-800); text-align: left;
  cursor: pointer;
}
.biz-opt:hover { background: var(--gray-50); }
.biz-opt .biz-avatar { width: 24px; height: 24px; border-radius: 6px; font-size: 10px; }
.biz-opt-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-opt.is-active .biz-opt-name { font-weight: 600; }
.biz-opt-status { width: 16px; display: flex; justify-content: center; color: var(--green); font-size: 11px; }
.biz-opt-status svg { width: 15px; height: 15px; }
.biz-add { border-top: 1px solid var(--gray-100); margin-top: 4px; padding-top: 4px; }
.biz-add .biz-opt { color: var(--green); font-weight: 500; }

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-group { display: flex; flex-direction: column; gap: 1px; margin-top: 18px; }
.sidebar-group-label { font-size: 12px; font-weight: 500; color: var(--gray-400); padding: 0 10px 6px; }
.sidebar-spacer { flex: 1 0 16px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--gray-600);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  user-select: none;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--gray-900); }
.nav-item.active {
  background: var(--white);
  color: var(--green);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.06);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--gray-400); transition: color 0.12s; }
.nav-item:hover .nav-icon { color: var(--gray-600); }
.nav-item.active .nav-icon { color: var(--green); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); flex-shrink: 0; }
.nav-tag {
  font-size: 10.5px; font-weight: 500;
  padding: 1px 6px; border-radius: 5px;
  background: rgba(11, 37, 69, 0.06);
  color: var(--gray-500);
}
.nav-badge {
  background: var(--red); color: white;
  font-size: 10px; font-weight: 600;
  border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center;
}

/* Footer: signed-in user + account menu */
.sidebar-footer { position: relative; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-200); }
.sidebar-user {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 6px;
  border: none; border-radius: 8px; background: none;
  font-family: var(--font); text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover, .sidebar-user[aria-expanded="true"] { background: var(--sidebar-hover); }
.sidebar-user .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.sidebar-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11.5px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-chevron { width: 15px; height: 15px; color: var(--gray-400); flex-shrink: 0; }
.dropdown-menu.dropup { top: auto; bottom: calc(100% + 6px); left: 0; right: 0; width: auto; }
.dropdown-menu-item svg { width: 16px; height: 16px; color: var(--gray-400); flex-shrink: 0; }
.dropdown-menu-item.danger svg { color: var(--red); }

/* Desktop collapsed state: icons only, labels become native tooltips */
@media (min-width: 769px) {
  .sidebar.collapsed { width: 64px; padding-left: 8px; padding-right: 8px; }
  .sidebar.collapsed .sidebar-brand-name,
  .sidebar.collapsed .biz-meta,
  .sidebar.collapsed .biz-chevron,
  .sidebar.collapsed .sidebar-group-label,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-tag,
  .sidebar.collapsed .sidebar-user-info,
  .sidebar.collapsed .sidebar-user-chevron { display: none; }
  .sidebar.collapsed .sidebar-brand { flex-direction: column; gap: 10px; padding: 0 0 12px; }
  .sidebar.collapsed .sidebar-brand-link { flex: none; }
  .sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
  .sidebar.collapsed .biz-switch { justify-content: center; padding: 6px; }
  .sidebar.collapsed .biz-menu { left: 0; right: auto; width: 220px; }
  .sidebar.collapsed .sidebar-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-200); }
  .sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
  .sidebar.collapsed .nav-dot { position: absolute; top: 7px; right: 9px; }
  .sidebar.collapsed .sidebar-user { justify-content: center; }
  .sidebar.collapsed .dropdown-menu.dropup { right: auto; width: 200px; }
}

/* ────────────────────────────────────
   TOPBAR
──────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
}
/* Mobile only: opens the sidebar drawer. Doubled class beats .topbar-icon-btn's
   display:flex, which used to leave a dead button on desktop. */
.topbar-hamburger.topbar-hamburger {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--gray-600);
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--gray-400);
}
.topbar-breadcrumb .current {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}
.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.topbar-search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--gray-50);
  color: var(--gray-800);
  transition: border-color var(--transition), background var(--transition);
}
.topbar-search input:focus {
  border-color: var(--green);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(11,37,69,0.06);
}
.topbar-search input::placeholder { color: var(--gray-400); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.topbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--gray-600);
  position: relative;
  transition: background var(--transition);
}
.topbar-icon-btn:hover { background: var(--gray-50); }
/* Hidden: there is no notifications feed yet, so an always-on dot would
   signal unread alerts that don't exist. Remove display:none once there is. */
.topbar-notif-dot {
  display: none;
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--white);
}
.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--gray-200);
  margin: 0 4px;
}

/* ── Main Content ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── Mobile Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 49;
}

/* ────────────────────────────────────
   AUTH LAYOUT
──────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
}
.auth-panel-left {
  background: var(--green);
  padding: 60px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.auth-panel-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 60px;
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
}
.auth-logo-box {
  width: 36px; height: 36px;
  background: url('../img/logo-mark.svg') center / contain no-repeat;
  color: transparent; font-size: 0;
}
.auth-logo-name { font-size: 20px; font-weight: 700; color: var(--green); letter-spacing: -0.035em; text-transform: lowercase; }
.auth-heading   { font-size: 24px; font-weight: 800; color: var(--gray-900); margin-bottom: 6px; letter-spacing: -0.01em; }
.auth-subheading{ font-size: 14px; color: var(--gray-500); margin-bottom: 28px; line-height: 1.5; }
.auth-footer-text { font-size: 13.5px; color: var(--gray-500); text-align: center; margin-top: 20px; }
.auth-link { color: var(--green); font-weight: 600; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
}
.auth-divider-line { flex: 1; height: 1px; background: var(--gray-200); }
.auth-divider-text { font-size: 12px; color: var(--gray-400); font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel-left  { display: none; }
  .auth-panel-right { padding: 40px 24px; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.show { display: block; }
  .topbar-hamburger.topbar-hamburger { display: flex; }
  .sidebar-collapse-btn { display: none; }
  .page-content         { padding: 16px; }
  .topbar               { padding: 0 16px; }
}
