/*
 * Cassiopeia 2 — structural polish for a corporate intranet.
 * Brand-agnostic; loaded last (weight 500) via the `template.user` asset.
 */

/* White cards on the page background, with a soft, modern radius */
:root {
  --border-radius: .5rem;
  --card-border-radius: .5rem;
}

.card {
  --card-bg: #fff;
  --card-border-color: #e6e8ec;
  box-shadow: 0 1px 2px hsla(0, 0%, 0%, .05);
}

.card-header {
  --card-cap-bg: #f6f7f9;
  border-bottom: 1px solid #e6e8ec;
}

/* Header — background image + overlay (configurable) */
.container-header {
  background-image:
    linear-gradient(rgba(0, 0, 0, var(--cassiopeia-header-bg-overlay, 0)), rgba(0, 0, 0, var(--cassiopeia-header-bg-overlay, 0))),
    var(--cassiopeia-header-bg-image, none);
  background-size: cover, cover;
  background-position: center, center;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .05), 0 10px 24px -14px rgba(0, 0, 0, .35);
}

.container-header .grid-child {
  padding-top: .8rem;
  padding-bottom: .8rem;
}

/* Header bar — brand aligned left / center / right across the full width */
.container-header-bar {
  display: grid;
  /* The centre column must be able to shrink so a large logo never
     overlaps the side modules (login form etc.) at narrow widths. */
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem;
}

.header-brand,
.header-modules-left,
.header-modules-center,
.header-modules-right {
  min-width: 0;
  color: var(--headercolor);
}

.header-brand a:not(.btn),
.header-modules-left a:not(.btn),
.header-modules-center a:not(.btn),
.header-modules-right a:not(.btn) {
  color: inherit;
  text-decoration: none;
}

.header-brand a:not(.btn):hover,
.header-modules-left a:not(.btn):hover,
.header-modules-center a:not(.btn):hover,
.header-modules-right a:not(.btn):hover {
  text-decoration: underline;
}

/* Grid placement */
.header-modules-left { grid-column: 1; grid-row: 1; justify-self: start; }
.header-brand { grid-column: 2; grid-row: 1; justify-self: center; text-align: center; }
.header-modules-center { grid-column: 2; grid-row: 1; }
.header-modules-right { grid-column: 3; grid-row: 1; justify-self: end; }

.header-align-left .header-brand { text-align: left; }
.header-align-center .header-brand { text-align: center; }
.header-align-right .header-brand { text-align: right; }

/* Brand (logo left + title/tagline right) — sizes configurable in admin */
.container-header .navbar-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .85rem;
  margin-inline-end: 0;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
}

.container-header .navbar-brand .brand-logo img {
  /* The logo PNG has transparent padding around the mark (~half the canvas),
     so scale it 2x to make the visible mark the same height as the title. */
  height: calc(var(--cassiopeia-header-title-size, 1.5rem) * 2);
  width: auto;
  display: block;
}

/* Logo mark when no logo is uploaded */
.container-header .navbar-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .7rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, .06));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 1.3rem;
  text-decoration: none;
}

.container-header .navbar-brand .brand-text {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}

.container-header .navbar-brand .brand-title,
.container-header .navbar-brand .brand-tagline {
  overflow-wrap: anywhere;
}

.container-header .navbar-brand .brand-title {
  font-size: var(--cassiopeia-header-title-size, 1.5rem);
  font-weight: var(--cassiopeia-header-title-weight, 700);
  letter-spacing: -.01em;
  line-height: 1.1;
}

.container-header .navbar-brand .brand-tagline {
  font-size: var(--cassiopeia-header-tagline-size, 0.82rem);
  font-weight: 400;
  opacity: .82;
  letter-spacing: .01em;
}

/* Right column: social networks (top) + contacts (below, one per line) */
.header-modules-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
}

