/* ==========================================================================
   Web app-каркас: авторизованные страницы (Сообщения / Аккаунты / Лайки /
   Профиль / Редактирование). Подключается дополнительно к lp/style.css.
   Оборачивает мини-аппные UI-блоки в полноценный desktop-layout.
   ========================================================================== */

:root {
  --app-bg: #F8F8F8;
  --app-card: #ffffff;
  --app-border: #EFF1F5;
  --app-text: #222337;
  --app-text-muted: #6B6C79;
  --app-text-gray: #9299a5;
  --app-purple: #8B32FF;
  --app-purple-soft: #F5F3FF;
  --app-pink: #ff4990;
  --app-pink-soft: #fff1f5;
  --app-mamba: #0099ff;
  --app-loveplanet: #ff4990;
  --app-success: #22c55e;
  --app-danger: #ff4444;
}

body.app-body {
  background: var(--app-bg);
}

/* Шапка авторизованного юзера: аватар-меню справа */
.user-menu { position: relative; }
.user-menu__btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--app-border);
  border-radius: 999px; padding: 6px 14px 6px 6px;
  font-weight: 600; font-size: 14px; color: var(--app-text);
  cursor: pointer;
  font-family: inherit;
}
.user-menu__btn:hover { background: #FAFAFA; }
.user-menu__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #C5A8FF 0%, #8B32FF 100%);
  color: #fff; font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.user-menu__avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu__name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__caret { width: 10px; height: 6px; fill: #6B6C79; }

.user-menu__dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
  padding: 8px;
  z-index: 200;
  display: none;
}
.user-menu.is-open .user-menu__dropdown { display: block; }
.user-menu__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--app-text);
  cursor: pointer; background: none; border: 0; width: 100%;
  font-family: inherit; text-align: left;
}
.user-menu__item:hover { background: #F5F3FF; color: var(--app-purple); }
.user-menu__item--danger { color: var(--app-danger); }
.user-menu__item--danger:hover { background: #FEECEC; color: var(--app-danger); }
.user-menu__sep { height: 1px; background: var(--app-border); margin: 6px 4px; }

/* Container/каркас десктоп-страниц */
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* Sidebar */
.app-sidebar {
  position: sticky; top: 24px;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 20px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.app-sidebar__title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--app-text-gray);
  padding: 6px 12px 10px;
}
.app-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: var(--app-text);
  position: relative;
  transition: background .12s, color .12s;
}
.app-nav-item:hover { background: #F5F3FF; color: var(--app-purple); }
.app-nav-item.is-active { background: var(--app-purple); color: #fff; }
.app-nav-item.is-active:hover { background: var(--app-purple); color: #fff; }
.app-nav-item__icon { width: 22px; height: 22px; flex-shrink: 0; }
.app-nav-item__badge {
  margin-left: auto;
  background: var(--app-pink); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  padding: 2px 8px; min-width: 20px; text-align: center;
}

/* Main content area */
.app-main {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 20px;
  min-height: calc(100vh - 230px);
  overflow: hidden;
}
.app-main__header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--app-border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.app-main__header h1 {
  font-size: 24px; font-weight: 700; color: var(--app-text); margin: 0;
}
.app-main__header p { color: var(--app-text-muted); font-size: 14px; margin-top: 4px; }
.app-main__body { padding: 24px 28px; }

/* Filters: pills */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--app-bg); color: var(--app-text-gray);
  border-radius: 999px; padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  border: 0; cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
}
.pill:hover { background: #EBEDF1; color: var(--app-text); }
.pill.is-active { background: var(--app-purple); color: #fff; }

/* ==========================================================================
   Сообщения (двухколоночный inbox + чат)
   ========================================================================== */
.msg-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 200px);
  min-height: 600px;
}
.msg-list-pane {
  border-right: 1px solid var(--app-border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.msg-list-head {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--app-border);
  display: flex; flex-direction: column; gap: 12px;
}
.msg-list-head h2 { font-size: 18px; font-weight: 700; margin: 0; }
.msg-list { flex: 1; overflow-y: auto; }
.msg-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid #F4F5F7;
  transition: background .1s;
}
.msg-list-item:hover { background: #FAFAFA; }
.msg-list-item.is-active { background: #F5F3FF; }
.msg-list-item__avatar {
  position: relative; width: 52px; height: 52px; flex-shrink: 0;
}
.msg-list-item__avatar > div {
  width: 100%; height: 100%; border-radius: 14px; overflow: hidden;
  background: var(--app-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--app-text-gray); font-weight: 700; font-size: 18px;
}
.msg-list-item__avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-list-item__platform {
  position: absolute; bottom: -2px; right: -2px;
  background: #fff; border-radius: 6px; padding: 2px;
}
.platform-badge {
  width: 16px; height: 16px; border-radius: 5px; color: #fff;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.platform-badge--mamba { background: var(--app-mamba); }
.platform-badge--loveplanet { background: var(--app-loveplanet); }
.platform-badge--shtory { background: var(--app-purple); }
.msg-list-item__body { flex: 1; min-width: 0; }
.msg-list-item__row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 2px;
}
.msg-list-item__name {
  font-size: 14px; font-weight: 600; color: var(--app-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-list-item__time { font-size: 11px; color: var(--app-text-gray); flex-shrink: 0; }
.msg-list-item__preview {
  font-size: 13px; color: var(--app-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Правая панель — чат */
.msg-chat-pane {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.msg-chat-head {
  padding: 14px 24px;
  border-bottom: 1px solid var(--app-border);
  display: flex; align-items: center; gap: 12px;
}
.msg-chat-head__avatar {
  position: relative; width: 44px; height: 44px;
}
.msg-chat-head__avatar > div {
  width: 100%; height: 100%; border-radius: 12px; overflow: hidden;
  background: var(--app-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--app-text-gray); font-weight: 700;
}
.msg-chat-head__avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-chat-head__name { font-size: 16px; font-weight: 700; }
.msg-chat-head__sub { font-size: 12px; color: var(--app-text-muted); margin-top: 2px; }

.msg-stream {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
  background: #FAFAFB;
}
.msg-bubble {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.4;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-bubble--in { background: #fff; color: var(--app-text); align-self: flex-start; }
.msg-bubble--out { background: var(--app-purple); color: #fff; align-self: flex-end; }
.msg-bubble__time {
  font-size: 11px; opacity: .7;
  margin-top: 4px;
}

.msg-compose {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--app-border);
  background: #fff;
  display: flex; gap: 10px; align-items: flex-end;
}
.msg-compose textarea {
  flex: 1;
  background: var(--app-bg);
  border: 0; border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px; font-family: inherit;
  resize: none; outline: none;
  min-height: 44px; max-height: 140px;
}
.msg-compose textarea:focus { background: #F2F0FA; }
.msg-send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--app-purple); color: #fff;
  border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.msg-send-btn:disabled { opacity: .5; cursor: not-allowed; }

.msg-empty-state, .msg-empty-pane {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px;
  gap: 8px;
}
.msg-empty-state__icon, .msg-empty-pane__icon { font-size: 48px; }
.msg-empty-state h3, .msg-empty-pane h3 {
  font-size: 18px; font-weight: 700; color: var(--app-text);
}
.msg-empty-state p, .msg-empty-pane p {
  font-size: 14px; color: var(--app-text-muted); max-width: 360px;
}

/* ==========================================================================
   Аккаунты Mamba/LovePlanet (карточки)
   ========================================================================== */
.acc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.acc-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 18px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .12s, box-shadow .12s;
}
.acc-card:hover { border-color: #E1DAF5; box-shadow: 0 4px 16px rgba(139, 50, 255, 0.06); }
.acc-card__head {
  display: flex; align-items: center; gap: 12px;
}
.acc-card__logo {
  width: 48px; height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
}
.acc-card__logo--mamba { background: var(--app-mamba); }
.acc-card__logo--loveplanet { background: var(--app-loveplanet); }
.acc-card__title { font-size: 16px; font-weight: 700; }
.acc-card__status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
}
.acc-card__status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.acc-card__status--active { color: var(--app-success); }
.acc-card__status--active .acc-card__status-dot { background: var(--app-success); }
.acc-card__status--needs_reauth { color: var(--app-danger); }
.acc-card__status--needs_reauth .acc-card__status-dot { background: var(--app-danger); }
.acc-card__status--suspended { color: var(--app-text-gray); }
.acc-card__status--suspended .acc-card__status-dot { background: var(--app-text-gray); }
.acc-card__meta { font-size: 12px; color: var(--app-text-muted); }
.acc-card__actions { display: flex; gap: 8px; }
.acc-card__action {
  flex: 1;
  height: 38px; border-radius: 10px;
  font-size: 13px; font-weight: 600; border: 0; cursor: pointer;
  font-family: inherit;
}
.acc-card__action--reauth { background: var(--app-bg); color: var(--app-text); }
.acc-card__action--reauth:hover { background: #EBEDF1; }
.acc-card__action--disconnect { background: #FFECEC; color: var(--app-danger); }
.acc-card__action--disconnect:hover { background: #FFD9D9; }

.acc-add-card {
  background: #fff;
  border: 1px dashed #D7DBE3;
  border-radius: 18px;
  padding: 20px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .12s, background .12s;
  font-family: inherit;
}
.acc-add-card:hover { border-color: var(--app-purple); background: #FBFAFF; }
.acc-add-card__title { font-size: 16px; font-weight: 700; }
.acc-add-card__sub { font-size: 13px; color: var(--app-text-muted); }

.app-banner {
  background: #F5F3FF;
  border: 1px solid #E1DAF5;
  color: #4F2FA8;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ==========================================================================
   Лайки/события
   ========================================================================== */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.event-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 18px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.event-card__photo {
  aspect-ratio: 3 / 4;
  background: var(--app-bg);
  position: relative;
  overflow: hidden;
}
.event-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.event-card__placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; color: var(--app-text-gray); font-weight: 700;
}
.event-card__badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.event-card__platform-dot { width: 8px; height: 8px; border-radius: 50%; }
.event-card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.event-card__name { font-size: 15px; font-weight: 700; color: var(--app-text); }
.event-card__actions { display: flex; gap: 6px; margin-top: auto; }
.event-card__btn {
  flex: 1; height: 34px; border-radius: 10px;
  font-size: 12px; font-weight: 700; border: 0;
  cursor: pointer; font-family: inherit;
}
.event-card__btn--primary { background: var(--app-pink); color: #fff; }
.event-card__btn--primary:hover { filter: brightness(1.05); }
.event-card__btn--ghost { background: var(--app-bg); color: var(--app-text-muted); }
.event-card__btn--ghost:hover { background: #EBEDF1; }

/* ==========================================================================
   Профиль (просмотр) и Редактирование
   ========================================================================== */
.profile-grid {
  display: grid; gap: 24px;
  grid-template-columns: 360px 1fr;
}
@media (max-width: 960px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-photo-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 20px;
  overflow: hidden;
}
.profile-photo-card__main {
  aspect-ratio: 3/4; background: var(--app-bg);
  position: relative;
}
.profile-photo-card__main img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-card__placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: #C9CDD6; font-weight: 700;
}
.profile-photo-card__thumbs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; padding: 10px;
}
.profile-photo-card__thumb {
  aspect-ratio: 1; background: var(--app-bg); border-radius: 8px;
  overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
}
.profile-photo-card__thumb.is-active { border-color: var(--app-purple); }
.profile-photo-card__thumb img { width: 100%; height: 100%; object-fit: cover; }

.profile-info-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 20px;
  padding: 26px 28px;
}
.profile-info-card h2 { font-size: 26px; font-weight: 700; margin: 0; }
.profile-info-card .age { color: var(--app-text-muted); font-weight: 500; }
.profile-info-card .meta { color: var(--app-text-muted); font-size: 14px; margin-top: 6px; }
.profile-info-card .bio { font-size: 15px; line-height: 1.5; margin-top: 16px; white-space: pre-wrap; }
.profile-info-card .empty-bio { color: var(--app-text-gray); font-style: italic; }

.profile-section {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 18px;
  padding: 22px 26px;
  margin-top: 16px;
}
.profile-section h3 {
  font-size: 16px; font-weight: 700; margin: 0 0 14px; color: var(--app-text);
}
.profile-row {
  display: flex; gap: 16px; align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--app-border);
}
.profile-row:first-of-type { border-top: 0; }
.profile-row__label { color: var(--app-text-muted); font-size: 14px; min-width: 160px; }
.profile-row__value { font-size: 14px; font-weight: 600; flex: 1; }
.profile-row__action {
  background: none; border: 0; color: var(--app-purple);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center;
  padding: 7px 14px; border-radius: 999px;
  background: var(--app-purple-soft);
  color: var(--app-purple);
  font-size: 13px; font-weight: 600;
}

/* Form */
.form-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--app-text-muted); }
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  background: var(--app-bg); border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px; font-family: inherit; color: var(--app-text);
  outline: none;
  transition: background .12s, border-color .12s;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus { background: #fff; border-color: var(--app-purple); }
.form-field textarea { resize: vertical; min-height: 110px; }
.form-field--full { grid-column: 1 / -1; }
.form-hint { font-size: 12px; color: var(--app-text-gray); }

.form-actions {
  margin-top: 22px;
  display: flex; gap: 10px; justify-content: flex-end;
}

.btn-primary {
  background: var(--app-purple); color: #fff;
  border: 0; border-radius: 12px;
  padding: 12px 24px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: filter .12s, opacity .12s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--app-bg); color: var(--app-text);
  border: 0; border-radius: 12px;
  padding: 12px 24px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.btn-secondary:hover { background: #EBEDF1; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal-card {
  background: #fff; border-radius: 20px;
  width: 100%; max-width: 460px;
  padding: 28px;
}
.modal-card h2 { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.modal-card p { font-size: 14px; color: var(--app-text-muted); margin: 0 0 18px; }
.modal-card .form-field input { background: var(--app-bg); }
.modal-card .form-actions { margin-top: 18px; }

.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: #222337; color: #fff;
  padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  z-index: 400;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; }
.toast--err { background: var(--app-danger); }

/* ==========================================================================
   Loading
   ========================================================================== */
.skeleton {
  background: linear-gradient(90deg, #EFF1F5 25%, #F8F8F8 50%, #EFF1F5 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Адаптив
   ========================================================================== */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .app-sidebar { position: static; flex-direction: row; overflow-x: auto; padding: 12px; }
  .app-sidebar__title { display: none; }
  .app-nav-item { white-space: nowrap; }
  .msg-layout { grid-template-columns: 1fr; height: auto; }
  .msg-list-pane { border-right: 0; border-bottom: 1px solid var(--app-border); max-height: 50vh; }
  .msg-chat-pane { min-height: 60vh; }
}
@media (max-width: 600px) {
  .app-main__header, .app-main__body { padding: 16px; }
  .acc-grid { grid-template-columns: 1fr; }
  .user-menu__name { display: none; }
}
