/* Custom Properties */
:root {
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.15);
    --page-primary: linear-gradient(45deg, #6e45e2, #88d3ce);
    --page-primary-light: #88d3ce;
    --light: #f8f9fa;
    --off-light: #ccc;
}

/* Global Styles */
body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0F111A 0%, #1a1e2e 100%);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: clamp(220px, 20vw, 250px);
    height: 100vh;
    height: 100dvh;
    background: var(--glass);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.22);
}

.sidebar.collapsed {
    width: 60px;
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 0.25rem 0.5rem;
}

.sidebar-toggle {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--light);
    transition: all 0.3s ease;
    border-radius: 50%;
    padding: 0.5rem;
}

.sidebar-toggle:hover {
    background: var(--page-primary);
    border-color: var(--page-primary-light);
    transform: scale(1.1);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 0.25rem;
    overflow-y: auto;
}

.sidebar-nav-heading {
    font-size: 0.65rem;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45) !important;
    list-style: none;
    padding: 0.75rem 0.75rem 0.35rem 0.9rem;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.78rem 0.9rem;
    color: var(--off-light);
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.sidebar-link i {
    color: var(--off-light);
    transition: color 0.25s ease, transform 0.25s ease;
    width: 18px;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: white;
    transform: translateX(3px);
}

.sidebar-link:hover i {
    color: white;
    transform: scale(1.08);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(110, 69, 226, 0.95), rgba(136, 211, 206, 0.72));
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 18px rgba(110, 69, 226, 0.28);
}

.sidebar-link.active i {
    color: white;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 12%;
    height: 76%;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: rgba(255, 255, 255, 0.9);
}

