/* ══════════════════════════════════════════════════════════════
   BrickFlow – App Shell Layout
   ══════════════════════════════════════════════════════════════ */

/* ── Page visibility — ONLY the four top-level page shells ──────
   (NOT the injected page content inside #view-root)             */
#authPage,
#appPage,
#signingPage,
#employeePage       { display: none !important; }

#authPage.active,
#appPage.active,
#signingPage.active,
#employeePage.active { display: block !important; }

/* ── Outer wrapper ─────────────────────────────────────────────── */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg, #f8f8f6);
}

/* ══════════════════════════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
  flex-shrink: 0;
}

/* Logo */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Syne', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #ffffff;
  letter-spacing: -0.5px;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 20px;
  flex-shrink: 0;
}

/* Blue brand mark — the "B" square */
.topbar-logo span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #1B4B8A;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.topbar-logo img {
  height: 28px;
  width: auto;
}

/* Top navigation */
.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }

.top-nav-item,
.top-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.top-nav-item:hover,
.top-nav-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.top-nav-item.active,
.top-nav-btn.active {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  font-weight: 600;
}

/* Separator pipe */
.top-nav-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.12);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Right-side actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.topbar-company {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* New button */
.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--brand, #1b4b8a);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-new:hover { background: #163d71; }

/* Avatar button */
.topbar-avatar {
  position: relative;
  display: flex;
  align-items: center;
}

/* The avatar circle — targets both #avatarInitials span and any button child */
.topbar-avatar > span,
.topbar-avatar > button,
.topbar-avatar > .avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand, #1b4b8a);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
  flex-shrink: 0;
}
.topbar-avatar > span:hover,
.topbar-avatar > button:hover,
.topbar-avatar > .avatar-btn:hover { background: #163d71; }

/* Avatar dropdown — shown on hover (CSS-only toggle) */
.avatar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  padding: 6px 0;
  overflow: hidden;
}
/* Show dropdown on hover of the whole .topbar-avatar wrapper */
.topbar-avatar:hover .avatar-dropdown,
.avatar-dropdown.open { display: block; }

.avatar-dropdown a,
.avatar-dropdown button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  text-align: left;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text, #111827);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
}
.avatar-dropdown a:hover,
.avatar-dropdown button:hover {
  background: var(--bg, #f8f8f6);
}
.avatar-dropdown hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--line, #e5e7eb);
}

/* ══════════════════════════════════════════════════════════════
   APP BODY  (sidebar + main)
   ══════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface, #fff);
  border-right: 1px solid var(--line, #e5e7eb);
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-section-label {
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 8px;
}

.sidebar-nav li a,
.sidebar-nav li button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: none;
  background: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text, #111827);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
  background: var(--bg, #f8f8f6);
  color: var(--brand, #1b4b8a);
}
.sidebar-nav li a.active,
.sidebar-nav li button.active {
  background: #EEF3FB;
  color: var(--brand, #1b4b8a);
  font-weight: 600;
}

/* ── Main content area ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg, #f8f8f6);
}

#view-root {
  min-height: 100%;
  padding: 0;
  position: relative;
  will-change: opacity, transform;
}

/* Första gången en sida hämtas: diskret laddning så det inte känns tomt/hackigt */
#view-root.view-root--busy::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(
    90deg,
    rgba(248, 248, 246, 0.65) 0%,
    rgba(240, 240, 238, 0.85) 50%,
    rgba(248, 248, 246, 0.65) 100%
  );
  background-size: 200% 100%;
  animation: bf-view-shimmer 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes bf-view-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #view-root.view-root--busy::before {
    animation: none;
    background: rgba(248, 248, 246, 0.75);
  }
}

/* ══════════════════════════════════════════════════════════════
   NOTIFICATION BADGE  (chat nav badge)
   ══════════════════════════════════════════════════════════════ */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-left: 2px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .top-nav {
    gap: 0;
  }

  .top-nav-item,
  .top-nav-btn {
    padding: 5px 7px;
    font-size: 12px;
  }

  .topbar-company { display: none; }

  .sidebar {
    position: fixed;
    left: -240px;
    top: 56px;
    height: calc(100vh - 56px);
    z-index: 150;
    transition: left 0.25s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,0.12);
  }
  .sidebar.open {
    left: 0;
  }

  .main-content {
    padding-bottom: 60px;
  }
}
