/* ==========================================================
   PATHREST GLOBAL ACCOUNT DROPDOWN MENU — STEP 55
   Общий код для всех страниц Tilda / Zero Block:
   публичные страницы, /account, /partner, /admin.
   + Avatar inside round .account trigger when logged in
   + Unread dialogs badge synced with the global .account badge
   ========================================================== */

html.pathrest-account-menu-open {
  overflow: hidden;
}

.pathrest-account-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999998;
  background: rgba(20, 16, 13, 0.28);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  pointer-events: none;
}

.pathrest-account-menu-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pathrest-account-menu {
  position: fixed;
  z-index: 9999999;
  width: min(328px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid rgba(42, 101, 131, 0.16);
  border-radius: 28px;
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 139, 33, 0.16), transparent 34%),
    radial-gradient(circle at 100% 0%, rgba(42, 101, 131, 0.12), transparent 34%),
    rgba(245, 253, 255, 0.97);
  box-shadow:
    0 22px 60px rgba(42, 101, 131, 0.20),
    0 8px 22px rgba(20, 16, 13, 0.08);
  color: #2a6583;
  font-family: "Arian AMU Serif", "Times New Roman", serif;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease;
  box-sizing: border-box;
  overflow: hidden;
}

.pathrest-account-menu--admin {
  width: min(348px, calc(100vw - 24px));
}

.pathrest-account-menu *,
.pathrest-account-menu *::before,
.pathrest-account-menu *::after {
  box-sizing: border-box;
}

.pathrest-account-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.pathrest-account-menu__sheet-handle {
  display: none;
}

/* ==========================================================
   Round account trigger avatar
   Работает только если пользователь вошёл и найдено фото.
   Если входа нет — исходная SVG-иконка Tilda остаётся без изменений.
   ========================================================== */

.account[data-pathrest-account-trigger-avatar="1"] {
  overflow: visible !important;
}

.account[data-pathrest-account-trigger-avatar="1"] .tn-atom,
.account .tn-atom[data-pathrest-account-trigger-avatar="1"] {
  position: relative !important;
  box-sizing: border-box !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  border: 1px solid rgba(245, 253, 255, 0.96) !important;
  box-shadow:
    0 0 0 1px rgba(42, 101, 131, 0.18),
    0 6px 16px rgba(42, 101, 131, 0.16) !important;
}

.account[data-pathrest-account-trigger-avatar="1"] .tn-atom::after,
.account .tn-atom[data-pathrest-account-trigger-avatar="1"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.pathrest-account-menu__profile {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 12px 11px;
  border: 1px solid rgba(42, 101, 131, 0.11);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.48)),
    rgba(255, 255, 255, 0.58);
}

.pathrest-account-menu__avatar {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.88), transparent 36%),
    linear-gradient(135deg, #ff8b21, #f7b267);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(255, 139, 33, 0.20);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.pathrest-account-menu--admin .pathrest-account-menu__avatar {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.88), transparent 36%),
    linear-gradient(135deg, #2a6583, #6ca7bd);
  box-shadow: 0 13px 26px rgba(42, 101, 131, 0.18);
}

.pathrest-account-menu__user {
  min-width: 0;
}

.pathrest-account-menu__name {
  margin: 0;
  color: #2a6583;
  font-size: 15.5px;
  line-height: 1.18;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pathrest-account-menu__email {
  margin-top: 4px;
  color: rgba(42, 101, 131, 0.58);
  font-size: 11.8px;
  line-height: 1.2;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pathrest-account-menu__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.pathrest-account-menu__chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(42, 101, 131, 0.08);
  color: rgba(42, 101, 131, 0.78);
  font-size: 11.5px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

.pathrest-account-menu__chip--role {
  background: rgba(255, 139, 33, 0.13);
  color: #c86408;
}

.pathrest-account-menu__notice {
  display: none;
  margin: 8px 2px 0;
  padding: 10px 11px;
  border: 1px solid rgba(255, 139, 33, 0.24);
  border-radius: 18px;
  background: rgba(255, 248, 241, 0.90);
  color: rgba(42, 101, 131, 0.82);
  font-size: 12.4px;
  line-height: 1.35;
  font-weight: 500;
}

.pathrest-account-menu__notice.is-visible {
  display: block;
}

.pathrest-account-menu__inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 10px 2px 2px;
}

.pathrest-account-menu__item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: #2a6583 !important;
  background: transparent;
  font-family: "Arian AMU Serif", "Times New Roman", serif;
  text-decoration: none !important;
  cursor: pointer;
  text-align: left;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}

.pathrest-account-menu__item:hover {
  border-color: rgba(255, 139, 33, 0.20);
  background: rgba(255, 248, 241, 0.88);
  color: #ff8b21 !important;
  transform: translateX(2px);
}

.pathrest-account-menu__item.is-active {
  border-color: rgba(255, 139, 33, 0.30);
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 139, 33, 0.16), transparent 32%),
    rgba(255, 255, 255, 0.74);
}

.pathrest-account-menu__item.is-locked {
  opacity: 0.54;
  cursor: not-allowed;
}

.pathrest-account-menu__item.is-locked:hover {
  transform: none;
  border-color: transparent;
  background: transparent;
  color: #2a6583 !important;
}

.pathrest-account-menu__icon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  background: rgba(42, 101, 131, 0.08);
  color: #2a6583;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  font-weight: 600;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.pathrest-account-menu__item:hover .pathrest-account-menu__icon,
