/* ========================================
   SocialHub - Posts Styles
   ======================================== */

/* Posts Filter Bar */
.posts-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 15px 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    position: relative;
    z-index: 100; /* Increased to stay above post grid cards */
}

/* Custom Filter Dropdowns */
.filter-select {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 10px 35px 10px 15px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2300d4ff' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    min-width: 150px;
    backdrop-filter: blur(10px);
    color-scheme: dark;
}

.filter-select:hover {
    border-color: var(--accent-cyan);
    background-color: var(--bg-secondary);
}

.filter-select option {
    background-color: var(--bg-card);
    color: #ffffff;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* Custom Themed Dropdowns */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 140px;
}

.dropdown-trigger:hover {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.dropdown-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--bg-card) !important; /* Theme-aware solid background */
    backdrop-filter: none !important; /* Remove any transparency effects */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 180px;
    z-index: 1500; /* Boosted to ensure visibility over any section content */
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}

.dropdown-item {
    padding: 12px 16px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--accent-cyan);
}

/* Create Post Box */
.create-post {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    position: relative;
    z-index: 110; /* Increased to match filters hierarchy */
    box-shadow: var(--glass-shadow);
}

.create-post-top {
    display: flex;
    gap: 16px;
    align-items: center;
}

.create-post-top .avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.create-post hr {
    border: 0;
    border-top: 1px solid var(--glass-border);
    margin: 15px 0;
}

.create-post-top textarea {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: var(--bg-input);
    border-radius: 20px;
    font-size: 15px;
    transition: all 0.3s ease;
    color: var(--text-color);
    resize: none;
    outline: none;
    min-height: 44px;
}

.create-post-top textarea:focus {
    background: var(--bg-secondary);
}

.create-post-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* Mobile Fix for Create Post Layout - Prevents horizontal overflow */
@media (max-width: 600px) {
    .create-post-bottom {
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: flex-start !important;
    }
    .create-post-bottom .media-options label span {
        display: none; /* Hide "Photo/Video" text on mobile to save horizontal space */
    }
    .create-post-bottom .btn-primary {
        width: 100% !important; /* Make post button full width at the bottom */
        margin-top: 5px;
        order: 10; /* Ensure it stays at the bottom when wrapped */
    }
    /* Handle visibility dropdown and filter select spacing */
    .create-post-bottom .custom-dropdown,
    .create-post-bottom .filter-select,
    .create-post-bottom #visibility-dropdown {
        margin-left: 0 !important;
        min-width: auto !important;
        flex: 1; /* Allow the dropdown to fill available space next to icons */
    }
    .create-post-bottom .dropdown-trigger {
        min-width: auto !important;
    }
}

.media-options {
    display: flex;
    align-items: center;
    gap: 5px;
}

.media-options label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.media-options label:hover {
    background: var(--bg-hover);
    color: var(--accent-cyan);
}

.media-options label i {
    color: #45bd62; /* High-vibrant green for photos */
    font-size: 18px;
}

.create-post .filter-select {
    min-width: 120px;
    height: 36px;
    padding: 0 30px 0 12px;
    font-size: 13px;
    margin-left: auto;
}

.create-post .btn-primary {
    width: auto;
    padding: 8px 25px;
    height: 36px;
    font-size: 14px;
}

/* Upload Progress Container */
.upload-progress-container {
    display: none; /* Hidden until upload starts */
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    background: var(--bg-hover);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.upload-progress-container .progress-bar {
    flex: 1;
    height: 6px;
    background: var(--primary-gradient);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.upload-progress-container .progress-text {
    font-size: 11px;
    font-weight: 800;
    color: var(--accent-cyan);
    min-width: 32px;
    text-align: right;
}

/* Post Container & Header */
.post {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: var(--glass-shadow);
    position: relative;
    z-index: 1; /* Keep posts at a low stacking level */
    transition: all 0.3s ease;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 2px 20px;
}

/* Post Options Dropdown */
.post-options {
    position: relative;
}

.post-options-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.post-options-btn:hover {
    background: var(--bg-hover);
    color: var(--text-color);
}

.post-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card) !important; /* Force solid background */
    backdrop-filter: none !important; /* Remove transparency effects */
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1100;
    min-width: 190px;
    overflow: hidden;
    margin-top: 8px;
}

