/* ============================================================
   SocialNet 1.3.38 — исправления раскладки (по скриншотам).
   Подключается самым последним (functions.php, приоритет 100).
   ============================================================ */

/* ---------- 1. Шапка уезжала под чёрную панель WordPress ----------
   У администраторов сверху есть панель WP (32px на компьютере, 46px на
   планшете). Шапка «прилипала» к top:0 и при прокрутке пряталась под ней. */
body.admin-bar .site-header { top: 32px; }
body.admin-bar .profile-back-floating { top: 122px; }

/* Окна (подарки, выбор файлов, модалки, просмотр фото) — ниже панели WP,
   чтобы верх окна с заголовком и «✕» не закрывался */
body.admin-bar .gf-ov,
body.admin-bar .snct-ov,
body.admin-bar .sn-modal-overlay,
body.admin-bar .lightbox { top: 32px; }
body.admin-bar .gf-modal   { max-height: calc(100vh - 64px); }
body.admin-bar .snct-modal { max-height: min(640px, calc(100vh - 64px)); }

@media screen and (max-width: 782px) {
    body.admin-bar .site-header { top: 46px; }
    body.admin-bar .profile-back-floating { top: 116px; }
    body.admin-bar .gf-ov,
    body.admin-bar .snct-ov,
    body.admin-bar .sn-modal-overlay,
    body.admin-bar .lightbox { top: 46px; }
    body.admin-bar .gf-modal   { max-height: calc(100vh - 78px); }
    body.admin-bar .snct-modal { max-height: min(640px, calc(100vh - 78px)); }
}
/* На телефонах панель WP не закреплена и уезжает при прокрутке */
@media screen and (max-width: 600px) {
    body.admin-bar .site-header { top: 0; }
    body.admin-bar .gf-ov,
    body.admin-bar .snct-ov,
    body.admin-bar .sn-modal-overlay,
    body.admin-bar .lightbox { top: 0; }
    body.admin-bar .gf-modal { max-height: 92vh; }
}

/* ---------- 2. Окно подарков: «сплющенные» вкладки ----------
   Окно — колонка с ограниченной высотой; полоса вкладок (overflow-x:auto)
   сжималась по высоте, и надписи «вываливались» из рамок кнопок. */
.gf-head, .gf-tabs, .gf-form, .gf-foot { flex-shrink: 0; }
.gf-tab { line-height: 1.3; }

/* ---------- 3. Профиль: блоки справа в одном стиле ---------- */
/* «Информация»: список рисовался отдельной стеклянной рамкой без отступов,
   текст прилипал к краям. Убираем вложенную рамку. */
html body .widget .profile-meta,
html.theme-dark body .widget .profile-meta {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 0;
}
.widget .profile-meta li { padding: 8px 0; line-height: 1.45; }

/* Заголовки блоков: без большого пустого места сверху и с той же
   фиолетовой полоской, что у «Друзей» и «Записей» */
.profile-sidebar .widget > .widget-title {
    position: relative;
    margin: 0 0 12px;
    padding-left: 12px;
}
.profile-sidebar .widget > .widget-title::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(180deg, #6366f1 0%, #9333ea 100%);
}

/* «Гости»: «+N» сразу после заголовка, стрелка — справа */
.gs-widget.widget-clickable-friends .widget-friends-link .widget-title { justify-content: flex-start; gap: 8px; }
.gs-widget.widget-clickable-friends .widget-arrow { margin-left: auto; }
.gs-widget.widget-clickable-friends .gs-widget-note { margin-top: 2px; }

/* «Подарки»: плитки слева, без лишнего отступа снизу у ссылки */
.gifts-widget .gifts-mini { justify-items: start; }

/* ---------- 1.3.43: «Подарки» и «Гости» — заголовок ровно как у «Друзей» ----------
   Работает и без класса widget-clickable-friends в разметке (если на сервере
   остался старый inc/gifts.php или inc/guests.php). */
