/* ============================================
   ÁÀÇÀ
   ============================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #f5f5f7;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary, #2b2b3a);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ============================================
   ÏÐÎÈÇÂÎÄÈÒÅËÜÍÎÑÒÜ / UX
   ============================================ */

.turbo-progress-bar {
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999;
    transition: width 0.2s ease;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

body.turbo-loading {
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

img[loading="lazy"] {
    content-visibility: auto;
}

/* ============================================
   PRELOADER (ãëîáàëüíûé + ñòðàíèöû ïîñòîâ)
   ============================================ */

#globalPreloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf2f8 100%);
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
}

[data-theme="dark"] #globalPreloader {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #2d1b3d 100%);
}

#globalPreloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-logo {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -1px;
    animation: preloaderPulse 1.6s ease-in-out infinite;
}

    .preloader-logo .brand-text {
        color: #8b8bff;
    }

    .preloader-logo .brand-highlight {
        color: #1a1a2e;
    }

[data-theme="dark"] .preloader-logo .brand-highlight {
    color: #ffffff;
}

@keyframes preloaderPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.85;
    }
}

.preloader-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(99, 102, 241, 0.15);
    border-top-color: #6366f1;
    border-right-color: #a855f7;
    border-radius: 50%;
    animation: preloaderSpin 0.9s linear infinite;
}

@keyframes preloaderSpin {
    to {
        transform: rotate(360deg);
    }
}

.preloader-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #6366f1;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: preloaderBlink 1.4s ease-in-out infinite;
}

@keyframes preloaderBlink {
    0%, 100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.preloader-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
}

    .preloader-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #6366f1;
        animation: preloaderDot 1.2s infinite ease-in-out;
    }

        .preloader-dots span:nth-child(2) {
            animation-delay: 0.15s;
        }

        .preloader-dots span:nth-child(3) {
            animation-delay: 0.3s;
        }

@keyframes preloaderDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   PRELOADER ÄËß ÑÒÐÀÍÈÖÛ ÏÎÑÒÎÂ
   ============================================ */

.posts-preloader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    min-height: 300px;
}

    .posts-preloader .preloader-spinner {
        width: 44px;
        height: 44px;
        border-width: 3px;
    }

    .posts-preloader .preloader-text {
        font-size: 0.8rem;
        letter-spacing: 1.5px;
    }

/* Ñêåëåòîíû */
.skeleton-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

[data-theme="dark"] .skeleton-card {
    background: rgba(255, 255, 255, 0.05);
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient( 90deg, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0.18) 50%, rgba(99, 102, 241, 0.08) 100% );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    margin-bottom: 12px;
}

    .skeleton-line.title {
        height: 20px;
        width: 60%;
        margin-bottom: 16px;
    }

    .skeleton-line.text {
        width: 100%;
    }

        .skeleton-line.text.short {
            width: 80%;
        }

    .skeleton-line.image {
        height: 160px;
        width: 100%;
        border-radius: 12px;
        margin-bottom: 16px;
    }

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   NAVBAR — ëîãî | öåíòð | ïðîôèëü
   ============================================ */

.glass-nav .container-fluid {
    padding-left: 16px;
    padding-right: 16px;
    display: flex;
    align-items: center;
}

.navbar-brand-fixed {
    flex-shrink: 0;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    margin-right: 0 !important;
    padding: 4px 0;
    text-decoration: none;
}

.nav-glass-menu {
    gap: 4px !important;
    flex-wrap: nowrap;
}

.nav-profile-group {
    flex-shrink: 0;
    margin-left: auto;
}

