/*
  Portal look: gradients, rounded cards and tables, soft shadows, in both the light and the dark theme.
  Colours come from CSS variables that /branding/theme.css derives from the owner's branding (Services/Branding/BrandTheme.cs):
  --brand-page-bg, --brand-page-tint, --brand-page-glow, --brand-surface, --brand-shadow, --brand-shadow-sm,
  --brand-header-bg, --brand-header-bg-2, --brand-header-text, --brand-header-text-rgb, --brand-btn-bg, --brand-btn-text.
  theme.js sets data-bs-theme="light|dark" on <html>; Bootstrap 5.3 and theme.css do the rest.
  The Content Security Policy allows no inline styles, so everything visual lives here or in theme.css.
*/

:root {
  --portal-radius: .75rem;
  --portal-radius-sm: .5rem;
}

html {
  font-size: 14px;
  min-height: 100%;
  background-color: var(--brand-page-bg, #ffffff);
  background-image:
    radial-gradient(70rem 36rem at 100% -14rem, var(--brand-page-glow, rgba(13, 110, 253, .16)), transparent 70%),
    linear-gradient(180deg, var(--brand-page-tint, #e7f0fe) 0, var(--brand-page-bg, #ffffff) 38rem);
  background-repeat: no-repeat;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background-color: transparent;
}

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

.brand-header {
  border-bottom: 1px solid rgba(var(--brand-header-text-rgb, 33, 37, 41), .12);
  box-shadow: var(--brand-shadow-sm);
  margin-bottom: 1.5rem;
  padding-top: .6rem;
  padding-bottom: .6rem;
}

.brand-header .navbar-brand {
  font-weight: 600;
  letter-spacing: -.01em;
}

.brand-header .navbar-nav > .nav-item > .nav-link {
  border-radius: var(--portal-radius-sm);
  padding: .4rem .75rem;
  transition: background-color .15s ease;
}

@media (min-width: 576px) {
  .brand-header .navbar-collapse {
    margin-right: 1rem;
  }
}

@media (max-width: 575.98px) {
  .brand-header .navbar-collapse {
    padding-top: .75rem;
  }

  .brand-header .navbar-collapse form {
    padding-top: .5rem;
    border-top: 1px solid rgba(var(--brand-header-text-rgb, 33, 37, 41), .15);
  }
}

/* The header's buttons (sign out, menu) draw on the header text colour, so they fit any header colour. */
.brand-header .btn-outline-secondary {
  --bs-btn-color: var(--brand-header-text);
  --bs-btn-border-color: rgba(var(--brand-header-text-rgb), .35);
  --bs-btn-hover-color: var(--brand-header-text);
  --bs-btn-hover-bg: rgba(var(--brand-header-text-rgb), .12);
  --bs-btn-hover-border-color: rgba(var(--brand-header-text-rgb), .5);
  --bs-btn-active-color: var(--brand-header-text);
  --bs-btn-active-bg: rgba(var(--brand-header-text-rgb), .2);
  --bs-btn-active-border-color: rgba(var(--brand-header-text-rgb), .5);
  --bs-btn-focus-shadow-rgb: var(--brand-header-text-rgb);
}

.brand-header .navbar-toggler {
  border-color: rgba(var(--brand-header-text-rgb), .35);
  padding: .3rem .55rem;
}

.brand-header .navbar-toggler:focus {
  box-shadow: 0 0 0 .2rem rgba(var(--brand-header-text-rgb), .25);
}

/* Three bars in the current text colour instead of Bootstrap's fixed light/dark icon, so it matches any header. */
.brand-header .navbar-toggler-icon {
  background-image: none;
  position: relative;
  width: 1.4em;
  height: 1.4em;
}

.brand-header .navbar-toggler-icon::before {
  content: "";
  position: absolute;
  left: .1em;
  right: .1em;
  top: calc(50% - 1px);
  height: 2px;
  border-radius: 1px;
  background-color: currentColor;
  box-shadow: 0 -.42em 0 currentColor, 0 .42em 0 currentColor;
}

/* Light / Dark / Auto switch */
.theme-switch .btn,
.language-switch .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .3rem .55rem;
  border: 1px solid rgba(var(--brand-header-text-rgb, 33, 37, 41), .35);
  background-color: transparent;
  transition: background-color .15s ease;
}

.theme-switch .btn:hover,
.language-switch .btn:hover {
  background-color: rgba(var(--brand-header-text-rgb, 33, 37, 41), .12);
  color: var(--brand-header-text);
}

.theme-switch .btn:focus-visible,
.language-switch .btn:focus-visible {
  box-shadow: 0 0 0 .2rem rgba(var(--brand-header-text-rgb, 33, 37, 41), .3);
  z-index: 2;
}

.theme-switch .btn[aria-pressed="true"],
.language-switch .btn[aria-pressed="true"] {
  background-color: rgba(var(--brand-header-text-rgb, 33, 37, 41), .18);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
}

.language-switch .btn {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.theme-switch svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-switch .theme-switch-fill {
  fill: currentColor;
  stroke: none;
}

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

main h1 {
  font-weight: 650;
  letter-spacing: -.015em;
}

main h2 {
  font-weight: 600;
}

/* Cards */
.card {
  --bs-card-bg: var(--brand-surface, var(--bs-body-bg));
  --bs-card-border-color: var(--bs-border-color);
  --bs-card-border-radius: var(--portal-radius);
  --bs-card-inner-border-radius: calc(var(--portal-radius) - 1px);
  --bs-card-spacer-y: 1.25rem;
  --bs-card-spacer-x: 1.25rem;
  box-shadow: var(--brand-shadow);
}

.card .card-title {
  font-weight: 600;
}

/* Tables: separate borders so the corners can round, one shadow around the whole table, a soft primary gradient on the header row. */
main .table {
  --bs-table-bg: var(--brand-surface, var(--bs-body-bg));
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-hover-bg: rgba(var(--bs-primary-rgb), .06);
  --bs-table-hover-color: var(--bs-body-color);
  border-collapse: separate;
  border-spacing: 0;
  background-color: var(--bs-table-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--portal-radius);
  box-shadow: var(--brand-shadow);
  overflow: hidden;
}

main .table > :not(caption) > * > * {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--bs-border-color);
}

main .table-sm > :not(caption) > * > * {
  padding: .45rem .7rem;
}

main .table > thead > tr > th {
  font-weight: 600;
  color: var(--bs-emphasis-color);
  background-image: linear-gradient(180deg, rgba(var(--bs-primary-rgb), .16), rgba(var(--bs-primary-rgb), .07));
  border-bottom: 1px solid rgba(var(--bs-primary-rgb), .25);
  white-space: nowrap;
}

main .table > tbody > tr:last-child > * {
  border-bottom: 0;
}

main .table > tbody > tr:hover > * {
  --bs-table-color-state: var(--bs-table-hover-color);
  --bs-table-bg-state: var(--bs-table-hover-bg);
}

main .table > :first-child > tr:first-child > *:first-child { border-top-left-radius: calc(var(--portal-radius) - 1px); }
main .table > :first-child > tr:first-child > *:last-child { border-top-right-radius: calc(var(--portal-radius) - 1px); }
main .table > :last-child > tr:last-child > *:first-child { border-bottom-left-radius: calc(var(--portal-radius) - 1px); }
main .table > :last-child > tr:last-child > *:last-child { border-bottom-right-radius: calc(var(--portal-radius) - 1px); }

/* On a phone a wide table scrolls inside the page instead of making the whole page wider. */
@media (max-width: 767.98px) {
  main {
    overflow-x: auto;
    padding-top: 2px;
  }
}

/* A scrolling wrapper takes over the frame, so the shadow is not clipped and the table can still scroll sideways on a phone. */
main .table-responsive {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--portal-radius);
  box-shadow: var(--brand-shadow);
  background-color: var(--brand-surface, var(--bs-body-bg));
  margin-bottom: 1rem;
}

main .table-responsive > .table {
  border: 0;
  box-shadow: none;
  margin-bottom: 0;
}

/* Buttons and form controls */
.btn {
  --bs-btn-border-radius: var(--portal-radius-sm);
  font-weight: 500;
}

.btn-sm {
  --bs-btn-border-radius: .4rem;
}

.btn-primary {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 60%);
  box-shadow: var(--brand-shadow-sm);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 60%);
}

