/*
 * portal.css: the look of the portal shell (index.html): the sign-in card, the menu on the left, the header and the
 * frame where the pages open. The pages inside the frame have their own styles (workspace.css, home.html …).
 *
 * Sections: colours, the page, the sign-in card, the menu, the header, the frame, phones, the Customize dialog,
 * the light and dark themes, and last the phones' 44px touch targets. i18n/rtl.css mirrors the menu for Persian and
 * Arabic.
 */

/* ---- Colours used in several places (the light theme changes them at the end of this file) ---- */
:root {
  --navy: #152d3a;
  --teal: #087f8c;
  --line: #e2e8ee;
  --muted: #647585;
}

/* ---- The page ---- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f6f8;
  color: #172d3b;
}
body {
  overflow: hidden;
}
/* Two columns: the menu and the rest. */
.shell {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

/* ---- The sign-in card (covers everything until someone is signed in) ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top left, #dcece9, transparent 60%), #eff4f6;
}
.login-screen.hidden {
  display: none;
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 22px 60px #17394712;
}
.login-card h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.04em;
  color: #152d3a; /* not var(--navy): the light theme makes it the menu's near-white */
}
.login-subtitle {
  margin-top: 5px;
  margin-bottom: 28px;
  color: #64748b;
  font-size: 14px;
}
.login-card label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}
.login-card input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 15px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px #087f8c15;
}
#loginButton,
#setupPasswordButton {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
#loginButton:disabled,
#setupPasswordButton:disabled {
  opacity: 0.6;
  cursor: wait;
}
/* The "create your password" form shows instead of email and password after an invitation or reset link. */
#passwordSetup {
  display: none;
}
#passwordSetup.active {
  display: block;
}
#normalLogin.hidden-form {
  display: none;
}
#loginError {
  min-height: 18px;
  margin-top: 12px;
  color: #b91c1c;
  font-size: 13px;
  text-align: center;
}

/* ---- The menu ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 16px 0;
  /* Taller than the screen (a laptop)? The menu scrolls by itself, so Sign Out is always reachable. */
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  background: var(--navy);
  color: #fff;
}
/* "GFM" in a rounded square, then the name and the mission. A click opens the Overview. */
.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 4px 10px 12px;
  border-radius: 12px;
}
.brand:before {
  content: "GFM";
  grid-column: 1;
  grid-row: 1/3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 13px;
  background: #ffffff14;
  border: 1px solid #ffffff24;
  color: #aee1dd;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.brand-title {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.brand-subtitle {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  margin: 1px 0 0;
  color: #a8bec9;
  font-size: 10px;
  line-height: 1.5;
}
/* WEEKLY, INFORMATION, INSIGHTS, MANAGER: the section headings of the menu. Logical margins/padding keep them
   aligned for Arabic and Persian (RTL). */
.nav-group-title {
  margin: 14px 12px 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ffffff10;
  text-transform: uppercase;
  color: #7f9caa;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.nav-item {
  width: 100%;
  margin: 1px 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c6d7df;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.nav-item:hover {
  background: #ffffff0c;
  color: #fff;
}
.nav-item.active {
  background: #ffffff16;
  color: #fff;
  box-shadow: inset 3px 0 #61c4bc;
}
html[dir="rtl"] .nav-item.active {
  box-shadow: inset -3px 0 #61c4bc;
}
.nav-item:focus-visible,
.portal-action:focus-visible {
  outline: 2px solid #61c4bc;
  outline-offset: 3px;
}
.nav-item .nav-icon {
  display: inline-grid;
  width: 22px;
  color: #81aaa9;
}
/* DA Management sits under its own MANAGER heading (the managers' section, above Sign Out). */
.nav-item.management {
  margin-top: 2px;
}
/* Sign Out and the name of the person signed in, at the bottom. */
.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  /* A real gap under Sign Out (also above the home bar of a phone). */
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #ffffff16;
}
.user-summary {
  padding: 0 14px 14px;
  color: #a8bec9;
  font-size: 12px;
  line-height: 1.4;
}

/* ---- The header: the ☰ button (phones), the page title, the buttons ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 82px;
  flex: 0 0 82px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.mobile-menu {
  display: none;
  margin-right: 12px;
  border: 0;
  background: transparent;
  color: #294e60;
  font-size: 24px;
  cursor: pointer;
}
.page-heading {
  min-width: 0;
  flex: 1;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.page-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.portal-actions {
  display: flex;
  gap: 8px;
}
.portal-action {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #345064;
  font: 600 12px inherit;
  white-space: nowrap;
  cursor: pointer;
}
.portal-action:hover {
  background: #f1f6f8;
  border-color: #b8cbd3;
}
.portal-action.primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.portal-language {
  max-width: 130px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #345064;
  font: inherit;
  font-size: 12px;
}
/* The message line under the header (reminders). */
.portal-notice {
  padding: 9px 28px;
  background: #e6f2f0;
  color: #315f67;
  font-size: 12px;
  line-height: 1.5;
}
.portal-notice[hidden] {
  display: none;
}