.post-dropdown-menu.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.post-dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 18px;
    border: none;
    background: none;
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.post-dropdown-menu button:hover {
    background: var(--bg-hover);
    color: var(--accent-cyan);
}

.post-dropdown-menu button i {
    width: 18px;
    text-align: center;
    color: var(--text-secondary);
}

.post-dropdown-menu button:last-child:hover {
    color: var(--danger);
}

.post-author {
    display: flex;
    gap: 14px;
    align-items: center;
}

.post-author img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-purple);
}

.post-content {
    padding: 0 20px 15px 20px;
    font-size: 0.9375rem;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    word-break: break-word;
    color: var(--text-color);
    text-indent: 0;
    margin-top: -4px; /* Pull text closer to the header name */
}

.post-actions {
    display: flex;
    justify-content: space-between;
    padding: 10px 22px;
    border-top: 1px solid var(--border-color);
    align-items: center;
}

.post-actions-left, .post-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-actions-right span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.post-actions-right span:hover {
    background: var(--bg-hover);
}

.post-action {
    padding: 10px; color: var(--text-secondary);
    font-weight: 600; border-radius: 8px; cursor: pointer; transition: all 0.3s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 18px;
}
.post-action:hover { background: var(--bg-hover); color: var(--accent-cyan); }

.comments-section {
    background: var(--bg-secondary);
    padding: 20px 22px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Comment Component Redesign
   ======================================== */
.comment {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.comment .avatar-img {
    width: 32px !important;
    height: 32px !important;
    padding: 1px !important;
    border-width: 2px !important;
    flex-shrink: 0;
}

.comment-content {
    background: var(--bg-hover);
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    flex: 1;
    position: relative;
    min-width: 0; /* Prevents overflow */
}

.comment-content h5 {
    margin: 0 0 2px 0;
    font-size: 13px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 25px;
}

.comment-content h5 span {
    font-weight: normal;
    color: var(--text-muted);
    font-size: 11px;
}

.comment-content p {
    margin: 0;
     font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-color);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 6px;
}

.comment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.reply-btn {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.reply-btn:hover {
    background: rgba(0, 212, 255, 0.1);
}

.replies {
    margin-left: 22px; /* Centers the timeline spine under the parent's avatar */
    border-left: none; /* We will use individual spine segments instead */
    padding-left: 0;
    margin-top: 0;
    position: relative;
}

/* ========================================
   Read More / Collapsible Text
   ======================================== */
.collapsible-text-container {
    position: relative;
    width: 100%;
}

.collapsible-text-content {
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Show 3 lines before truncating */
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.3s ease;
    word-break: break-word;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.collapsible-text-container.expanded .collapsible-text-content {
    display: block;
    -webkit-line-clamp: unset;
}

.read-more-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    padding: 4px 0 0 0;
    cursor: pointer;
    display: inline-block;
    opacity: 0.7;
}

.read-more-btn:hover {
    text-decoration: underline;
    opacity: 1;
}

/* Nested containers indent slightly to create the threaded look without aggressive shrinking */
.replies .replies {
    margin-left: 16px;
}

.comment.reply, .reply-form {
    position: relative;
    margin-top: 12px;
    padding-left: 30px; /* Space for the "bend" arm */
}

/* The Vertical Spine and Horizontal Bend (The "L" shape) */
.comment.reply::before {
    content: "";
    position: absolute;
    left: 0;
    top: -12px; /* Reach up to connect to previous segment */
    width: 22px;
    height: 28px; /* Height to the middle of the reply avatar */
    border-left: 2px solid var(--glass-border);
    border-bottom: 2px solid var(--glass-border);
    border-bottom-left-radius: 12px;
}

/* The vertical continuation line for items that have a sibling below them */
.comment.reply:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 0;
    top: 16px; /* Start after the bend point */
    width: 2px;
    height: calc(100% + 12px);
    background: var(--glass-border);
}

/* Comment Dropdown Positioning */
.comment-dropdown {
    position: absolute;
    top: 8px;
    right: 8px;
}

.comment-options-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.comment-options-btn:hover {
    background: var(--bg-hover);
    color: var(--text-color);
}

/* ========================================
   Comment & Reply Forms
   ======================================== */
.comment-form, .reply-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
    padding: 15px 0 0;
    border-top: 1px solid var(--glass-border);
}