.profile-sidebar .gifts-widget .widget-friends-link,
.profile-sidebar .gs-widget .widget-friends-link {
    display: block; text-decoration: none; color: inherit;
    margin: -16px -16px 12px; padding: 16px 16px 0;
    border-radius: 16px 16px 0 0;
}
.profile-sidebar .gifts-widget .widget-friends-link .widget-title,
.profile-sidebar .gs-widget .widget-friends-link .widget-title {
    position: relative; display: flex; align-items: center; gap: 8px;
    margin: 0 0 12px; padding-left: 12px; text-decoration: none;
    color: var(--text);
}
.profile-sidebar .gifts-widget .widget-friends-link .widget-title::before,
.profile-sidebar .gs-widget .widget-friends-link .widget-title::before {
    content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
    width: 3px; border-radius: 2px;
    background: linear-gradient(180deg, #6366f1 0%, #9333ea 100%);
}
.profile-sidebar .gifts-widget .widget-arrow,
.profile-sidebar .gs-widget .widget-arrow { margin-left: auto; }
.profile-sidebar .gifts-widget .widget-friends-link:hover .widget-title,
.profile-sidebar .gs-widget .widget-friends-link:hover .widget-title { color: var(--primary); }
html.theme-dark .profile-sidebar .gifts-widget .widget-friends-link:hover .widget-title,
html.theme-dark .profile-sidebar .gs-widget .widget-friends-link:hover .widget-title { color: #a5b4fc; }

/* плитки подарков — от левого края, как аватарки друзей и гостей */
.profile-sidebar .gifts-widget .gifts-mini {
    display: flex; flex-wrap: wrap; gap: 8px; justify-items: initial;
}

/* ---------- 1.3.47: без подчёркиваний в записях ----------
   «1 секунда назад» (ссылка на запись) была синей и подчёркнутой,
   число лайков — с пунктирным подчёркиванием. */
.post-meta .post-permalink,
.post-meta .post-permalink:visited {
    color: inherit;
    text-decoration: none;
}
.post-meta .post-permalink:hover { color: var(--primary); text-decoration: none; }
html.theme-dark .post-meta .post-permalink:hover { color: #a5b4fc; }

.js-show-likers,
.js-show-likers:hover { text-decoration: none !important; }

/* ---------- 1.3.48: значки 🔖 📌 🚀 были меньше остальных ----------
   WordPress в Windows заменяет эмодзи картинками <img class="emoji">.
   Общее правило img { max-width: 100% } позволяло этим картинкам сжиматься,
   когда кнопкам под записью не хватало места: у кнопок без подписи значок
   ужимался почти в точку, а у остальных подпись уезжала под значок. */
img.emoji, img.wp-smiley { max-width: none !important; }
.post-actions { flex-wrap: wrap; row-gap: 4px; }
.post-actions > button,
.post-actions > a { flex: 0 0 auto; white-space: nowrap; }

/* ---------- 1.3.52: мобильная версия ---------- */
/* Кнопка ➤ уезжала на вторую строку: поле ввода занимало ширину «по умолчанию»
   (~20 символов) ещё до сжатия, и строка переполнялась. Теперь поле берёт
   только оставшееся место. Плашка выбранного файла по-прежнему — отдельной строкой. */
.chat-form textarea { flex: 1 1 0% !important; min-width: 0 !important; }
.chat-form > button[type="submit"] { flex-shrink: 0; }

/* Друзья: «✉ Написать» (ссылка) и «Удалить» (кнопка) — одинаково по центру */
.friend-actions .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    line-height: 1.2; text-align: center; box-sizing: border-box;
}
/* подсказка в поле ввода — в одну строку, без переноса */
.chat-form textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 1.3.53: плашка даты в чате больше не наезжает на сообщения ----------
   Разделитель дня («26 октября», «Вчера») был «прилипающим» (position: sticky) и
   полупрозрачным: при прокрутке он висел поверх текста сообщений, а старые плашки
   оставались под новыми. Это было и на телефоне, и на компьютере, в личных и
   групповых чатах. Теперь плашка стоит на своём месте между сообщениями. */
.chat-body .chat-day-sep {
    position: static !important;
    top: auto !important;
    z-index: auto;
    margin: 16px 0 10px;
}
.chat-body .chat-day-sep span {
    background: var(--card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
html.theme-dark .chat-body .chat-day-sep span { background: #1e293b; border-color: rgba(148, 163, 184, .2); }

/* ---------- 1.3.67: режим модератора ---------- */
.sn-mod-bar {
    position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
    z-index: 100040; max-width: calc(100vw - 24px); padding: 9px 16px; border-radius: 999px;
    background: #b45309; color: #fff; font-size: 13px; line-height: 1.35; text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.sn-mod-bar a { color: #fff; font-weight: 700; text-decoration: underline; margin-left: 4px; }
@media (max-width: 768px) { .sn-mod-bar { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); border-radius: 14px; } }
.header-more-menu .sn-mod-item.is-on { color: #b45309; font-weight: 700; }
.sn-locked .sn-mod-btn { margin-top: 10px; }
.sn-mod-bar .sn-mod-left { font-variant-numeric: tabular-nums; }
.sn-mod-bar.is-ending { background: #dc2626; animation: sn-mod-pulse 1s ease-in-out infinite; }
@keyframes sn-mod-pulse { 50% { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .sn-mod-bar.is-ending { animation: none; } }

/* ---------- 1.3.73: кнопки в профиле — компактно ----------
   На компьютере — как раньше (значок + подпись в строку).
   На телефоне: статус дружбы — одна строка, остальные действия — плиткой 4 в ряд
   (значок сверху, подпись снизу) вместо столбика кнопок во всю ширину. */
.pa-tile .pa-ico { margin-right: 6px; }
.pa-tile .pa-txt { white-space: nowrap; }
.profile-more .pa-tile .pa-txt { display: none; }
.profile-more .pa-tile .pa-ico { margin: 0; }

@media (max-width: 768px) {
    html body .profile-actions {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }
    /* главные кнопки (дружба, войти, редактировать) — на всю ширину */
    html body .profile-actions > .btn:not(.pa-tile):not(.pa-side):not(.pa-status) { grid-column: 1 / -1; flex-basis: auto; width: 100%; }
    html body .profile-actions > .pa-status { grid-column: span 3; display: flex; align-items: center; justify-content: center; }
    html body .profile-actions > .pa-side { grid-column: span 1; padding-left: 4px; padding-right: 4px; font-size: 13px; min-width: 0; display: flex; align-items: center; justify-content: center; }
    /* «Принять» / «Отклонить» — пополам */
    html body .profile-actions > .js-friend-accept, html body .profile-actions > .js-friend-reject { grid-column: span 2; }

    html body .profile-actions .pa-tile,
    html body .profile-actions .profile-more {
        flex-basis: auto; width: 100%; min-width: 0;
    }
    html body .profile-actions .pa-tile {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        min-height: 64px; padding: 8px 2px; border-radius: 16px; text-align: center; line-height: 1.1;
    }
    html body .profile-actions .pa-tile .pa-ico { margin: 0; font-size: 22px; line-height: 1; }
    html body .profile-actions .pa-tile .pa-txt { display: block; font-size: 11.5px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; hyphens: auto; }
    html body .profile-actions .profile-more { display: block; }
    html body .profile-actions .profile-more .pa-tile { height: 100%; }
    html body .profile-actions .profile-more .pa-txt { display: block; }
    html body .profile-actions .profile-more .pa-ico { font-size: 20px; letter-spacing: 1px; }
    /* меню «⋯» открывается к правому краю, не уезжая за экран */
    html body .profile-actions .profile-more-menu { right: 0; left: auto; }
}