/* ---- The frame where the pages open, and the "Loading …" chip over it ---- */
.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 16px;
  background: #f3f6f8;
}
#appFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px #17394705;
}
.portal-loading {
  position: absolute;
  top: 27px;
  right: 28px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 2px 12px #17394718;
  color: #47606f;
  font-size: 12px;
  pointer-events: none;
}
.portal-loading[hidden] {
  display: none;
}
.portal-loading:before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid #d7e9e7;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: portal-spin 0.8s linear infinite;
}
@keyframes portal-spin {
  to {
    transform: rotate(360deg);
  }
}
/* A page that could not open: the reason in the chip, without the spinner, so it does not look like loading. */
.portal-loading[data-state="error"] {
  background: #fff4e8;
  color: #7a3410;
}
.portal-loading[data-state="error"]:before {
  display: none;
}
/* Phones only: the dark layer behind the open menu. */
.mobile-overlay {
  display: none;
}

/* ---- Phones: the menu slides in from the left (☰), the header is smaller ---- */
@media (max-width: 780px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -290px;
    z-index: 100;
    width: 280px;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.12);
    transition: left 0.2s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .mobile-menu {
    display: block;
  }
  .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    background: rgba(15, 23, 42, 0.34);
  }
  .mobile-overlay.open {
    display: block;
  }
  .main {
    height: 100dvh;
  }
  .topbar {
    height: 76px;
    flex-basis: 76px;
    padding: 0 16px;
  }
  .page-title {
    font-size: 17px;
  }
  .page-subtitle {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .portal-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
    max-width: 180px;
  }
  .portal-action {
    padding: 8px;
    font-size: 11px;
  }
  .portal-actions .portal-action {
    padding: 6px;
    font-size: 10px;
  }
  .portal-language {
    max-width: 95px;
    padding: 5px;
  }
  .portal-notice {
    padding: 8px 16px;
  }
  .frame-wrap {
    padding: 8px;
  }
  .portal-loading {
    top: 18px;
    right: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
  .portal-loading:before {
    animation: none;
  }
}