.comment-form .avatar-img, .reply-form .avatar-img {
    width: 32px !important;
    height: 32px !important;
    padding: 1px !important;
    border-width: 2px !important;
    flex-shrink: 0;
}

.reply-form {
    margin-left: 0;
}

.comment-form input, .reply-form input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    padding: 10px 18px;
    border-radius: 20px;
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.comment-form input:focus, .reply-form input:focus {
    border-color: var(--accent-cyan);
    background: var(--bg-hover);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.reply-form-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.comment-form button, .reply-form button {
    background: var(--primary-gradient);
    color: var(--white);
    border: none;
    padding: 8px 20px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.comment-form button:hover, .reply-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
}

.reply-form .cancel-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

/* Comment Dropdown Styling */
.comment-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card) !important; 
    border: 1px solid var(--border-color);
    border-radius: 14px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1100;
    min-width: 170px;
    overflow: hidden !important;
    padding: 6px !important;
    margin-top: 8px;
}

.comment-dropdown-menu.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

.comment-dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 15px !important;
    border: none;
    background: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-color) !important;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    border-radius: 8px !important;
    margin-bottom: 2px;
}

.comment-dropdown-menu button:hover {
    background: var(--bg-hover);
    color: var(--accent-cyan);
}

.comment-dropdown-menu button i {
    width: 18px;
    text-align: center;
    color: var(--text-secondary);
}

/* New Comment Edit Modal Styles */
#edit-comment-modal .modal-content {
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8), var(--glass-shadow);
    animation: editModalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#edit-comment-modal textarea {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2) !important;
}

/* Enhanced Search Box Theming */
.enhanced-search-box {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    position: relative;
    z-index: 50; /* Above posts (1) and filters (30), but well below navbar (2600) */
    overflow: visible; /* Allow search suggestions to dropdown */
    transition: all 0.3s ease;
}

.enhanced-search-box:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.enhanced-search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 18px;
    color: var(--text-color);
    font-size: 14px;
    outline: none;
}

.enhanced-search-box button {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    padding: 0 15px;
    cursor: pointer;
}

/* Live Search Suggestions Dropdown */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card) !important; /* Theme-aware background */
    backdrop-filter: none !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 8px;
    z-index: 1000; /* Match other dropdowns to stay behind bottom navigation */
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.9);
    display: none;
    overflow: hidden;
}

.search-suggestions.show { display: block; }

.suggestion-item {
    background: var(--bg-card); /* Match container */
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    padding: 10px 16px;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-hover) !important;
}

