/* ---- Page shell ---- */

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

.app-main {
  flex: 1 0 auto;
  width: 100%;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ---- Header ---- */

.site-header {
  background: var(--color-navy);
  color: var(--color-text-on-navy);
  border-bottom: 1px solid var(--color-navy-900);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-height);
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  line-height: 1;
  text-decoration: none;
  color: var(--color-text-on-navy);
  padding: var(--space-2) 0;
}

.brand:hover {
  color: var(--color-text-on-navy);
  text-decoration: none;
}

.brand__logo {
  display: block;
  height: 36px;
  width: auto;
}

.brand__icon {
  display: block;
  height: 40px;
  width: 40px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand__icon--login {
  height: 56px;
  width: 56px;
  border-radius: 12px;
}

.brand__wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__wordmark--login {
  gap: 4px;
}

.brand__name {
  font-family: var(--font-display, var(--font-sans, Inter)), system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.brand__name--dark {
  color: #0F1F3D;
  font-size: 22px;
}

.brand__mark {
  font-size: var(--fs-20);
  font-weight: var(--fw-bold);
  letter-spacing: 0.01em;
}

.brand__sub {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: rgba(255, 255, 255, 0.78);
  margin-top: 4px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand__sub--dark {
  color: rgba(15, 31, 61, 0.7);
  font-size: 11px;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-3);
}

.primary-nav__link {
  position: relative;
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.primary-nav__link:hover {
  color: var(--color-text-on-navy);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.primary-nav__link[aria-current="page"] {
  color: var(--color-text-on-navy);
}

.primary-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: -10px;
  height: 2px;
  background: var(--color-red);
  border-radius: 2px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  padding: 2px;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

.lang-toggle__btn {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
}

.lang-toggle__btn:not([aria-pressed="true"]):hover {
  color: var(--color-text-on-navy);
}

.lang-toggle__btn[aria-pressed="true"] {
  background: var(--color-text-on-navy);
  color: var(--color-navy);
}

/* Keyboard focus on the navy header/footer needs a light ring — the default
   navy-tinted ring would all but vanish against the dark bars. */
.site-header a:focus-visible,
.site-header button:focus-visible,
.site-footer a:focus-visible {
  box-shadow: var(--focus-ring-on-navy);
}

.notif-bell {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--color-text-on-navy);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notif-bell:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Wrap the bell button so the dropdown can position relative to it. */
.notif-wrapper {
  position: relative;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.notif-dropdown[hidden] {
  display: none;
}

.notif-dropdown__header {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.notif-dropdown__item {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.notif-dropdown__item:last-child {
  border-bottom: 0;
}

.notif-dropdown__item:hover {
  background: var(--color-surface-alt);
}

.notif-dropdown__title {
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  line-height: 1.4;
}

.notif-dropdown__body {
  font-size: var(--fs-12);
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.notif-dropdown__time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Override the navy-bar focus ring for items inside the light dropdown. */
.site-header .notif-dropdown__item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.notif-bell__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-red);
  color: var(--color-text-on-navy);
  font-size: 10px;
  font-weight: var(--fw-bold);
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--color-navy);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  padding: 4px var(--space-3) 4px 4px;
  color: var(--color-text-on-navy);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.user-pill__avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--color-red);
  color: var(--color-text-on-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  object-position: center 20%;
  font-size: var(--fs-12);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
}

/* Demo-only role switcher — stands in for a static "Viewing as" line.
   The trigger reads as quiet gray against the navy header and only gains
   weight on hover / when open; the popover is a light surface anchored
   below it. Mounted + wired by assets/js/nav.js. */
.role-switcher {
  position: relative;
}

.role-switcher__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: var(--space-2) 6px;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.role-switcher__trigger:hover,
.role-switcher__trigger[aria-expanded="true"] {
  color: var(--color-text-on-navy);
  background: rgba(255, 255, 255, 0.06);
}

.role-switcher__caret {
  font-size: 9px;
  line-height: 1;
}

.role-switcher__popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 200px;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.role-switcher__popover[hidden] {
  display: none;
}

.role-switcher__label {
  padding: 6px var(--space-2) var(--space-2);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.role-switcher__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 6px var(--space-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}

.role-switcher__option:hover {
  background: var(--color-surface-alt);
}

/* The popover sits inside .site-header, whose focus rule paints a light ring
   for the navy bar — invisible on this white surface. Override with the
   standard dark ring (higher specificity wins regardless of source order). */
.site-header .role-switcher__option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.role-switcher__check {
  display: inline-flex;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
  color: var(--color-navy);
  font-weight: var(--fw-bold);
}

.role-switcher__divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--color-border);
}

.role-switcher__signout {
  color: var(--color-text-muted);
}

.signout-link {
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: rgba(255, 255, 255, 0.72);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.signout-link:hover {
  color: var(--color-text-on-navy);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

/* ---- Page heading region ---- */

.page-header {
  padding: var(--space-7) 0 var(--space-5);
}

.page-header__eyebrow {
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.page-header__title {
  font-size: var(--fs-28);
  font-weight: var(--fw-bold);
}

.page-header__subtitle {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--fs-15);
}

.page-section {
  padding: var(--space-5) 0 var(--space-7);
}

/* ---- Footer ---- */

.site-footer {
  background: var(--color-navy);
  color: rgba(255, 255, 255, 0.78);
  margin-top: var(--space-10);
  padding: var(--space-7) 0 var(--space-6);
  font-size: var(--fs-13);
}

.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
}

.site-footer__brand {
  color: var(--color-text-on-navy);
  font-weight: var(--fw-semibold);
}

.site-footer__logo {
  display: block;
  height: 28px;
  width: auto;
}

.site-footer__divider {
  color: rgba(255, 255, 255, 0.32);
}

.site-footer__meta {
  margin-top: var(--space-3);
  font-size: var(--fs-12);
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- Responsive squeeze ---- */

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
}

@media (max-width: 840px) {
  .site-header__inner {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
  }
  .primary-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .primary-nav::-webkit-scrollbar {
    display: none;
  }
  .primary-nav__link[aria-current="page"]::after {
    bottom: -6px;
  }
  .header-actions {
    margin-left: auto;
  }
  .container {
    padding: 0 var(--space-4);
  }
}

/* ---- Mobile-first breakpoint ---- */

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-3);
  }

  /* Header: stack brand + actions, add side padding so logo isn't flush */
  .site-header__inner {
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .brand__mark {
    font-size: var(--fs-16);
  }

  .brand__sub {
    font-size: 10px;
  }

  /* Hide lang toggle on very small screens */
  .lang-toggle {
    display: none;
  }

  /* Compact the role switcher */
  .role-switcher__trigger {
    font-size: 11px;
    padding: var(--space-1) 4px;
  }

  /* Truncate user name on mobile */
  .user-pill {
    max-width: 140px;
    padding: 3px var(--space-2) 3px 3px;
    font-size: var(--fs-12);
  }

  .user-pill__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
    display: inline-block;
  }

  .user-pill__avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  /* Sign out link — hide text, keep accessible */
  .signout-link {
    font-size: var(--fs-12);
    padding: var(--space-1) var(--space-2);
  }

  /* Nav links: smaller on mobile */
  .primary-nav {
    gap: 0;
  }

  .primary-nav__link {
    font-size: var(--fs-12);
    padding: var(--space-2) var(--space-2);
    white-space: nowrap;
  }

  /* Hero: stack vertically */
  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .hero__greeting {
    font-size: var(--fs-20);
  }

  .hero__deadline {
    width: 100%;
  }

  /* Dashboard controls */
  .dash-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .entity-switcher {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .entity-switcher__pill {
    font-size: var(--fs-12);
    padding: 4px var(--space-2);
  }

  /* Page headers */
  .page-header {
    padding: var(--space-5) 0 var(--space-4);
  }

  .page-header__title {
    font-size: var(--fs-20);
  }

  /* Cards: tighter padding */
  .card__header {
    padding: var(--space-3) var(--space-4);
  }

  .card__body {
    padding: var(--space-3) var(--space-4);
  }

  .card__footer {
    padding: var(--space-2) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Deadline cards */
  .deadline-card {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .deadline-card__date {
    min-width: 48px;
    padding: 4px 8px;
  }

  .deadline-card__title {
    font-size: var(--fs-14);
  }

  .deadline-card__countdown {
    font-size: var(--fs-12);
  }

  /* RFI cards */
  .rfi-card {
    padding: var(--space-3) var(--space-4);
  }

  .rfi-card__title {
    font-size: var(--fs-14);
  }

  /* Filing cards */
  .filing-card {
    padding: var(--space-3) var(--space-4);
  }

  .filing-card__title {
    font-size: var(--fs-14);
  }

  /* Activity rows */
  .activity-row {
    padding: var(--space-2) var(--space-4);
    gap: var(--space-2);
  }

  .activity-row__body {
    font-size: var(--fs-13);
  }

  /* Document rows */
  .doc-row {
    padding: var(--space-2) var(--space-4);
  }

  /* Notification dropdown */
  .notif-dropdown {
    width: calc(100vw - var(--space-4) * 2);
    right: calc(-1 * var(--space-3));
  }

  /* Footer */
  .site-footer {
    margin-top: var(--space-7);
    padding: var(--space-5) 0 var(--space-4);
  }

  .site-footer__row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .site-footer__divider {
    display: none;
  }

  /* Toast */
  .toast {
    width: calc(100% - var(--space-6));
    font-size: var(--fs-13);
  }
}