.btn-primary:active,
.btn-primary.active {
  background-image: none;
}

.form-control,
.form-select {
  border-radius: var(--portal-radius-sm);
}

.form-control:not(.form-control-color),
.form-select {
  padding: .5rem .8rem;
}

.form-control-sm,
.form-select-sm {
  padding: .3rem .6rem;
}

.form-label {
  font-weight: 500;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Alerts, dropdowns, badges, code */
main .alert {
  --bs-alert-border-radius: var(--portal-radius);
  box-shadow: var(--brand-shadow-sm);
}

.dropdown-menu {
  --bs-dropdown-border-radius: var(--portal-radius-sm);
  --bs-dropdown-border-color: var(--bs-border-color);
  --bs-dropdown-padding-y: .4rem;
  --bs-dropdown-item-border-radius: .35rem;
  --bs-dropdown-item-padding-x: .75rem;
  padding-left: .4rem;
  padding-right: .4rem;
  box-shadow: var(--brand-shadow);
}

.dropdown-item {
  border-radius: .35rem;
}

.badge {
  font-weight: 600;
  letter-spacing: .01em;
}

main pre {
  border-radius: var(--portal-radius-sm);
}

/* Bootstrap's grey outline button is too dim on the dark surfaces. */
[data-bs-theme="dark"] main .btn-outline-secondary {
  --bs-btn-color: #cfd5dc;
  --bs-btn-border-color: #78828e;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: #5c6672;
  --bs-btn-hover-border-color: #5c6672;
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: #6c757d;
  --bs-btn-active-border-color: #6c757d;
}

/* Utilities a page uses that Bootstrap keeps light in both themes. */
[data-bs-theme="dark"] main .bg-light {
  background-color: var(--bs-tertiary-bg) !important;
}

/* ---------- Centred cards for sign-in, two-factor, setup and invitation ---------- */

.auth-page {
  padding-top: clamp(0rem, 5vh, 3rem);
}

.auth-card {
  --bs-card-spacer-y: 1.5rem;
  --bs-card-spacer-x: 1.5rem;
}

@media (min-width: 768px) {
  .auth-card {
    --bs-card-spacer-y: 2.25rem;
    --bs-card-spacer-x: 2.25rem;
  }
}

.auth-card h1 {
  margin-bottom: 1rem;
}

/* "How your files are protected" on the sign-in page */
.security-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .75rem;
}