/* Post Media Grid */
.post-media-grid { display: grid; gap: 4px; margin-top: 10px; background: #000; border-radius: 8px; overflow: hidden; height: 400px; }
.post-media-grid .grid-item { position: relative; cursor: pointer; overflow: hidden; }
.post-media-grid .grid-item img { width: 100%; height: 100%; object-fit: cover; }

.post-media-grid.items-1 { grid-template-columns: 1fr; height: auto; }
.post-media-grid.items-2 { grid-template-columns: 1fr 1fr; }
.post-media-grid.items-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.post-media-grid.items-3 .grid-item:first-child { grid-row: span 2; }

/* Media Preview and Rotation */
.preview-wrapper, .edit-media-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.btn-rotate-preview {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 10;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .post-media-grid { height: 300px; }
}

/* ========================================
   Reaction System Styles
   ======================================== */
.reaction-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.comment-meta-action {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s;
}

.reactions-popover {
    display: flex !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    position: absolute;
    bottom: 110%;
    left: -10px; /* Start slightly left of the button to ensure padding */
    transform: translateY(10px);
    background: var(--bg-card) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 30px;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 5000 !important; /* Force to top */
    margin-bottom: 2px;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.2s;
}

/* Right-side fallback to prevent overflow on the right edge */
.reactions-popover.align-right {
    left: auto;
    right: -10px;
}

/* Invisible bridge to prevent the popover from closing when moving the mouse from the button to the icons */
.reactions-popover::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: -20px;
    right: -20px;
    height: 15px;
    background: transparent;
}

.reaction-container:hover .reactions-popover,
.reactions-popover.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0.05s;
}

@keyframes reactionPop {
    from { opacity: 0; transform: translateX(-50%) scale(0.5); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

.reaction-item {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
}

.reaction-item:hover {
    transform: scale(1.3);
}

/* ========================================
   Post Media Viewer & Ads
   ======================================== */
.post-media-viewer {
    width: 100%;
    background: #000;
    margin-bottom: 15px;
}

.main-view-image {
    width: 100%;
    max-height: 600px;
    object-fit: contain;
}

.post-thumbnails {
    display: flex;
    gap: 8px;
    padding: 10px 22px;
    overflow-x: auto;
}

.post-video {
    width: 100%;
    max-height: 500px;
    background: #000;
}

.sponsored-ad {
    border: 2px solid var(--accent-cyan) !important; /* Thicker border */
    background: rgba(0, 212, 255, 0.06) !important; /* More distinct background */
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.1) !important;
}

.sponsored-ad .post-header span { color: var(--accent-cyan); font-weight: 900; letter-spacing: 1px; }

/* Friends Page Grid and Cards */
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

@media (min-width: 993px) {
    .friends-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        gap: 30px;
    }
}

@media (max-width: 992px) {
    .friends-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.friend-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 0;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--glass-shadow);
}

.friend-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-cyan);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), var(--glow-cyan);
}

/* Remove Tron rings from friend cards */
.friend-card .profile-tron-rings::before,
.friend-card .profile-tron-rings::after {
    content: none !important;
    animation: none !important;
    filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Card Banner/Cover */
.friend-card-cover {
    width: 100%;
    height: 100px;
    background-size: cover;
    background-position: center;
    background-color: #1a1a2e;
    position: relative;
    z-index: 0;
}

.friend-card-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(10, 11, 18, 0.2), rgba(10, 11, 18, 0.6));
}

/* Overlapping Avatar Wrapper */
.friend-card-avatar-wrap {
    margin-top: -35px; /* Pulls avatar up into the cover (half of 70px avatar) */
    position: relative;
    z-index: 2;
}

.friend-card .profile-tron-rings {
    width: 70px; /* Avatar size */
    height: 70px; /* Avatar size */
    background: transparent; /* No background needed for the container itself */
    border-radius: 50%;
    padding: 0; /* No padding needed */
    margin-bottom: 10px; /* Adjusted margin */
    box-shadow: none; /* No shadow needed for the container itself */
}

/* Revamped Unfriend Button */
.unfriend-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    background: rgba(10, 11, 18, 0.7) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
    color: #ef4444 !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-size: 13px !important;
    z-index: 10;
}

.tp-stats-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    text-align: left;
    padding: 0 5px;
}

.unfriend-btn:hover {
    background: #ef4444 !important;
    color: white !important;
    transform: scale(1.1) rotate(90deg) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6) !important;
    border-color: #ef4444 !important;
}