.pathrest-account-menu__item.is-active .pathrest-account-menu__icon {
  background: #ff8b21;
  color: #ffffff;
}

.pathrest-account-menu__text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.pathrest-account-menu__label {
  color: inherit;
  font-size: 14.5px;
  line-height: 1.16;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pathrest-account-menu__hint {
  color: rgba(42, 101, 131, 0.58);
  font-size: 11.8px;
  line-height: 1.18;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pathrest-account-menu__arrow {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(42, 101, 131, 0.48);
  font-size: 16px;
  line-height: 1;
}

.pathrest-account-menu__item:hover .pathrest-account-menu__arrow {
  color: #ff8b21;
}

/* ==========================================================
   Unread dialogs badge inside dropdown menu
   Синхронизируется с PATHREST ACCOUNT UNREAD BADGE — V1.
   ========================================================== */

.pathrest-account-menu__item-end {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 22px;
}

.pathrest-account-menu__unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: #ff8b21;
  color: #ffffff;
  box-shadow:
    0 5px 14px rgba(255, 139, 33, 0.28),
    0 1px 3px rgba(42, 101, 131, 0.14);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.2px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.pathrest-account-menu__unread[hidden] {
  display: none !important;
}

.pathrest-account-menu__unread.is-pulse {
  animation: pathrest-account-menu-unread-pulse 0.48s ease;
}

.pathrest-account-menu__item.has-unread .pathrest-account-menu__icon {
  background: rgba(255, 139, 33, 0.13);
  color: #ff8b21;
  box-shadow: inset 0 0 0 1px rgba(255, 139, 33, 0.16);
}

.pathrest-account-menu__item.has-unread:hover .pathrest-account-menu__icon,
.pathrest-account-menu__item.has-unread.is-active .pathrest-account-menu__icon {
  background: #ff8b21;
  color: #ffffff;
  box-shadow: none;
}

@keyframes pathrest-account-menu-unread-pulse {
  0% {
    transform: scale(1);
  }

  42% {
    transform: scale(1.22);
  }

  100% {
    transform: scale(1);
  }
}

.pathrest-account-menu__divider {
  height: 1px;
  margin: 7px 10px;
  background: rgba(42, 101, 131, 0.12);
}

.pathrest-account-menu__item--logout {
  grid-template-columns: 34px minmax(0, 1fr);
  color: #c03a2b !important;
}

.pathrest-account-menu__item--logout .pathrest-account-menu__icon {
  background: rgba(192, 58, 43, 0.08);
  color: #c03a2b;
}

.pathrest-account-menu__item--logout:hover {
  border-color: rgba(192, 58, 43, 0.18);
  background: #fff4f2;
  color: #c03a2b !important;
}

.pathrest-account-menu__item--logout:hover .pathrest-account-menu__icon {
  background: #c03a2b;
  color: #ffffff;
}

@media (max-width: 640px) {
  .pathrest-account-menu-backdrop {
    background: rgba(20, 16, 13, 0.46);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  .pathrest-account-menu,
  .pathrest-account-menu--admin {
    top: max(10px, env(safe-area-inset-top)) !important;
    left: 10px !important;
    right: 10px !important;
    bottom: auto !important;
    width: auto;
    max-height: min(calc(100vh - 22px), 720px);
    padding: 10px;
    border-radius: 30px;
    transform: translateY(-112%);
    transform-origin: top center;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .pathrest-account-menu.is-open {
    transform: translateY(0);
  }

  .pathrest-account-menu__sheet-handle {
    display: block;
    width: 42px;
    height: 5px;
    margin: 2px auto 10px;
    border-radius: 999px;
    background: rgba(42, 101, 131, 0.20);
  }

  .pathrest-account-menu__profile {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 12px;
    border-radius: 23px;
  }

  .pathrest-account-menu__avatar {
    width: 46px;
    height: 46px;
    border-radius: 17px;
    font-size: 16px;
  }

  .pathrest-account-menu__name {
    font-size: 15px;
  }

  .pathrest-account-menu__email {
    font-size: 11px;
  }

  .pathrest-account-menu__chip {
    min-height: 23px;
    font-size: 11px;
  }

  .pathrest-account-menu__inner {
    gap: 6px;
    padding-top: 10px;
  }

  .pathrest-account-menu__item {
    min-height: 54px;
    grid-template-columns: 38px minmax(0, 1fr) 22px;
    padding: 9px 11px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.52);
  }

  .pathrest-account-menu__item--logout {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .pathrest-account-menu__icon {
    width: 38px;
    height: 38px;
    border-radius: 15px;
    font-size: 15px;
  }

  .pathrest-account-menu__item-end {
    gap: 6px;
  }

  .pathrest-account-menu__unread {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 10.5px;
  }

  .pathrest-account-menu__label {
    font-size: 14.5px;
  }

  .pathrest-account-menu__hint {
    font-size: 11.6px;
  }
}

@media (max-width: 380px) {
  .pathrest-account-menu,
  .pathrest-account-menu--admin {
    left: 8px !important;
    right: 8px !important;
    padding: 9px;
    border-radius: 27px;
  }

  .pathrest-account-menu__item {
    min-height: 52px;
    gap: 9px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .pathrest-account-menu__hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pathrest-account-menu__unread.is-pulse {
    animation: none;
  }
}
