/* Account module — авторизация, регистрация, профиль */
/* Шрифт Montserrat: подключайте /assets/fonts/montserrat-local.css в HTML до этого файла (локальные woff2, без FOUC от @import) */

:root {
  --account-bg: #0f1218;
  --account-bg-elevated: #161b24;
  --account-surface: #1c222e;
  --account-border: rgba(255, 255, 255, 0.08);
  --account-text: #e8eaef;
  --account-muted: #8b93a7;
  --account-accent: #3d8bfd;
  --account-accent-hover: #5b9fff;
  --account-success: #3ecf8e;
  --account-radius: 16px;
  --account-radius-sm: 10px;
  --account-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --account-input-bg: rgba(255, 255, 255, 0.05);
  --account-focus: rgba(61, 139, 253, 0.45);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  color: var(--account-text);
  font-family: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--account-bg);
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(61, 139, 253, 0.12), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(62, 207, 142, 0.06), transparent 45%);
}

/* Базовые утилиты */
.d-none {
  display: none !important;
}

.d-flex {
  display: flex !important;
}

.content-between {
  display: flex;
  justify-content: space-between;
}

.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.5rem !important; }
.ml-2 { margin-left: 1rem !important; }
.ml-3 { margin-left: 1.5rem !important; }
.mr-1 { margin-right: 0.5rem !important; }
.mr-2 { margin-right: 1rem !important; }
.mr-3 { margin-right: 1.5rem !important; }

.text-center {
  text-align: center;
}

.text-link {
  color: var(--account-accent);
  cursor: pointer;
}

.text-link:hover {
  text-decoration: underline !important;
}

a:link,
a:visited {
  color: var(--account-accent);
}

a:hover {
  color: var(--account-accent-hover);
  text-decoration: underline !important;
}

hr {
  border: none;
  height: 1px;
  background: var(--account-border);
  margin: 1.75rem 0;
  width: 100%;
}

h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--account-text);
}

nav {
  display: none;
}

form {
  margin: 0;
}

select.form-control {
  display: flex;
  height: 40px;
  border: 1px solid var(--account-border);
  border-radius: var(--account-radius-sm);
  background-color: var(--account-input-bg);
  color: var(--account-text);
  box-sizing: border-box;
}

/* Контейнер страницы */
.account__container,
.account-page {
  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 1.75rem);
  min-height: 0;
}

.account-page--wide {
  max-width: min(100%, 560px);
}

/* Карточка */
.account-card {
  background: var(--account-surface);
  border: 1px solid var(--account-border);
  border-radius: var(--account-radius);
  box-shadow: var(--account-shadow);
  padding: clamp(1.5rem, 5vw, 2rem);
  text-align: center;
}

.account-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  color: var(--account-text);
}

.account-card__lead {
  font-size: 0.875rem;
  color: var(--account-muted);
  margin: 0 0 1.5rem;
  line-height: 1.45;
}

.account-panel + .account-panel {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--account-border);
}

.profile-hero {
  margin-bottom: 1rem;
}

.account-card--profile .account-card__title {
  margin-bottom: 1rem;
}

.account-profile-links {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
  text-align: center;
}

.account-profile-links a {
  font-size: 0.9375rem;
}

.account__group {
  text-align: center;
}

/* Формы */
.account__form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  max-width: none;
  width: 100%;
  margin: 0 auto;
}

.account__form--centered {
  text-align: center;
  align-items: center;
}

.account__form .input {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 1rem;
  width: 100%;
}

.account__form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--account-muted);
  text-align: left;
}

.account__form .account__checkbox-row label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  color: var(--account-text);
  margin-bottom: 0;
}

.account__logo,
.klerk__logo {
  height: auto;
  max-height: 100px;
  width: auto;
  margin: 0 auto 1rem;
}

.account__form input[type="email"],
.account__form input[type="text"],
.account__form input[type="password"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 1rem;
  font-size: 0.9375rem;
  color: var(--account-text);
  background: var(--account-input-bg);
  border: 1px solid var(--account-border);
  border-radius: var(--account-radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.account__form input::placeholder {
  color: var(--account-muted);
  opacity: 0.8;
}

.account__form input[type="email"]:focus,
.account__form input[type="text"]:focus,
.account__form input[type="password"]:focus {
  border-color: var(--account-accent);
  box-shadow: 0 0 0 3px var(--account-focus);
  background: rgba(255, 255, 255, 0.07);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--account-accent);
  flex-shrink: 0;
}

.account__form input[type="submit"],
.account-btn {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 1.25rem;
  margin-top: 0.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, var(--account-accent) 0%, #2563c4 100%);
  border: none;
  border-radius: var(--account-radius-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 2px 8px rgba(61, 139, 253, 0.35);
}

.account__form input[type="submit"]:hover,
.account-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(61, 139, 253, 0.4);
}

.account__form input[type="submit"]:active,
.account-btn:active {
  transform: translateY(0);
}

.account__form input[type="submit"].account-btn--ghost,
.account__form .account-btn--ghost {
  background: transparent;
  color: var(--account-muted);
  box-shadow: none;
  border: 1px solid var(--account-border);
}

.account__form input[type="submit"].account-btn--ghost:hover,
.account__form .account-btn--ghost:hover {
  color: var(--account-text);
  border-color: var(--account-muted);
  filter: none;
}

.account-actions input[type="submit"].account-btn--ghost {
  margin-top: 0;
}

/* Регистрация — индикация отправки письма */
.account-submit-wrap {
  width: 100%;
  margin-top: 0.25rem;
}

.account-submit-wrap.is-loading input[type="submit"] {
  cursor: wait;
  filter: saturate(0.85) brightness(0.93);
}

.account-submit__status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
  color: var(--account-muted);
  text-align: center;
}