/* Card Content Area */
.friend-card-content {
    padding: 0 15px 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.friend-card .avatar-img {
    width: 100% !important;
    height: 100% !important;
    border: 3px solid var(--accent-cyan) !important; /* Keep a border on the avatar itself */
    border-radius: 50% !important;
    object-fit: cover !important;
}

.friend-card h3 {
    margin: 5px 0 2px 0;
    font-size: 16px;
    font-weight: 800;
    padding: 0 10px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-card h3 a {
    color: var(--white);
    text-decoration: none;
    transition: color 0.2s;
}
.friend-card h3 a:hover { color: var(--accent-cyan); }

.friend-card p {
    color: var(--text-secondary);
    font-size: 11px;
    margin: 0 0 15px 0;
    font-family: monospace;
    opacity: 0.6;
}

.friend-card-actions {
    display: flex;
    flex-direction: column !important;
    gap: 10px;
    width: 100%;
    margin-top: auto;
}

/* Mobile-specific adjustments for the business grid */
@media (max-width: 600px) {
    .friends-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .friend-card {
        border-radius: 20px !important;
    }

    .friend-card-actions .btn {
        width: 100% !important;
    }
}

.friend-card-actions .btn {
    font-size: 12px !important;
    font-weight: 900 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px !important;
    flex: 1;
    border-radius: 12px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease !important;
}

.friend-card-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* ========================================
   User Preview (Hover Card)
   ======================================== */
.user-preview-card {
    position: absolute;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    z-index: 5000;
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(15px);
}
.user-preview-card.show { display: block; opacity: 1; transform: translateY(0); }

/* --- Global Emoji Reactions --- */
.post, .comment-content, .message-bubble, .sponsored-ad { position: relative; }

.message-reactions-container {
    display: flex;
    gap: 4px;
    z-index: 10;
}

/* Adjustments for reactions when displayed inline with actions/stats */
.post-actions-right .message-reactions-container,
.comment-stats .message-reactions-container {
    position: relative;
    bottom: auto;
    left: auto;
    margin-right: 5px;
    vertical-align: middle;
    min-height: 24px;
}

/* The new Stacked UI */
.reaction-badge-stack {
    display: inline-flex;
    align-items: center;
    background: var(--bg-secondary);
    padding: 2px 8px 2px 4px;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.reaction-badge-stack:hover {
    transform: scale(1.05);
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
}

.reaction-badge-stack.my-reaction {
    background: rgba(0, 212, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.3);
}

.reaction-emoji-group {
    display: flex;
    margin-right: 2px;
    align-items: center;
}

.stacked-emoji {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    margin-left: -6px;
    position: relative;
    box-shadow: 0 0 0 2px var(--bg-card); /* This creates the "cutout" border effect */
    z-index: 1;
}

.stacked-emoji:first-child { margin-left: 0; }
.stacked-emoji:nth-child(2) { z-index: 3; }
.stacked-emoji:nth-child(3) { z-index: 2; }

.stacked-emoji span { font-size: 12px; }

.reaction-total-count {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-color);
    padding-left: 2px;
}

/* Reaction Popup UI */
.msg-reaction-popup {
    position: fixed;
    background: var(--bg-card);
    backdrop-filter: blur(25px);
    border: 1px solid var(--border-color);
    border-radius: 35px;
    padding: 10px 16px;
    display: flex;
    gap: 12px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.6);
    z-index: 8000;
    animation: reactionPopupPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom center;
}

@keyframes reactionPopupPop {
    from { transform: scale(0.5) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.reaction-option {
    font-size: 26px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.5);
    padding: 4px;
}
.reaction-option:hover { transform: scale(1.4) translateY(-8px); }

@keyframes reactionPing {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
.reaction-ping { animation: reactionPing 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.user-preview-card::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 25px;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    transform: rotate(45deg);
}