/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ==========================================================================
   Sidebar — light panel (off-canvas drawer on mobile, fixed rail on desktop)
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(var(--sidebar-width), 84vw);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  color: var(--sidebar-text);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}

.sidebar.is-open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 4px;
}

/* FACILIX logo (includes the product tagline). The PNG has an off-white
   (253,254,254) background: it always sits on white, and the slight
   brightness lift turns that background pure white so no box shows. */
.brand-logo {
  display: block;
  height: auto;
  width: 100%;
  max-width: 228px;
  filter: brightness(1.012);
  max-width: 100%;
  align-self: flex-start;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}

/* Legacy initials mark (still used where no logo fits). */
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-close {
  margin-left: auto;
  color: var(--gray-500);
}
.sidebar-close:hover { background: var(--gray-100); color: var(--gray-900); }

.sidebar-nav {
  padding: 4px 14px 16px;
  flex: 1;
}

.nav-section-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-400);
  padding: 18px 10px 8px;
}

.nav-section-label:first-child {
  padding-top: 10px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14.5px;
  margin-bottom: 3px;
  min-height: 46px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Each nav icon sits in a soft rounded tile. */
.nav-link svg {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 10px;
  background: var(--sidebar-icon-bg);
  color: var(--color-primary);
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-link:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}
.nav-link:hover svg { background: var(--color-primary-light); }

.nav-link.is-active {
  background: var(--color-primary-50);
  color: var(--color-primary-dark);
  font-weight: 600;
}
.nav-link.is-active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--color-secondary);
}

.nav-link.is-active svg {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.nav-pill {
  margin-left: auto;
  background: #ff5a4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Footer: a faint skyline drawing above the signed-in user. */
.sidebar-footer {
  padding: 56px 14px 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 264 60' fill='none' stroke='%23c4e0dd' stroke-width='1.5' stroke-linejoin='round'><path d='M0 59h264'/><path d='M14 59V30h22v29M20 36h4M28 36h4M20 44h4M28 44h4'/><path d='M44 59V14h30v45M51 21h5M62 21h5M51 30h5M62 30h5M51 39h5M62 39h5'/><path d='M82 59V36h18v23'/><path d='M108 59V22l18-10 18 10v37M120 30h4M130 30h4M120 40h4M130 40h4'/><path d='M152 59V40h16v19'/><path d='M176 59V8h26v51M182 16h5M192 16h5M182 26h5M192 26h5M182 36h5M192 36h5'/><path d='M210 59V32h20v27M216 40h8'/><path d='M238 59V24h18v35'/></svg>") center top / 100% 54px no-repeat;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.role-card .avatar {
  background: var(--brand-gradient);
  color: #fff;
}

.role-card .icon-btn {
  color: var(--gray-500);
  margin-left: auto;
}
.role-card .icon-btn:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.role-card-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  overflow: hidden;
  min-width: 0;
}

.role-card-text strong {
  font-size: 13.5px;
  color: var(--gray-900);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-card-text small {
  color: var(--gray-500);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Topbar — frosted, sits over the page
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

/* App mark beside the title on phones (the sidebar logo is off-canvas). */
.topbar-logo {
  height: 30px;
  width: auto;
  flex-shrink: 0;
  border-radius: 8px;
  filter: brightness(1.012);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: var(--gray-900);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-actions .icon-btn.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ==========================================================================
   Page content
   ========================================================================== */

.page-content {
  flex: 1;
  padding: 18px 16px calc(var(--bottom-nav-height) + 28px);
  max-width: var(--page-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   Bottom navigation (mobile only)
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px -8px rgba(11, 41, 41, 0.12);
  display: flex;
  z-index: 45;
  padding: 6px 4px env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  --tone: var(--color-primary);
  --tone-bg: var(--color-primary-light);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
  min-height: 56px;
}

/* Each tab has its own colour: a tinted pill when idle, solid when active. */
.bottom-nav-item.tone-teal   { --tone: #057f7b; --tone-bg: #e0f2f1; }
.bottom-nav-item.tone-coral  { --tone: #e5534b; --tone-bg: #fde9e7; }
.bottom-nav-item.tone-gold   { --tone: #c99a00; --tone-bg: #fff4cc; }
.bottom-nav-item.tone-violet { --tone: #7a5af8; --tone-bg: #eeeafe; }
.bottom-nav-item.tone-blue   { --tone: #2f7ae5; --tone-bg: #e5effc; }

.bottom-nav-item svg {
  color: var(--tone);
  background: var(--tone-bg);
  width: 48px;
  height: 30px;
  padding: 5px 13px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.bottom-nav-item.is-active {
  color: var(--tone);
  font-weight: 700;
}

.bottom-nav-item.is-active svg {
  color: #fff;
  background: var(--tone);
  box-shadow: 0 6px 14px -6px var(--tone);
  transform: translateY(-1px);
}

/* ==========================================================================
   Responsive: tablet and up
   ========================================================================== */

@media (min-width: 640px) {
  .page-content {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    transform: none;
    box-shadow: none;
  }

  /* Qualified so they beat .icon-btn (components.css loads after this file). */
  .sidebar .sidebar-close,
  .sidebar-overlay,
  .topbar #menuToggle,
  .topbar .topbar-logo,
  .bottom-nav {
    display: none;
  }

  .app-main {
    margin-left: var(--sidebar-width);
  }

  .page-content {
    padding: 32px 36px 48px;
  }

  .topbar {
    padding: 0 36px;
    height: 72px;
  }

  .topbar-title {
    font-size: 21px;
  }
}
.back-btn { margin-right: 2px; color: var(--gray-700); }