.security-list li {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  line-height: 1.4;
}

.security-list .security-icon {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .6rem;
  color: var(--bs-link-color);
  background-color: rgba(var(--bs-primary-rgb), .12);
  margin-top: -.15rem;
}

.security-list svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Footer and misc ---------- */

.footer {
  border-top: 1px solid var(--bs-border-color);
  background-color: rgba(var(--bs-body-bg-rgb), .5);
}

.pre-wrap {
  white-space: pre-wrap;
}

.pre-line {
  white-space: pre-line;
}

.brand-logo {
  max-height: 40px;
  max-width: 200px;
  width: auto;
}

.brand-logo-preview {
  max-height: 80px;
  max-width: 100%;
}

/* A customer's own logo on the company details pages. */
.company-logo { max-height: 80px; max-width: 100%; }

/* ---- Company groups ---- */
/* Trees of company cards (Pages/Admin/Groups). Only Bootstrap variables, so light and dark both work. */

.groups-card {
  cursor: grab;
  margin-bottom: .5rem;
}

.groups-card > .card-body {
  padding: .5rem .75rem;
}

.groups-children {
  margin-left: .75rem;
  padding-left: .75rem;
  border-left: 2px solid var(--bs-border-color);
}

@media (min-width: 576px) {
  .groups-children {
    margin-left: 1.25rem;
  }
}

.groups-handle {
  cursor: grab;
}

.groups-dragging > .groups-card {
  opacity: .5;
}

.groups-over {
  outline: 2px dashed var(--bs-primary);
  outline-offset: 2px;
  background-color: var(--bs-primary-bg-subtle);
}

.groups-loose {
  min-height: 8rem;
/* ---- Document requests ---- */
.docrequest-checklist .docrequest-overdue {
  border-left: 3px solid var(--bs-danger);
  padding-left: .5rem !important;
}
.docrequest-checklist .docrequest-done {
  opacity: .7;
}
.docrequest-upload {
  min-width: 16rem;
  max-width: 24rem;
}
.docrequest-actions > summary {
  list-style: none;
}
.docrequest-actions > summary::-webkit-details-marker {
  display: none;
}
.docrequest-actions[open] {
  min-width: 18rem;
}