/* ---- The Customize dialog (the portal theme) ---- */
/* Every pop-up of the shell: a visible border, a soft shadow and a dimmed page behind it (as workspace.css and home.css). */
dialog {
  border: 1px solid var(--line);
  box-shadow:
    0 24px 64px #0f2a3640,
    0 2px 8px #0f2a3624;
}
dialog::backdrop {
  background: #0f2a3673;
}
html[data-theme="dark"] dialog {
  border-color: #6a8794;
  box-shadow:
    0 24px 64px #000000a6,
    0 0 0 1px #00000066;
}
html[data-theme="dark"] dialog::backdrop {
  background: #000000a6;
}
.portal-customizer {
  width: min(520px, 94vw);
  padding: 0;
  border-radius: 18px;
  color: #183240;
  background: #fff;
}
html[data-theme="dark"] .portal-customizer { background: #1e303a; color: #f2f8f9; }
html[data-theme="dark"] .portal-customizer p { color: #c0d0d5; }
html[data-theme="dark"] .portal-customizer select { background: #101a21; color: #f2f8f9; border-color: #6a8794; }
.portal-customizer form {
  padding: 25px;
}
.portal-customizer h2 {
  margin: 0 0 7px;
}
.portal-customizer p {
  color: #647585;
  font-size: 13px;
}
.portal-customizer > form > label {
  display: grid;
  gap: 7px;
  margin: 18px 0;
  font-size: 12px;
  font-weight: 700;
}
.portal-customizer select {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.customizer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ---- Themes: "mission" (navy and teal) is everything above; light and dark change these parts ---- */
html[data-theme="light"] {
  --navy: #f8fafb;
  --teal: #087f8c;
}
html[data-theme="light"] .sidebar {
  background: #f8fafb;
  color: #173644;
  border-right: 1px solid var(--line);
}
html[data-theme="light"] .nav-item {
  color: #496573;
}
html[data-theme="light"] .nav-item:hover,
html[data-theme="light"] .nav-item.active {
  background: #e7f2f2;
  color: #173644;
}
html[data-theme="light"] .brand-subtitle,
html[data-theme="light"] .user-summary,
html[data-theme="light"] .nav-group-title {
  color: #5b707a;
}
html[data-theme="light"] .nav-group-title {
  border-bottom-color: #dfe8ec;
}
html[data-theme="light"] .nav-item .nav-icon {
  color: #3f7472;
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main,
html[data-theme="dark"] .frame-wrap {
  background: #101a21;
  color: #f2f8f9;
}
html[data-theme="dark"] .topbar {
  background: #1e303a;
  border-color: #4c6875;
}
html[data-theme="dark"] .page-subtitle {
  color: #c0d0d5;
}
html[data-theme="dark"] .portal-action,
html[data-theme="dark"] .portal-language {
  background: #2e4855;
  color: #f2f8f9;
  border-color: #6a8794;
}
html[data-theme="dark"] .portal-action:hover {
  background: #3a5866;
}
html[data-theme="dark"] .portal-action.primary {
  background: var(--teal);
  border-color: var(--teal);
}
html[data-theme="dark"] .nav-group-title,
html[data-theme="dark"] .brand-subtitle,
html[data-theme="dark"] .user-summary {
  color: #a9c2cd;
}

/* ---- Full screen for the page in the frame (portal-enhancements.js, section 4): the browser's own full screen of
   .frame-wrap, or "expanded" (the box fills the window) where a page cannot go full screen, such as iPhone Safari. ---- */
.frame-wrap:fullscreen,
.frame-wrap.frame-expanded {
  padding: 0;
  background: #f3f6f8;
}
.frame-wrap:-webkit-full-screen {
  padding: 0;
}
.frame-wrap.frame-expanded {
  position: fixed;
  inset: 0;
  z-index: 1000;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
html.frame-expanded-open,
html.frame-expanded-open body {
  overflow: hidden;
}
.frame-wrap:fullscreen #appFrame,
.frame-wrap.frame-expanded #appFrame {
  border: 0;
  border-radius: 0;
}
/* "Exit full screen": a small button in the top corner (the end side: right, or left for Arabic and Persian). It fades
   out about 2 s after it appeared (the .faded class, portal-enhancements.js) and comes back on mouse move, tap or key.
   .frame-exit-zone is an invisible corner area above the frame: a page from another address cannot report mouse moves,
   so moving into the corner (or a first tap there) brings the button back. While the button shows, the zone lets
   clicks through to it. */
.frame-exit-fullscreen {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  inset-inline-end: calc(22px + env(safe-area-inset-right));
  z-index: 4;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid #c9d6dc;
  border-radius: 9px;
  background: #ffffffe6;
  color: #173947;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px #17394722;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.frame-exit-fullscreen.faded {
  opacity: 0;
  pointer-events: none;
}
.frame-exit-fullscreen:focus-visible {
  opacity: 1;
}
.frame-exit-fullscreen[hidden],
.frame-exit-zone[hidden] {
  display: none;
}
.frame-exit-zone {
  position: absolute;
  bottom: 0;
  inset-inline-end: 0;
  z-index: 3;
  width: 190px;
  height: calc(56px + env(safe-area-inset-bottom));
}
.frame-exit-fullscreen:not(.faded) ~ .frame-exit-zone {
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .frame-exit-fullscreen {
    transition: none;
  }
}
html[data-theme="dark"] .frame-wrap:fullscreen,
html[data-theme="dark"] .frame-wrap.frame-expanded {
  background: #101a21;
}
html[data-theme="dark"] .frame-exit-fullscreen {
  background: #2e4855e6;
  color: #f2f8f9;
  border-color: #6a8794;
}
@media (max-width: 780px) {
  .frame-exit-fullscreen {
    min-height: 44px;
    padding: 6px 14px;
    font-size: 15px;
    inset-inline-end: calc(10px + env(safe-area-inset-right));
  }
  .frame-exit-zone {
    width: 170px;
    height: calc(64px + env(safe-area-inset-bottom));
  }
}

/* ---- Phones: 44px touch targets (portal-enhancements.js puts the settings menu in the place named here; see placeHeaderControls). Kept last: these win over the rules above. ---- */
@media (max-width: 780px) {
  /* The header: the menu button, Library and Reload at 44px. Slimmer gaps and padding leave the title room for
     "Presentations" next to Library and Reload on a 360px phone; a word breaks only when it cannot fit on a line of
     its own. */
  .main > .topbar {
    gap: 10px;
    padding: 0 12px;
  }
  .topbar .mobile-menu {
    min-width: 44px;
    min-height: 44px;
    margin-right: 0;
    padding: 0;
    border-radius: 9px;
  }
  .topbar .portal-actions {
    flex-wrap: nowrap;
    max-width: none;
    gap: 6px;
    flex-shrink: 0;
  }
  .topbar .portal-actions .portal-action {
    min-height: 44px;
    padding: 10px;
    font-size: 14px;
  }
  .topbar .page-title {
    overflow-wrap: break-word;
  }
  /* The menu: every item 44px; it scrolls when it is taller than the screen, so Sign Out stays reachable. */
  .sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sidebar .nav-item {
    min-height: 44px;
  }
  .sidebar-bottom .portal-language {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 44px;
    margin: 4px 0 6px;
    padding: 10px 12px;
    font-size: 16px;
  }
  .sidebar-bottom .portal-language[hidden] {
    display: none;
  }
  /* The Customize dialog: a 16px select (no zoom on focus) and 44px buttons. */
  .portal-customizer select {
    min-height: 44px;
    font-size: 16px;
  }
  .portal-customizer .customizer-actions .portal-action {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }
}


/* ---- Round 14 (clean UI) ---------------------------------------------------------------------------------------- */
/* No white flash: the shell, the frame's box and the frame itself carry the theme's background before a page paints,
   and the frame stays invisible until its page has loaded (.frame-loading, portal-enhancements.js). */
html { color-scheme: light; }  /* the theme decides, not the computer: a light theme never gets dark form controls or dialogs */
html[data-theme="dark"], html[data-theme="dark"] body { background: #101a21; color-scheme: dark; }
html[data-theme="dark"] #appFrame { background: #101a21; border-color: #4c6875; }
.frame-wrap.frame-loading #appFrame { visibility: hidden; }
/* The loading chip sits at the bottom centre, so it never covers a page's own top-right buttons (Whiteboard "New board"). */
.portal-loading { top: auto; right: auto; bottom: 28px; left: 50%; transform: translateX(-50%); }
html[data-theme="dark"] .portal-loading { background: #2e4855; color: #f2f8f9; }
/* The one Settings menu in the header: language, theme, tour, reload. */
.portal-settings { position: relative; }
.portal-settings > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.portal-settings > summary::-webkit-details-marker { display: none; }
.portal-settings-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; display: grid; gap: 4px;
  padding: 8px; border: 1px solid var(--line, #d9e5e8); border-radius: 12px; background: #fff; box-shadow: 0 10px 30px #17394726; }
.portal-settings-item { min-height: 40px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: #173644; font: inherit; font-size: 14px; text-align: start; cursor: pointer; }
.portal-settings-item:hover, .portal-settings-item:focus-visible { background: #e7f2f2; }
.portal-settings-language { display: grid; gap: 4px; padding: 4px 8px 8px; font-size: 12px; font-weight: 700; color: #5a7380; border-bottom: 1px solid var(--line, #d9e5e8); }
.portal-settings-language .portal-language { width: 100%; min-height: 40px; }
html[data-theme="dark"] .portal-settings-panel { background: #1e303a; border-color: #6a8794; box-shadow: 0 10px 30px #000000a6; }
html[data-theme="dark"] .portal-settings-item { color: #f2f8f9; }
html[data-theme="dark"] .portal-settings-item:hover { background: #2e4855; }
html[data-theme="dark"] .portal-settings-language { color: #c0d0d5; border-color: #4c6875; }
.mobile-menu svg { display: block; margin: auto; }
@media (max-width: 780px) {
  /* In the side menu: the Settings menu opens in place, every row 44 px. */
  .sidebar-bottom .portal-settings > summary { width: 100%; min-height: 44px; justify-content: flex-start; }
  .sidebar-bottom .portal-settings-panel { position: static; box-shadow: none; margin: 4px 0 8px; }
  .sidebar-bottom .portal-settings-item, .sidebar-bottom .portal-language { min-height: 44px; font-size: 15px; }
  .nav-item { min-height: 44px; }
  /* Page titles never break inside a word ("Presentations"). */
  .page-title { overflow-wrap: normal; word-break: normal; hyphens: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .page-heading { min-width: 0; flex: 1 1 auto; }
}

/* Round 14: the sign-in card follows the theme (no white flash on a dark device). */
html[data-theme="dark"] .login-screen{background:#101a21;color:#f2f8f9}
html[data-theme="dark"] .login-card{background:#1e303a;border-color:#4c6875;color:#f2f8f9;box-shadow:0 20px 60px #0009}
html[data-theme="dark"] .login-card h1{color:#f2f8f9}
html[data-theme="dark"] .login-card label{color:#d7e6ea}
html[data-theme="dark"] .login-card input{background:#101a21;color:#f2f8f9;border-color:#6a8794}
html[data-theme="dark"] .login-subtitle{color:#c0d0d5}
html[data-theme="dark"] #loginError{color:#ff9b91}

/* Round 14: Mission drive is a real link (new tab), styled like the other menu buttons. */
a.nav-item.nav-link{text-decoration:none;display:flex;align-items:center;box-sizing:border-box}