.header-modules-right .header-social {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.header-modules-right .header-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: inherit;
  font-size: .95rem;
  transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.header-modules-right .header-social a:hover {
  background: rgba(255, 255, 255, .28);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px -3px rgba(0, 0, 0, .35);
  text-decoration: none;
}

.header-modules-right .header-contacts {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .875rem;
  line-height: 1.35;
}

.header-modules-right .header-contacts li {
  margin: 0;
}

.header-modules-right .header-contacts li a,
.header-modules-right .header-contacts li span {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.header-modules-right .header-contacts li [class*="fa-"],
.header-modules-right .header-contacts li [class*="icon-"] {
  width: 2rem;
  flex: 0 0 auto;
  text-align: center;
}

/* Compact login form in the header (position `header-left`) */
.header-modules-left .mod-login {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .5rem;
}

.header-modules-left .mod-login__userdata {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .5rem;
}

.header-modules-left .mod-login__username,
.header-modules-left .mod-login__password,
.header-modules-left .mod-login__submit {
  margin: 0;
}

.header-modules-left .mod-login__username,
.header-modules-left .mod-login__password {
  width: 11rem;
}

.header-modules-left .mod-login .form-control {
  border-radius: .5rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
}

.header-modules-left .mod-login .form-control::placeholder {
  color: rgba(255, 255, 255, .75);
}

.header-modules-left .mod-login .input-group-text,
.header-modules-left .mod-login .input-password-toggle {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
}

.header-modules-left .mod-login__submit .btn {
  width: auto;
  padding: .5rem 1.1rem;
  border-radius: .5rem;
}

/* Hide the remember-me and password-reset links for a compact header */
.header-modules-left .mod-login__remember,
.header-modules-left .mod-login__options {
  display: none;
}

/* Header text animations */
@keyframes hdr-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes hdr-slide-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes hdr-zoom-in {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

.header-anim-fade .header-brand { animation: hdr-fade-in .8s ease both; }
.header-anim-slide .header-brand { animation: hdr-slide-up .8s ease both; }
.header-anim-zoom .header-brand { animation: hdr-zoom-in .8s ease both; }

@media (prefers-reduced-motion: reduce) {
  .header-anim-fade .header-brand,
  .header-anim-slide .header-brand,
  .header-anim-zoom .header-brand {
    animation: none;
  }
}

/* Mobile: stack the header columns */
@media (max-width: 767.98px) {
  .container-header-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
  }

  .header-brand,
  .header-modules-left,
  .header-modules-center,
  .header-modules-right {
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  /* Login form: stack the fields vertically and constrain the width,
     otherwise the 11rem inputs + button overflow the viewport (<470px). */
  .header-modules-left {
    width: 100%;
    max-width: 22rem;
  }

  .header-modules-left .mod-login {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .header-modules-left .mod-login__userdata {
    flex-direction: column;
    width: 100%;
  }

  .header-modules-left .mod-login__username,
  .header-modules-left .mod-login__password {
    width: 100%;
  }

  .header-modules-left .mod-login__submit .btn {
    width: 100%;
  }

  /* Brand: let logo + title wrap, slightly smaller logo */
  .container-header .navbar-brand {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: .35rem;
  }

  .container-header .navbar-brand .brand-text {
    min-width: 0;
    max-width: min(100%, 16rem);
  }
}

/* More compact tables for data-heavy pages */
table {
  font-size: .9375rem;
}

/* Forms */
.form-control,
.form-select {
  border-radius: .375rem;
}

/* Footer */
.container-footer .grid-child {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  font-size: .875rem;
}

/*
 * Configurable sidebar/content ratio (fluid / 100% width layout).
 * The four main grid columns are: [sidebar][content][content][sidebar].
 * `--cassiopeia-sidebar` is set from the template option (default 25%).
 */
body.wrapper-fluid .site-grid {
  grid-template-columns:
    [full-start] minmax(0, 1fr)
    [main-start] minmax(0, var(--cassiopeia-sidebar))
                 minmax(0, calc((100% - 2 * var(--cassiopeia-sidebar)) / 2))
                 minmax(0, calc((100% - 2 * var(--cassiopeia-sidebar)) / 2))
                 minmax(0, var(--cassiopeia-sidebar))
    [main-end] minmax(0, 1fr)
    [full-end];
}

/* Tablet/mobile: add breathing room on the content grid */
@media (max-width: 991.98px) {
  .site-grid {
    padding-inline: .75rem;
  }
}

/*
 * Horizontal navigation above breadcrumbs (position `main-nav`).
 * Rendered as a pill-style menu inside a soft card.
 */
.main-nav-wrap {
  margin-top: .25rem;
  margin-bottom: .25rem;
}

.main-nav-wrap .mod-menu {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .35rem;
  margin: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #e6e8ec;
  border-radius: .75rem;
  box-shadow: 0 1px 2px hsla(0, 0%, 0%, .05);
}

.main-nav-wrap .mod-menu > li {
  margin: 0;
}

.main-nav-wrap .mod-menu > li > a,
.main-nav-wrap .mod-menu > li > span {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.35rem;
  border-radius: .55rem;
  color: var(--body-color);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.main-nav-wrap .mod-menu > li > a:hover,
.main-nav-wrap .mod-menu > li > a:focus-visible {
  background-color: var(--cassiopeia-color-primary);
  color: #fff;
}

.main-nav-wrap .mod-menu > li.current > a,
.main-nav-wrap .mod-menu > li.active > a,
.main-nav-wrap .mod-menu > li > a.active,
.main-nav-wrap .mod-menu > li > a.current {
  background-color: var(--cassiopeia-color-primary);
  color: #fff;
}

/* Icons inside the horizontal menu (menu item "Link Icon Class") */
.main-nav-wrap .mod-menu > li > a .p-2 {
  padding: 0 !important;
}

.main-nav-wrap .mod-menu > li > a [class*="fa-"],
.main-nav-wrap .mod-menu > li > a [class*="icon-"] {
  font-size: 1em;
  line-height: 1;
  width: 1.25em;
  text-align: center;
}

/*
 * Submenus. The menu is rendered by metismenu, so the real markup uses
 * `mm-toggler` (chevron button) and `mm-collapse` (submenu list).
 * Desktop: click the chevron to open a styled dropdown.
 */
.main-nav-wrap .metismenu.mod-menu .metismenu-item {
  padding: 0;
}

.main-nav-wrap .metismenu.mod-menu .metismenu-item > .mm-toggler {
  padding: 0 .8rem;
  align-self: stretch;
}

.main-nav-wrap .metismenu.mod-menu .metismenu-item > ul.mm-collapse {
  top: calc(100% + .45rem);
  left: 0;
  z-index: 1030;
  min-width: 15rem;
  padding: .35rem;
  margin: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #e6e8ec;
  border-radius: .7rem;
  box-shadow: 0 14px 36px -14px rgba(0, 0, 0, .25);
}

.main-nav-wrap .metismenu.mod-menu .mm-collapse > li {
  padding: 0;
  margin: 0;
}

.main-nav-wrap .metismenu.mod-menu .mm-collapse > li > a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem .85rem;
  border-radius: .45rem;
  color: var(--body-color);
  font-size: .95rem;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.main-nav-wrap .metismenu.mod-menu .mm-collapse > li > a:hover,
.main-nav-wrap .metismenu.mod-menu .mm-collapse > li > a:focus-visible {
  background-color: var(--cassiopeia-color-primary);
  color: #fff;
}

/* Mobile: vertical list, submenus expand inline (real metismenu classes) */
@media (max-width: 767.98px) {
  .main-nav-wrap .metismenu.mod-menu .metismenu-item > a,
  .main-nav-wrap .metismenu.mod-menu .metismenu-item > span {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* Chevron: big tap target pinned to the right edge of the pill */
  .main-nav-wrap .metismenu.mod-menu .metismenu-item > .mm-toggler {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 3rem;
    padding: 0;
    justify-content: center;
    align-items: center;
  }

  .main-nav-wrap .metismenu.mod-menu .metismenu-item.parent > a {
    padding-right: 3.25rem;
  }

  .main-nav-wrap .metismenu.mod-menu .metismenu-item > ul.mm-collapse {
    position: static;
    top: auto;
    left: auto;
    min-width: 0;
    width: 100%;
    padding: .25rem 0 .25rem 1rem;
    margin: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .main-nav-wrap .metismenu.mod-menu .mm-collapse ul.mm-collapse {
    padding-inline-start: 1rem;
  }

  .main-nav-wrap .metismenu.mod-menu .mm-collapse > li > a {
    width: 100%;
  }
}

/* Mobile hamburger navigation */
.main-nav-toggle {
  display: none;
}

@media (max-width: 767.98px) {
  .main-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.1rem;
    margin: 0;
    border: 1px solid #e6e8ec;
    border-radius: .6rem;
    background: #fff;
    color: var(--body-color);
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px hsla(0, 0, 0, .05);
  }

  .main-nav-toggle:hover {
    border-color: var(--cassiopeia-color-primary);
  }

  .main-nav-toggle .hamburger {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    width: 22px;
  }

  .main-nav-toggle .hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
  }

  .main-nav-toggle[aria-expanded="true"] .hamburger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .main-nav-toggle[aria-expanded="true"] .hamburger span:nth-child(2) {
    opacity: 0;
  }

  .main-nav-toggle[aria-expanded="true"] .hamburger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .main-nav-collapse {
    display: none;
    margin-top: .5rem;
  }

  .main-nav-wrap.is-open .main-nav-collapse {
    display: block;
  }

  .main-nav-wrap .mod-menu {
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
  }

  .main-nav-wrap .mod-menu > li > a {
    justify-content: center;
    width: 100%;
  }
}

/* Error pages (404 etc.) — portal-styled card */
.tpl-error {
	display: flex;
	justify-content: center;
	padding: 3rem 1rem 4rem;
}

.tpl-error__card {
	max-width: 40rem;
	width: 100%;
	text-align: center;
	background: #fff;
	border: 1px solid #e6e8ec;
	border-radius: 1rem;
	box-shadow: 0 18px 45px rgba(15, 23, 42, .09);
	padding: 2.5rem 2rem;
}

.tpl-error__code {
	font-size: 4.5rem;
	font-weight: 800;
	line-height: 1;
	letter-spacing: .02em;
	color: var(--cassiopeia-color-primary, #1a56db);
}

.tpl-error__icon {
	font-size: 1.6rem;
	color: var(--cassiopeia-color-primary, #1a56db);
	margin: .6rem 0 .4rem;
}

.tpl-error__title {
	font-size: 1.6rem;
	font-weight: 700;
	margin: .5rem 0 .75rem;
	color: var(--cassiopeia-color-h1, #212529);
}

.tpl-error__text {
	color: #64748b;
	margin-bottom: 1.5rem;
}

.tpl-error__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: .75rem;
}

.tpl-error__meta {
	margin-top: 1.5rem;
	font-size: .85rem;
	color: #94a3b8;
	overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
	.tpl-error { padding: 1.5rem 1rem 3rem; }
	.tpl-error__card { padding: 2rem 1.25rem; }
	.tpl-error__code { font-size: 3.5rem; }
}