.sidebar-link span {
    display: inline;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.72rem;
    gap: 0;
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed .sidebar-link i {
    font-size: 1.2rem;
}

.sidebar.collapsed .sidebar-link.active::before {
    display: none;
}

.sidebar.collapsed .navbar-brand {
    display: none;
}

/* Glow effect for collapsed sidebar icons on hover */
.sidebar.collapsed .sidebar-link:hover i {
    text-shadow: 0 0 10px var(--page-primary-light), 0 0 20px var(--page-primary);
}

/* Main Content */
.main-content {
    margin-left: 250px;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 60px;
}

/* Footer alignment with fixed sidebar */
.footer {
    margin-left: 250px;
    width: calc(100% - 250px);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.main-content.sidebar-collapsed + .footer {
    margin-left: 60px;
    width: calc(100% - 60px);
}

/* Navbar */
.glass-nav {
    position: fixed;
    top: 0;
    left: 250px;
    width: calc(100% - 250px);
    background: var(--glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    transition: left 0.3s ease, width 0.3s ease;
    z-index: 999;
}

.main-content.sidebar-collapsed .glass-nav {
    left: 60px;
    width: calc(100% - 60px);
}

/* Nav is a sibling of .main-content; keep top bar aligned when sidebar collapses */
body.member-shell-collapsed .glass-nav {
    left: 60px;
    width: calc(100% - 60px);
}

/* Member Search */
.member-search-form, .member-search-form-mobile {
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.member-search-form.active, .member-search-form-mobile.active {
    transform: translateY(0);
    opacity: 1;
}

.member-search-toggle:hover {
    background: var(--page-primary);
    transform: scale(1.1);
}

/* Chat Bar */
.chat-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 250px;
    background: var(--glass);
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 0 0 0;
    backdrop-filter: blur(12px);
    z-index: 1001;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .chat-bar {
    width: 60px;
}

.chat-bar-toggle {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--light);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.chat-bar-toggle:hover {
    background: var(--page-primary);
    border-color: var(--page-primary-light);
    transform: scale(1.1);
}

.chat-panel {
    position: fixed;
    bottom: 0;
    right: 0px;
    width: min(350px, 100vw);
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 17, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1002;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.chat-panel.open {
    display: flex;
    transform: translateY(0);
}

.chat-panel-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.chat-panel .chat-search-area {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-panel .chat-search-input {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #f8f9fa;
}

.chat-panel .chat-search-input:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(110, 69, 226, 0.3);
}

.chat-panel .chat-sidebar {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    overflow-y: auto;
    max-height: calc(100dvh - 150px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-panel.chat-active .chat-sidebar {
    display: none;
}

.chat-panel .chat-main {
    flex: 1;
    display: none;
    flex-direction: column;
    position: relative;
}

.chat-panel.chat-active .chat-main {
    display: flex;
}

.chat-panel .chat-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-panel .chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.chat-panel .chat-input-area {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-panel .chat-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s ease;
    cursor: pointer;
}

.chat-panel .chat-item.active,
.chat-panel .chat-item:hover {
    background: rgba(110, 69, 226, 0.15);
}

.chat-panel .chat-item.unread {
    font-weight: 600;
}

.chat-panel .chat-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.chat-panel .chat-item .flex-grow-1 {
    min-width: 0;
    overflow: hidden;
}

.chat-panel .chat-item h6 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-panel .chat-item .chat-preview {
    font-size: 0.85rem;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 10ch;
    display: block;
    margin-bottom: 0.25rem;
}

.chat-panel .chat-item .chat-time {
    font-size: 0.7rem;
    color: #999;
    display: block;
    margin-top: 0.1rem;
}

.chat-panel .message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-end;
}

.chat-panel .message.sent {
    justify-content: flex-end;
}

.chat-panel .message.received {
    justify-content: flex-start;
}

.chat-panel .message-bubble {
    max-width: 70%;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
}

.chat-panel .message.sent .message-bubble {
    background: var(--page-primary);
    color: #fff;
    border-bottom-right-radius: 0.2rem;
}

.chat-panel .message.received .message-bubble {
    background: rgba(255, 255, 255, 0.15);
    color: #f8f9fa;
    border-bottom-left-radius: 0.2rem;
}

.chat-panel .message-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 0.2rem;
}

.chat-panel .chat-input {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #f8f9fa;
    resize: none;
}

.chat-panel .chat-input:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(110, 69, 226, 0.3);
}

.chat-panel .delete-confirmation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 17, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    padding: 1rem;
    z-index: 1003;
    width: 80%;
    text-align: center;
}

.chat-panel .delete-confirmation p {
    color: #f8f9fa;
    margin-bottom: 1rem;
}

.chat-panel .confirmation-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* Notification Dropdown */
.notification-dropdown {
    background: rgba(15, 17, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1rem;
    width: 350px;
    max-height: 500px;
    overflow-y: auto;
}

.notification-dropdown .notification-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s ease;
}

.notification-dropdown .notification-item.unread {
    background: rgba(110, 69, 226, 0.15);
}

.notification-dropdown .notification-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-dropdown .notification-item i {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.notification-dropdown .notification-item .remove-btn {
    font-size: 0.9rem;
    color: #ff4d4f;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notification-dropdown .notification-item:hover .remove-btn {
    opacity: 1;
}

/* Comments Card */
.comments-card .comment-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s ease;
}

.comments-card .comment-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.comments-card .comment-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.75rem;
}

.comments-card .comment-item .comment-text {
    font-size: 0.9rem;
    color: #f8f9fa;
}

.comments-card .comment-item .comment-time {
    font-size: 0.7rem;
    color: #999;
}

.comments-card .reply-input {
    display: none;
    margin-top: 0.5rem;
}

.comments-card .reply-input.active {
    display: block;
}

/* Buttons */
.btn-glow {
    background: var(--page-primary);
    border: none;
    transition: all 0.3s ease;
}

.btn-glow:hover {
    box-shadow: 0 0 15px rgba(110, 69, 226, 0.5);
    transform: scale(1.05);
}

/* Member sidebar overlay (align with Bootstrap lg breakpoint) */
.member-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1095;
    display: none;
}

.member-sidebar-backdrop.show {
    display: block;
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
    }

    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .footer {
        margin-left: 0;
        width: 100%;
    }

    .main-content.sidebar-collapsed + .footer {
        margin-left: 0;
        width: 100%;
    }

    .glass-nav {
        left: 0;
        width: 100%;
    }

    .main-content.sidebar-collapsed .glass-nav {
        left: 0;
        width: 100%;
    }

    body.member-shell-collapsed .glass-nav {
        left: 0;
        width: 100%;
    }

    .sidebar {
        width: min(280px, 88vw);
        transform: translateX(-100%);
        z-index: 1100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: min(280px, 88vw);
        padding: 1rem 0.75rem;
        transform: translateX(-100%);
    }

    .sidebar.collapsed.open {
        transform: translateX(0);
    }

    .sidebar.collapsed .navbar-brand {
        display: block;
    }

    .sidebar.collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 0.78rem 0.9rem;
        gap: 0.7rem;
    }

    .sidebar.collapsed .sidebar-link span {
        display: inline;
    }

    .sidebar.collapsed .sidebar-link.active::before {
        display: block;
    }

    .chat-bar {
        left: 0;
        right: 0;
        width: auto;
        max-width: 100%;
        border-radius: 0;
        justify-content: center;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    .sidebar.collapsed .chat-bar {
        width: auto;
    }

    .chat-panel {
        width: min(100vw - 1rem, 380px);
        max-width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
        height: 100vh;
        height: 100dvh;
    }

    .notification-dropdown {
        width: min(100vw - 2rem, 350px);
        max-width: calc(100vw - 2rem);
    }
}

/* Enhanced User Profile in Navbar */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 50px;
    transition: all 0.3s ease;
    background-color: transparent;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(110, 69, 226, 0.3);
}

.user-profile img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border: none;
    transition: transform 0.3s ease;
}

.user-profile:hover img {
    transform: scale(1.1);
}

.user-profile .username {
    font-size: 0.9rem;
    font-weight: 500;
    color: #f8f9fa;
    margin-left: 0.5rem;
    display: inline-block;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4d4f;
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #0F111A;
}

/* Chat and Notification Icons */
.chat-toggle,
.notification-toggle,
.member-search-toggle {
    font-size: 1.2rem;
    color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
}

.chat-toggle:hover,
.notification-toggle:hover,
.member-search-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(110, 69, 226, 0.3);
}


.text-hover {
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
}

.text-hover:hover {
    color: #0066ff;
    transform: translateY(-2px);
    text-shadow: 0 2px 8px rgba(0, 102, 255, 0.2);
}

/* Optional underline animation */
.text-hover::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #0066ff;
    transition: width 0.3s ease;
}

.text-hover:hover::after {
    width: 100%;
}