.nav-link-glass {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    color: var(--text-primary, #2b2b3a);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    white-space: nowrap;
    position: relative;
    background: transparent;
}

.nav-icon {
    font-size: 1rem;
    transition: transform 0.22s ease, color 0.22s ease;
    display: inline-block;
}

.nav-label {
    transition: color 0.22s ease;
}

.nav-link-glass:hover {
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-1px);
}

    .nav-link-glass:hover .nav-icon {
        transform: translateY(-2px) scale(1.1);
    }

    .nav-link-glass:hover .nav-label {
        color: var(--accent, #6366f1);
    }

.nav-link-glass.active {
    background: rgba(99, 102, 241, 0.12);
}

/* Öâåòà èêîíîê */
.icon-home {
    color: #6366f1;
}

.icon-posts {
    color: #10b981;
}

.icon-search {
    color: #06b6d4;
}

.icon-premium {
    color: #f59e0b;
}

.icon-roles {
    color: #a855f7;
}

.icon-admin {
    color: #ef4444;
}

.icon-dev {
    color: #f97316;
}

.icon-create {
    color: #22c55e;
}

.icon-chats {
    color: #14b8a6;
}

.icon-bell {
    color: #ec4899;
}

.icon-login {
    color: #0ea5e9;
}

.icon-register {
    color: #8b5cf6;
}

/* User chip */
.user-chip {
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    transition: background 0.22s ease;
    text-decoration: none;
}

    .user-chip:hover {
        background: rgba(99, 102, 241, 0.16);
    }

.user-name {
    font-weight: 700;
    font-size: 0.88rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-xs {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* ============================================
   ÓÂÅÄÎÌËÅÍÈß (toast + badge)
   ============================================ */

.toast-container {
    margin-top: 70px;
    max-width: 380px;
}

    .toast-container .toast {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        background: rgba(30, 30, 45, 0.95) !important;
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        min-width: 300px;
        animation: toastSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
        overflow: hidden;
    }

        .toast-container .toast::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: linear-gradient(180deg, #6366f1, #8b5cf6);
        }

    .toast-container .toast-body {
        padding: 12px 16px;
        font-size: 0.9rem;
        line-height: 1.35;
    }

        .toast-container .toast-body strong {
            font-weight: 700;
            font-size: 0.95rem;
        }

        .toast-container .toast-body small {
            opacity: 0.85;
        }

@keyframes toastSlideIn {
    from {
        transform: translateX(110%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#unreadBadge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.25em 0.45em;
    min-width: 18px;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.15);
    }
}

/* ============================================
   ÌÎÁÈËÜÍÀß ÀÄÀÏÒÀÖÈß
   ============================================ */

@media (max-width: 991px) {
    .navbar-collapse {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-glass-menu {
        gap: 0 !important;
    }

    .nav-link-glass {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .nav-profile-group {
        width: 100%;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .user-chip {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 576px) {
    .toast-container {
        max-width: calc(100vw - 24px);
        margin-top: 60px;
    }

        .toast-container .toast {
            min-width: unset;
            width: 100%;
        }
}
/* ============================================
   GROUP CHAT
   ============================================ */

.message-form label.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    cursor: pointer;
    margin: 0;
}

.group-message.own .msg-media {
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.group-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 320px);
    min-height: 400px;
    padding: 0;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

    .messages-container::-webkit-scrollbar {
        width: 6px;
    }

    .messages-container::-webkit-scrollbar-thumb {
        background: rgba(99, 102, 241, 0.3);
        border-radius: 3px;
    }

.group-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 75%;
    animation: msgAppear 0.2s ease-out;
}

    .group-message.own {
        align-self: flex-end;
        flex-direction: row-reverse;
    }

    .group-message.other {
        align-self: flex-start;
    }

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-avatar,
.msg-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.msg-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.msg-body {
    background: rgba(99, 102, 241, 0.08);
    padding: 8px 12px;
    border-radius: 14px;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.group-message.own .msg-body {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}

[data-theme="dark"] .msg-body {
    background: rgba(99, 102, 241, 0.15);
}

.group-message.own .msg-author {
    display: none;
}

.msg-author {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.msg-text {
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

    .msg-text .mention {
        color: #6366f1;
        font-weight: 700;
        background: rgba(99, 102, 241, 0.12);
        padding: 0 4px;
        border-radius: 4px;
    }

.group-message.own .msg-text .mention {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.msg-text a {
    color: #6366f1;
    text-decoration: underline;
}

.msg-media {
    max-width: 240px;
    border-radius: 10px;
    margin: 4px 0;
    display: block;
}

.msg-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.typing-indicator {
    padding: 6px 20px;
    font-size: 0.75rem;
    font-style: italic;
    color: #8b8b9a;
    animation: pulse 1.5s infinite;
}

.message-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(6px);
}

[data-theme="dark"] .message-form {
    background: rgba(30, 30, 45, 0.4);
    border-top-color: rgba(255, 255, 255, 0.06);
}

.message-form .form-control {
    flex: 1;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    background: #fff;
}

.message-form .btn {
    border-radius: 12px;
    padding: 0 18px;
}

@media (max-width: 768px) {
    .group-chat {
        height: calc(100vh - 260px);
    }

    .group-message {
        max-width: 88%;
    }

    .msg-media {
        max-width: 180px;
    }
}
/* ============================================
   MENTIONS AUTOCOMPLETE
   ============================================ */

.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-bottom: 4px;
}

[data-theme="dark"] .mention-dropdown {
    background: #1a1a2e;
    border-color: rgba(139, 92, 246, 0.3);
}

.mention-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: background 0.15s;
    color: #2b2b3a;
}

[data-theme="dark"] .mention-item {
    color: #e5e5ef;
}

.mention-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* ============================================
   READ MARK + ONLINE DOT (Ýòàï 7)
   ============================================ */

.read-mark {
    font-size: 0.6rem;
    margin-left: 4px;
    opacity: 0.7;
    color: #a5b4fc;
}

.msg-avatar-wrap {
    position: relative;
    display: inline-block;
}

.online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

[data-theme="dark"] .online-dot {
    border-color: #1a1a2e;
}
/* ============================================
   ÊÍÎÏÊÀ ÓÄÀËÅÍÈß ÍÀ ÊÀÐÒÎ×ÊÅ ÃÐÓÏÏÛ
   ============================================ */

.group-card-wrap {
    position: relative;
}

.group-delete-btn {
    top: 8px;
    right: 16px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: scale(0.9);
}

.group-card-wrap:hover .group-delete-btn {
    opacity: 1;
    transform: scale(1);
}

.group-delete-btn .btn {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

    .group-delete-btn .btn:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.5);
    }
/* ============================================
   SKELETON SCREENS (êàê â ÂÊ)
   ============================================ */

/* Ñêðûâàåì ïîëîñêó Turbo — íå ìåøàåò */
.turbo-progress-bar {
    display: none !important;
}

/* Îáùèé êîíòåéíåð skeleton */
.skeleton-card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
}

[data-theme="dark"] .skeleton-card {
    background: rgba(255, 255, 255, 0.05);
}

/* Îòäåëüíàÿ ïîëîñêà */
.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient( 90deg, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0.18) 50%, rgba(99, 102, 241, 0.08) 100% );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    margin-bottom: 12px;
}

    .skeleton-line.title {
        height: 20px;
        width: 60%;
        margin-bottom: 16px;
    }

    .skeleton-line.text {
        width: 100%;
    }

        .skeleton-line.text.short {
            width: 80%;
        }

    .skeleton-line.image {
        height: 160px;
        width: 100%;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .skeleton-line.avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        flex-shrink: 0;
    }

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Ïëàâíîå ïîÿâëåíèå ðåàëüíîãî êîíòåíòà */
.fade-in-content {
    animation: fadeInContent 0.3s ease-in;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ôåéä äëÿ êîíòåíòà main */
main.main-content {
    animation: fadeInContent 0.25s ease-in;
}