/* =========================================================
   TendReach authenticated application shell
   ========================================================= */

:root {
  --tr-blue: #2563EB;
  --tr-blue-dark: #1D4ED8;
  --tr-blue-soft: #EFF6FF;
  --tr-navy: #0D1B3D;
  --tr-sky: #7DB9F5;
  --tr-seafoam: #4DB6AC;
  --tr-coral: #FFB08A;
  --tr-sand: #F5F3EC;

  --tr-text: #172033;
  --tr-muted: #64748B;
  --tr-border: #E2E8F0;
  --tr-surface: #FFFFFF;
  --tr-page: #F7F9FC;

  --tr-sidebar-width: 216px;
  --tr-topbar-height: 68px;
}


/* =========================================================
   Overall application
   ========================================================= */

.app-body {
  margin: 0;
  min-width: 0;
  background: var(--tr-page);
  color: var(--tr-text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--tr-sidebar-width) minmax(0, 1fr);
  background: var(--tr-page);
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}


/* =========================================================
   Sidebar
   ========================================================= */

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;

  background: #FFFFFF;
  border-right: 1px solid var(--tr-border);

  z-index: 30;
}

.app-sidebar-brand {
  min-height: var(--tr-topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;

  border-bottom: 1px solid var(--tr-border);
}

.brand-sidebar {
  display: flex;
  align-items: center;
  gap: 10px;

  color: var(--tr-navy);
  text-decoration: none;
}

.brand-sidebar img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand-sidebar .brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-sidebar .brand-copy strong {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand-sidebar .brand-copy strong span {
  color: var(--tr-blue);
}

.brand-sidebar .brand-copy small {
  margin-top: 4px;
  color: var(--tr-muted);
  font-size: 0.67rem;
  line-height: 1.25;
}


/* =========================================================
   Sidebar navigation
   ========================================================= */

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;

  padding: 18px 12px;
}

.sidebar-nav-group {
  display: grid;
  gap: 4px;
}

.sidebar-nav-group + .sidebar-nav-group {
  margin-top: 24px;
}

.sidebar-nav-group-secondary {
  padding-top: 4px;
}

.sidebar-nav-label {
  padding: 0 12px 7px;

  color: #94A3B8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav-link {
  min-height: 44px;

  display: flex;
  align-items: center;
  gap: 11px;

  box-sizing: border-box;
  padding: 9px 12px;

  border-radius: 8px;

  color: #475569;
  font-size: 0.89rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-nav-link:hover,
.sidebar-nav-link[aria-current="page"],
.sidebar-nav-link:focus-visible {
  background: var(--tr-blue-soft);
  color: var(--tr-blue-dark);
}

.sidebar-nav-icon {
  width: 21px;

  display: inline-flex;
  justify-content: center;
  align-items: center;

  color: #64748B;
  font-size: 0.9rem;
}


/* =========================================================
   Sidebar footer
   ========================================================= */

.app-sidebar-footer {
  padding: 14px 16px 18px;

  border-top: 1px solid var(--tr-border);
}

.sidebar-org {
  margin-bottom: 16px;
}
.sidebar-org-logo { width: 34px; height: 34px; margin-bottom: 6px; border: 2px solid var(--org-primary, #2563EB); border-radius: 9px; object-fit: cover; }

.sidebar-org small {
  display: block;

  color: #94A3B8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-org strong {
  display: block;
  margin-top: 4px;

  color: var(--tr-navy);
  font-size: 0.82rem;
  line-height: 1.35;
}

.sidebar-mission {
  margin: 0 0 14px;
  padding: 11px 12px;

  border-radius: 9px;
  background: #F8FAFC;
}

.sidebar-mission p {
  margin: 0 0 4px;

  color: #64748B;
  font-size: 0.71rem;
  line-height: 1.45;
}

.sidebar-mission small {
  color: #94A3B8;
  font-size: 0.66rem;
}

.sidebar-footer-brand {
  display: none;
}


/* =========================================================
   Top bar
   ========================================================= */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 25;

  height: var(--tr-topbar-height);
  box-sizing: border-box;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  padding: 0 28px;

  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--tr-border);
}

.app-topbar-context {
  min-width: 0;
}

.topbar-org-name {
  display: block;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  color: #475569;
  font-size: 0.88rem;
  font-weight: 650;
}

.app-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.notification-bell { position: relative; }
.notification-bell > summary { position: relative; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--tr-border); border-radius: 50%; background: #fff; color: var(--tr-navy); cursor: pointer; list-style: none; font-size: 1.3rem; }
.notification-bell > summary::-webkit-details-marker { display: none; }
.notification-bell > summary strong { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; border-radius: 999px; background: #DC2626; color: #fff; font-size: .62rem; line-height: 1; }
.notification-bell-panel { position: absolute; top: calc(100% + 10px); right: 0; width: min(380px, calc(100vw - 24px)); overflow: hidden; border: 1px solid var(--tr-border); border-radius: 14px; background: #fff; box-shadow: 0 18px 45px rgba(15, 35, 65, .18); }
.notification-bell-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--tr-border); }
.notification-bell-panel > header span { display: grid; gap: 2px; }
.notification-bell-panel > header small { color: #64748B; }
.notification-bell-panel form { margin: 0; }
.notification-bell-list { max-height: min(52vh, 430px); overflow-y: auto; }
.notification-bell-list > p { margin: 0; padding: 24px 14px; color: #64748B; text-align: center; }
.notification-bell-item { border-bottom: 1px solid #EDF2F7; }
.notification-bell-item button { width: 100%; display: grid; gap: 3px; padding: 12px 14px; border: 0; background: #fff; color: #334155; text-align: left; cursor: pointer; }
.notification-bell-item.is-unread button { border-left: 4px solid var(--org-primary, #2563EB); background: #F4F8FF; }
.notification-bell-item button:hover, .notification-bell-item button:focus-visible { background: #EEF5FF; }
.notification-bell-item span { font-size: .78rem; line-height: 1.4; }
.notification-bell-item small { color: #64748B; font-size: .68rem; }
.notification-bell-all { display: block; padding: 11px 14px; color: #1D4ED8; font-size: .78rem; font-weight: 800; text-align: center; text-decoration: none; }
.notification-bell-all:hover, .notification-bell-all:focus-visible { text-decoration: underline; }


/* =========================================================
   User menu
   ========================================================= */

.app-topbar .user-menu {
  position: relative;
}

.app-topbar .user-menu summary {
  list-style: none;
  cursor: pointer;

  min-height: 44px;

  display: flex;
  align-items: center;
  gap: 9px;

  padding: 4px 7px;

  border-radius: 9px;
}

.app-topbar .user-menu summary::-webkit-details-marker {
  display: none;
}

.app-topbar .user-menu summary:hover {
  background: #F8FAFC;
}

.app-topbar .user-avatar {
  width: 34px;
  height: 34px;

  display: inline-grid;
  place-items: center;

  flex: 0 0 auto;

  border-radius: 50%;
  background: var(--tr-blue);
  color: #FFFFFF;

  font-size: 0.85rem;
  font-weight: 800;
}

.user-menu-name {
  max-width: 175px;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  color: #334155;
  font-size: 0.84rem;
  font-weight: 650;
}

.user-menu-chevron {
  color: #94A3B8;
  font-size: 0.8rem;
}

.app-topbar .user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;

  width: 230px;

  padding: 7px;

  border: 1px solid var(--tr-border);
  border-radius: 11px;

  background: #FFFFFF;

  box-shadow:
    0 16px 35px rgba(15, 23, 42, 0.12),
    0 2px 7px rgba(15, 23, 42, 0.05);
}

.app-topbar .user-menu-header {
  padding: 9px 10px 12px;
  border-bottom: 1px solid var(--tr-border);
  margin-bottom: 5px;
}

.app-topbar .user-menu-header strong,
.app-topbar .user-menu-header small {
  display: block;
}

.app-topbar .user-menu-header strong {
  color: var(--tr-navy);
  font-size: 0.86rem;
}

.app-topbar .user-menu-header small {
  margin-top: 2px;

  color: var(--tr-muted);
  font-size: 0.74rem;

  overflow-wrap: anywhere;
}

.app-topbar .user-menu-panel > a,
.app-topbar .user-menu-item {
  box-sizing: border-box;

  width: 100%;
  min-height: 40px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  padding: 8px 10px;

  border-radius: 7px;

  color: #334155;
  font-size: 0.8rem;
  text-decoration: none;
}

.app-topbar .user-menu-panel > a:hover {
  background: #F8FAFC;
}

.app-topbar .user-menu-item.is-disabled {
  color: #94A3B8;
}

.app-topbar .user-menu-item small {
  font-size: 0.65rem;
}

.app-topbar .user-menu-logout {
  margin-top: 5px;
  border-top: 1px solid var(--tr-border);
}


/* =========================================================
   Main content
   ========================================================= */

.app-content {
  min-width: 0;
  flex: 1;

  background: var(--tr-page);
}

.app-content-inner {
  width: min(100%, 1280px);
  box-sizing: border-box;

  margin: 0 auto;
  padding: 26px 32px 48px;
}

.app-messages {
  width: min(100%, 1280px);
  box-sizing: border-box;

  margin: 18px auto 0;
  padding: 0 32px;
}


/* =========================================================
   Make old page-width rules harmless inside app shell
   ========================================================= */

.app-shell .page-width {
  width: auto;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}


/* =========================================================
   General TendReach card language
   ========================================================= */

.app-shell .card,
.app-shell .panel {
  border-color: var(--tr-border);
}

.app-shell h1,
.app-shell h2,
.app-shell h3 {
  color: var(--tr-navy);
}


/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 1024px) {

  :root {
    --tr-sidebar-width: 188px;
  }

  .app-content-inner {
    padding-left: 22px;
    padding-right: 22px;
  }

  .app-topbar {
    padding-left: 22px;
    padding-right: 22px;
  }

  .brand-sidebar {
    gap: 8px;
  }

  .brand-sidebar img {
    width: 32px;
    height: 32px;
  }

  .brand-sidebar .brand-copy strong {
    font-size: 1rem;
  }

  .user-menu-name {
    display: none;
  }
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 760px) {

  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: relative;
    width: 100%;
    height: auto;

    border-right: 0;
    border-bottom: 1px solid var(--tr-border);
  }

  .app-sidebar-brand {
    min-height: 60px;
    padding: 0 16px;
  }

  .brand-sidebar .brand-copy small {
    display: none;
  }

  .app-sidebar-nav {
    display: flex;
    gap: 5px;

    overflow-x: auto;

    padding: 8px 12px 10px;

    border-top: 1px solid #F1F5F9;
  }

  .sidebar-nav-group {
    display: flex;
    gap: 5px;
  }

  .sidebar-nav-group + .sidebar-nav-group {
    margin-top: 0;
  }

  .sidebar-nav-label {
    display: none;
  }

  .sidebar-nav-link {
    flex: 0 0 auto;
    min-height: 42px;

    padding: 8px 11px;

    background: #F8FAFC;
  }

  .sidebar-nav-icon {
    display: none;
  }

  .app-sidebar-footer {
    display: none;
  }

  .app-topbar {
    position: relative;

    height: 56px;

    padding: 0 14px;
  }

  .topbar-org-name {
    font-size: 0.79rem;
  }

  .app-content-inner {
    padding: 18px 14px 36px;
  }

  .app-messages {
    padding-left: 14px;
    padding-right: 14px;
  }

  .user-menu-name,
  .user-menu-chevron {
    display: none;
  }
}


/* =========================================================
   Very small screens
   ========================================================= */

@media (max-width: 390px) {

  .app-content-inner {
    padding-left: 11px;
    padding-right: 11px;
  }

  .app-sidebar-nav {
    padding-left: 9px;
    padding-right: 9px;
  }

  .sidebar-nav-link {
    font-size: 0.78rem;
  }
}