.account-submit-wrap.is-loading .account-submit__status {
  display: flex;
}

.account-spinner {
  flex-shrink: 0;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--account-accent);
  border-radius: 50%;
  animation: account-spin 0.75s linear infinite;
}

@keyframes account-spin {
  to {
    transform: rotate(360deg);
  }
}

.account-feedback {
  margin-top: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--account-radius-sm);
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
}

.account-feedback--hidden {
  display: none;
}

.account-feedback--warning {
  background: rgba(235, 141, 0, 0.14);
  border: 1px solid rgba(235, 141, 0, 0.32);
  color: #f0c78a;
}

.account-feedback--error {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: #ffb3bf;
}

.account__form a {
  text-align: center;
  font-size: 0.875rem;
  color: var(--account-accent);
  text-decoration: none;
  margin-top: 0.75rem;
  transition: color 0.2s;
}

.account__form a:hover {
  color: var(--account-accent-hover);
  text-decoration: underline !important;
}

.account-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  margin-top: 0.5rem;
}

.account-actions--row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1rem;
}

/* Сохранённые аккаунты */
.account-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
}

.chip {
  position: relative;
  padding: 0.5rem 2rem 0.5rem 1.2rem;
  background: var(--account-bg-elevated);
  border: 1px solid var(--account-border);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--account-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, border-color 0.2s;
  max-width: 100%;
}

.chip:hover {
  border-color: rgba(61, 139, 253, 0.45);
  background: rgba(61, 139, 253, 0.08);
}

.chip .email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.chip .remove {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--account-muted);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  opacity: 0.85;
}

.chip .remove:hover {
  color: var(--account-text);
  background: rgba(255, 255, 255, 0.08);
}

.btn-add-account {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--account-accent);
  background: transparent;
  border: 1px dashed var(--account-border);
  border-radius: var(--account-radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn-add-account:hover {
  border-color: var(--account-accent);
  background: rgba(61, 139, 253, 0.08);
  text-decoration: none !important;
}

.btn-cancel {
  color: var(--account-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem;
  border-radius: var(--account-radius-sm);
  transition: color 0.2s, background 0.2s;
}

.btn-cancel:hover {
  color: var(--account-text);
  background: rgba(255, 255, 255, 0.06);
}

/* Профиль */
.account-profile-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  margin-bottom: 1rem;
  padding: 0.35rem 0.5rem 0.35rem 0;
  font-size: 0.875rem;
  color: var(--account-muted);
  text-decoration: none !important;
  border-radius: var(--account-radius-sm);
  transition: color 0.2s;
}

.account-profile-back:hover {
  color: var(--account-text);
}

.account-profile-back .icon-arrow-left {
  margin-right: 0;
}

.profile-avatar-wrap {
  margin: 0 auto 1.25rem;
}

.profile-avatar-wrap .img-fluid {
  display: block;
  border-radius: 50%;
  border: 3px solid var(--account-border);
  object-fit: cover;
  box-shadow: var(--account-shadow);
}

.btn-uploader {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 1rem;
  margin: 0 auto 1.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--account-text);
  background: var(--account-input-bg);
  border: 1px solid var(--account-border);
  border-radius: var(--account-radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn-uploader:hover {
  border-color: var(--account-accent);
  background: rgba(61, 139, 253, 0.1);
}

ul.userinfo {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0 0 1.5rem;
  list-style: none;
  text-align: left;
  border: 1px solid var(--account-border);
  border-radius: var(--account-radius-sm);
  overflow: hidden;
}

ul.userinfo > li {
  display: flex;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--account-border);
  gap: 0.75rem;
}

ul.userinfo > li:last-child {
  border-bottom: none;
}

ul.userinfo > li > span:first-child {
  flex: 0 0 42%;
  color: var(--account-muted);
  font-size: 0.8125rem;
}

ul.userinfo > li > span:last-child {
  flex: 1;
  font-size: 0.875rem;
  word-break: break-word;
}

ul.userlist {
  display: flex;
  flex-direction: column;
  padding-left: 0;
}

ul.userlist > li {
  display: flex;
  border-bottom: 1px solid var(--account-border);
  padding: 0.5rem 0;
  width: 100%;
}

ul.userlist > li > span {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0.35rem;
  width: 70%;
}

ul.userlist > li > span:first-child {
  width: 30%;
}

ul.userlist > li.role-disabled {
  background-color: rgba(255, 255, 255, 0.04);
  opacity: 0.75;
}

.role-administrator {
  display: inline-flex;
  background-color: #dc3545;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  color: #fff;
  font-size: 0.75rem;
}

.role-moderator {
  display: inline-flex;
  background-color: #e67e00;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  color: #fff;
  font-size: 0.75rem;
}

.role-user {
  display: inline-flex;
  background-color: rgba(255, 255, 255, 0.1);
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  color: var(--account-text);
  font-size: 0.75rem;
}

ul.userlist > li > span > a {
  text-decoration: underline;
  font-weight: 600;
}

ul.userlist > li > span > a:hover {
  text-decoration: none;
}

.img-fluid {
  max-width: 100%;
  height: auto;
}

.icon-arrow-left {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  margin-right: 0.5rem;
  content: url("../images/icon-arrow-left.svg");
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.icon-arrow-left:hover {
  opacity: 1;
}

.unselectable {
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 480px) {
  .account-card {
    padding: 1.25rem 1rem;
    border-radius: 12px;
  }

  .account-card__title {
    font-size: 1.35rem;
  }

  .chip .email {
    max-width: 180px;
  }
}
