:root {
    --primary: #EF4444;
    --primary-hover: #dc2626;
    --secondary: #22C55E;
    --dark: #111827;
    --gray: #6B7280;
    --light: #F3F4F6;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }

body {
    background-color: #F9FAFB;
    color: var(--dark);
    overflow-x: hidden;
}



/* Layout */
.main-container {
    max-width: 900px; margin: 100px auto 0;
    display: grid; grid-template-columns: 1fr 320px; 
    gap: 2rem; padding: 0 20px 40px;
}

@media (max-width: 900px) {
    .main-container { grid-template-columns: 1fr; }
    .sidebar-right { display: none; }
}

/* Feed */
.feed { display: flex; flex-direction: column; gap: 1.5rem; }

/* Create Post Card */
.create-post-card {
    background: white; border-radius: 16px; padding: 1.5rem;
    box-shadow: var(--shadow); border: 1px solid #E5E7EB;
}

.cp-tabs { display: flex; border-bottom: 1px solid #eee; margin-bottom: 1rem; }
.cp-tab {
    padding: 10px 20px; cursor: pointer; font-weight: 600; color: var(--gray);
    border-bottom: 3px solid transparent; transition: 0.3s;
}
.cp-tab:hover { color: var(--primary); }
.cp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cp-tab.hidden { display: none; }

.input-area { display: flex; flex-direction: column; gap: 10px; }

.post-title-input {
    width: 100%; border: 1px solid #E5E7EB; padding: 10px 15px;
    border-radius: 8px; font-weight: 600; font-size: 1rem; outline: none;
    display: none;
}
.post-title-input.active { display: block; }

textarea {
    width: 100%; border: none; resize: none; outline: none;
    font-size: 1rem; padding: 10px 0; min-height: 80px;
    font-family: 'Poppins', sans-serif;
}

.image-upload-area { margin-top: 10px; }
.btn-upload {
    display: inline-block; background: var(--light); padding: 8px 15px;
    border-radius: 20px; font-size: 0.9rem; cursor: pointer;
    border: 1px solid #ddd;
}
.image-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.image-preview img {
    width: 60px; height: 60px; object-fit: cover; border-radius: 8px;
    border: 1px solid #ddd;
}

.cp-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee;
}
.btn-post {
    background: var(--primary); color: white; padding: 8px 25px;
    border-radius: 50px; border: none; font-weight: 600;
    cursor: pointer; transition: 0.3s;
}
.btn-post:hover { background: var(--primary-hover); }

/* Post Card */
.post-card {
    background: white; border-radius: 16px; padding: 1.5rem;
    box-shadow: var(--shadow); border: 1px solid #E5E7EB;
}

.post-header { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.user-info { display: flex; gap: 12px; align-items: center; }
.avatar {
    width: 45px; height: 45px; border-radius: 50%; object-fit: cover;
    background: #eee; display: flex; align-items: center; justify-content: center;
    color: #aaa; font-size: 1.2rem;
}
.meta h4 { font-size: 1rem; font-weight: 600; line-height: 1.2; }
.meta span { font-size: 0.8rem; color: var(--gray); }

.role-badge {
    font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; margin-left: 5px;
}
.role-patient { background: #E0F2FE; color: #0284C7; }
.role-pharmacy { background: #F3E8FF; color: #9333EA; }
.role-doctor { background: #DCFCE7; color: #16A34A; }

/* Post Content */
.post-content h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--dark); }
.post-content p { color: #374151; line-height: 1.6; font-size: 0.95rem; white-space: pre-line; }
.post-tag { 
    display: inline-block; background: #FEF2F2; color: var(--primary); 
    font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; margin-bottom: 8px; font-weight: 600;
}

/* Truncated text */
.post-text.truncated {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.see-more-btn {
    background: none; border: none; color: var(--primary);
    font-size: 0.9rem; cursor: pointer; margin-top: 5px;
    font-weight: 500;
}

/* Images grid */
.post-images {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0;
}
.post-images img {
    max-width: 100%; border-radius: 8px; cursor: pointer;
    object-fit: cover;
}
.post-images.single img { max-height: 300px; width: auto; }
.post-images.multiple img {
    width: calc(33.33% - 5px); aspect-ratio: 1/1;
}
.post-images.expanded img { width: 100%; max-height: 400px; object-fit: contain; }

/* Interaction Bar */
/* Interaction Bar */
.interaction-bar {
    display: flex; 
    justify-content: space-between; /* Spreads buttons evenly */
    align-items: center;
    margin-top: 1rem; 
    padding-top: 1rem;
    border-top: 1px solid #eee; 
    flex-wrap: wrap;
}
.interaction-bar .action-btn {
    flex: 1; /* Allows buttons to take up equal space */
    justify-content: center; /* Centers icon and text */
}

.action-btn {
    background: none; border: none; color: var(--gray);
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    font-size: 0.9rem; transition: 0.2s;
}
.action-btn:hover { color: var(--dark); }
.action-btn.liked { color: var(--primary); }
.action-btn.liked i { font-weight: 900; }
.follow-btn.following { color: var(--secondary); }

/* Comments Section */
.comments-section {
    margin-top: 1rem; background: #F9FAFB; padding: 1rem;
    border-radius: 12px; display: none;
}
.comments-section.open { display: block; }

.comment-tabs { display: flex; gap: 10px; margin-bottom: 10px; }
.comment-tab {
    padding: 5px 15px; border-radius: 20px; background: #eee;
    cursor: pointer; font-size: 0.9rem;
}
.comment-tab.active { background: var(--primary); color: white; }

.comment-input-box { display: flex; gap: 10px; margin-bottom: 15px; }
.comment-input-box input {
    flex: 1; padding: 8px 12px; border: 1px solid #E5E7EB;
    border-radius: 20px; outline: none; font-size: 0.9rem;
}
.btn-send {
    background: var(--dark); color: white; border: none;
    width: 35px; height: 35px; border-radius: 50%; cursor: pointer;
}

.comment-list { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.single-comment { font-size: 0.9rem; border-bottom: 1px solid #eee; padding-bottom: 8px; }
.comment-author { font-weight: 600; font-size: 0.85rem; margin-right: 5px; }
.answer-badge {
    background: var(--secondary); color: white; font-size: 0.7rem;
    padding: 2px 8px; border-radius: 12px; margin-left: 5px;
}

/* Widgets */
.widget {
    background: white; padding: 1.5rem; border-radius: 16px;
    box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.widget h3 { font-size: 1.1rem; margin-bottom: 1rem; border-left: 4px solid var(--primary); padding-left: 10px; }

.topic-tag {
    display: inline-block; background: #F3F4F6; padding: 5px 12px;
    border-radius: 50px; font-size: 0.85rem; color: var(--dark);
    margin: 0 5px 8px 0; cursor: pointer; transition: 0.3s;
}
.topic-tag:hover { background: #e5e7eb; }

/* Toast */
#toast-box {
    position: fixed; bottom: 30px; right: 30px;
    background: var(--dark); color: white; padding: 15px 25px;
    border-radius: 12px; z-index: 9999; opacity: 0; transform: translateY(20px);
    transition: all 0.3s ease; pointer-events: none;
    display: flex; align-items: center; gap: 10px;
}
#toast-box.show { opacity: 1; transform: translateY(0); }

/* Loading */
.loading-spinner { text-align: center; padding: 40px; color: gray; }


/* --- SIDEBAR & NAVBAR INTEGRATION --- */
:root {
    --sidebar-width: 260px;
}

/* Exact Dashboard Sidebar Styles */
.sidebar { 
    width: var(--sidebar-width); height: 100vh; background: white; 
    position: fixed; top: 0; left: 0; border-right: 1px solid #E5E7EB; 
    display: flex; flex-direction: column; padding: 2rem 1.5rem; 
    /* Ultra-smooth slide animation */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease; 
    z-index: 2001; /* Boosted to cover the navbar on mobile */
}
.sidebar .brand { font-size: 24px; font-weight: 700; margin-bottom: 3rem; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.sidebar .nav-items { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar .nav-item { padding: 12px 15px; border-radius: 12px; color: var(--gray); font-weight: 500; cursor: pointer; transition: all 0.3s; display: flex; align-items: center; gap: 12px; }
.sidebar .nav-item:hover, .sidebar .nav-item.active { background: #FEF2F2; color: var(--primary); }
.sidebar .user-mini-profile { border-top: 1px solid #E5E7EB; padding-top: 1.5rem; margin-top: auto; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background 0.2s, padding 0.2s; border-radius: 12px; }
.sidebar .user-mini-profile:hover { background: #F9FAFB; padding-left: 10px; }
.sidebar .mini-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--secondary); }
.sidebar #sideName { font-size: 0.95rem; font-weight: 600; color: var(--dark); margin: 0; text-transform: capitalize; }

.sidebar-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); 
    z-index: 2000; /* Boosted to cover the main content and navbar */
    display: none; opacity: 0; 
    transition: opacity 0.4s ease; 
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* Centered Navbar Desktop */
.navbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 5%; position: fixed; height: 70px;
    width: calc(100% - var(--sidebar-width)); left: var(--sidebar-width); top: 0; z-index: 1000;
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.nav-top-bar { display: flex; align-items: center; width: 100%; justify-content: space-between; }
.nav-left { display: flex; align-items: center; gap: 15px; }

.mobile-menu-btn { display: none; background: transparent; border: none; font-size: 1.5rem; color: var(--dark); cursor: pointer; transition: color 0.3s; }
.mobile-menu-btn:hover { color: var(--primary); }

/* Desktop Search Icon */
.desktop-search-icon {
    background: #F3F4F6; border: none; width: 40px; height: 40px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; color: var(--dark);
    font-size: 1.1rem; cursor: pointer; transition: background 0.3s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.desktop-search-icon:hover { background: #E5E7EB; }
.desktop-search-icon:active { transform: scale(0.9); }

.nav-links { 
    display: flex; gap: 2.5rem; list-style: none; 
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); /* Perfect Center */
    align-items: center; margin: 0; padding: 0;
}
.nav-links a { 
    color: var(--gray); font-size: 1.4rem; text-decoration: none; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    padding: 8px 12px; border-radius: 8px; display: flex; align-items: center;
}
.nav-links a:hover, .nav-links a.active { 
    color: var(--primary); background: #FEF2F2; transform: scale(1.1);
}

/* Desktop Adjustments */
@media (min-width: 901px) {
    .main-container { margin-left: var(--sidebar-width); max-width: calc(100% - var(--sidebar-width)); margin-top: 90px; }
    #navLogo { display: none !important; } /* Hide top logo on desktop */
    .mobile-search-btn { display: none !important; } /* Hide mobile search on desktop */
    .desktop-search-icon { display: flex; } /* Show desktop search */
    
    .nav-links {
        left: calc(50% - 176px);
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (max-width: 900px) {
    .navbar { 
        left: 0; width: 100%; padding: 0; 
        flex-direction: column; align-items: stretch; height: auto;
        position: fixed; z-index: 1010; 
        background: rgba(255, 255, 255, 0.98); 
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }
    .nav-top-bar { padding: 12px 15px; justify-content: space-between; }
    
    .desktop-search-icon { display: none !important; } /* Hide desktop search */
    #navLogo { display: flex !important; } /* Show logo on mobile */
    .mobile-search-btn { display: flex !important; } /* Show mobile search */
    
    .sidebar { transform: translateX(-100%); box-shadow: 10px 0 30px rgba(0,0,0,0.15); z-index: 2001; }
    .sidebar.active { transform: translateX(0); }
    
    .nav-left { width: auto; z-index: 1011; }
    
    .mobile-menu-btn { 
        display: flex !important; align-items: center; justify-content: center;
        position: relative; z-index: 1015; padding: 0;
    }
    .mobile-menu-btn i { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
    .mobile-menu-btn:active i { transform: scale(0.8); }
    
    /* Hide Desktop Message Link on Mobile */
    .desktop-message-link { display: none !important; }

    /* Mobile Search & Message Icons */
    .top-search-icon, .top-message-icon {
        background: #F3F4F6; border: none; width: 40px; height: 40px; border-radius: 50%;
        display: flex; justify-content: center; align-items: center; color: var(--dark);
        font-size: 1.1rem; cursor: pointer; transition: background 0.3s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .top-search-icon:active, .top-message-icon:active { transform: scale(0.9); background: #E5E7EB; }

    /* Facebook-Style 2nd Row Nav Bar */
    .nav-links { 
        position: static; transform: none; width: 100%; 
        background: white; padding: 10px 0; justify-content: space-around; 
        border-top: 1px solid #E5E7EB; gap: 0;
    }
    
    /* Adjust main container to clear the new taller 2-row navbar */
    .main-container { margin-left: 0; max-width: 100%; margin-top: 125px; padding-bottom: 20px; }
}

/* Slim Post Trigger */
.slim-post-trigger {
    background: white; border-radius: 50px; padding: 6px 12px; /* A. Slimmer padding */
    box-shadow: var(--shadow); border: 1px solid #E5E7EB;
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.slim-post-trigger:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.1); }
.slim-post-trigger .trigger-input {
    flex: 1; color: var(--gray); background: #F3F4F6;
    padding: 8px 16px; border-radius: 30px; font-size: 0.95rem; text-align: left; /* A. Slimmer padding */
}

/* Modal Animations */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 3000; /* BUG FIX: Boosted to ensure it covers the 2001 Sidebar */
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    width: 100%; max-width: 550px; transform: translateY(30px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 20px; padding: 1.5rem;
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }

/* Dedicated Answers Section */
.answers-section {
    margin-top: 1rem; background: #F0FDF4; padding: 1rem;
    border-radius: 12px; border: 1px solid #BBF7D0; display: none;
    animation: fadeIn 0.3s ease;
}
.answers-section.open { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }


/* --- NEW POST OPTIONS & UI --- */

/* Sleek Inline Follow */
.inline-follow-btn {
    background: none; border: none; color: var(--gray);
    font-size: 0.9rem; cursor: pointer; transition: color 0.3s;
    padding: 2px 5px; border-radius: 4px;
}
.inline-follow-btn:hover { color: var(--primary); background: #FEF2F2; }
.inline-follow-btn.following { color: var(--secondary); }

/* 3-Dot Options Menu */
.post-options { position: relative; }
.options-trigger {
    background: none; border: none; font-size: 1.2rem; color: var(--gray);
    cursor: pointer; padding: 5px; border-radius: 50%; transition: 0.2s;
}
.options-trigger:hover { background: var(--light); color: var(--dark); }

.options-dropdown {
    position: absolute; right: 0; top: 100%; background: white;
    border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border: 1px solid #E5E7EB; width: 160px; z-index: 100;
    opacity: 0; pointer-events: none; transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.options-dropdown.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

.options-dropdown button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 15px; border: none; background: none; text-align: left;
    font-size: 0.9rem; color: var(--dark); cursor: pointer;
    border-bottom: 1px solid #F3F4F6; transition: background 0.2s;
}
.options-dropdown button:last-child { border-bottom: none; }
.options-dropdown button:hover { background: #F9FAFB; }
.text-danger { color: #EF4444 !important; }

.pin-badge {
    color: var(--primary); font-weight: 600; font-size: 0.75rem;
    margin-right: 5px;
}


/* --- NEW FIXES & FEATURES --- */

/* Add Gap Between Posts */
#feedContainer {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}


/* Modernized Comment Layout */
.single-comment {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #E5E7EB;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fadeIn 0.3s ease;
}

.single-comment:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.comment-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s ease;
}

.comment-user-info:hover {
    opacity: 0.8;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F3F4F6;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--gray);
}

.comment-text-content {
    color: #374151;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.5;
    padding-left: 42px; /* Aligns text seamlessly with the name, skipping the avatar */
}

/* Comment 3-Dot Options Menu */
.comment-options { position: relative; }

.comment-options-trigger { 
    background: none; border: none; color: #9CA3AF; cursor: pointer; 
    width: 28px; height: 28px; border-radius: 50%; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
}

.comment-options-trigger:hover { 
    color: var(--dark); 
    background: #F3F4F6; 
}

.comment-dropdown {
    position: absolute; right: 0; top: 100%; background: white; border: 1px solid #E5E7EB;
    border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); z-index: 50; 
    width: 120px; opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.comment-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }

.comment-dropdown button {
    width: 100%; text-align: left; padding: 8px 12px; border: none; background: none; 
    cursor: pointer; font-size: 0.85rem; border-bottom: 1px solid #F3F4F6;
}

.comment-dropdown button:hover { background: #F9FAFB; }


/* Notifications Dropdown */
.nav-item-relative { position: relative; display: flex; align-items: center; }
.notifications-dropdown {
    position: absolute; top: 140%; right: -20px; width: 320px; max-height: 400px; overflow-y: auto;
    background: white; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border: 1px solid #E5E7EB; z-index: 2000; opacity: 0; visibility: hidden; transform: translateY(-15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.notifications-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.notification-item { 
    padding: 12px 15px; border-bottom: 1px solid #F3F4F6; font-size: 0.85rem; 
    cursor: pointer; transition: background 0.2s; line-height: 1.4;
}
.notification-item:hover { background: #F9FAFB; }
.notification-item.unread { background: #F0FDF4; border-left: 3px solid var(--secondary); }
.notification-badge {
    position: absolute; top: 0; right: 0; background: var(--primary); color: white;
    font-size: 0.65rem; padding: 2px 6px; border-radius: 50%; transform: translate(30%, -30%);
    font-weight: bold; border: 2px solid white;
}


/* Feed Sort Toggle styling */
.feed-sort-toggle {
    display: flex;
    position: relative;
    background: rgba(243, 244, 246, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 6px;
    margin-bottom: 12px; /* B. Reduced gap to pull feed closer */
    width: 100%;
    max-width: 450px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), top 0.3s ease, box-shadow 0.3s ease;
    z-index: 99; /* D. Ensure it floats above posts when sticky */
}

/* D. Directional Sticky State */
.feed-sort-toggle.is-sticky {
    position: sticky;
    top: 80px; /* Rest just below Desktop Nav */
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    background: rgba(243, 244, 246, 0.95); /* More opaque when floating */
}

@media (max-width: 900px) {
    .feed-sort-toggle.is-sticky {
        top: 115px; /* Rest exactly under the 2-row Mobile Nav */
    }
}

.sort-bg {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(33.33% - 8px);
    height: calc(100% - 12px);
    background: white;
    border-radius: 40px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

.feed-sort-toggle[data-active="foryou"] .sort-bg { transform: translateX(0); }
.feed-sort-toggle[data-active="recent"] .sort-bg { transform: translateX(100%); }
.feed-sort-toggle[data-active="trending"] .sort-bg { transform: translateX(200%); }

.sort-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s ease, transform 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.sort-btn:active { transform: scale(0.95); }
.sort-btn.active { color: var(--primary); }

/* Recommended Badge */
.recommended-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(239, 68, 68, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
    animation: fadeIn 0.5s ease;
}

/* Mobile Optimization */
@media (max-width: 600px) {
    .nav-links { padding: 8px 0; }
    .nav-links a { font-size: 1.3rem; padding: 8px 15px; }
    .main-container { padding: 0 10px 20px; margin-top: 120px; }
    .create-post-card { padding: 1rem; }
    .interaction-bar { gap: 1rem; justify-content: space-between; }
    
    /* Hide text labels (like 'Answers') to save space, but explicitly show vital metrics */
    .action-btn span { display: none; }
    .action-btn span.like-count, 
    .action-btn span.comment-count { 
        display: inline-block; 
        margin-left: 2px; 
        font-size: 0.95rem; 
        font-weight: 500;
    }
    
    .action-btn { font-size: 1.1rem; }
    .feed-sort-toggle { width: 100%; }
    .modal-content { align-self: flex-end; margin: 0; border-radius: 20px 20px 0 0; }
    
    /* Dropdown now animates from the top header */
    .notifications-dropdown {
        position: fixed; top: 110px; bottom: auto; right: 10px; left: 10px; width: auto; 
        max-height: 60vh; transform: translateY(-15px);
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }
    .notifications-dropdown.show { transform: translateY(0); }

    /* Constrain editor height on mobile to leave room for the keyboard */
    .rich-editor { max-height: 35vh; }
}


/* --- D. RICH TEXT EDITOR STYLES --- */
.editor-toolbar {
    display: flex; gap: 8px; margin-bottom: 5px; padding: 5px;
    background: #F9FAFB; border: 1px solid #E5E7EB; border-radius: 8px;
}
.editor-toolbar button {
    background: none; border: none; cursor: pointer; padding: 6px 10px;
    border-radius: 4px; color: var(--gray); transition: 0.2s;
}
.editor-toolbar button:hover { background: #E5E7EB; color: var(--dark); }

.rich-editor {
    width: 100%; min-height: 100px; max-height: 350px; border: 1px solid #E5E7EB;
    border-radius: 8px; padding: 12px; font-size: 1rem;
    outline: none; overflow-y: auto; background: white;
    white-space: pre-wrap; word-wrap: break-word; line-height: 1.6;
    scroll-behavior: smooth;
}

/* Modern Scrollbar for the Editor */
.rich-editor::-webkit-scrollbar { width: 6px; }
.rich-editor::-webkit-scrollbar-track { background: transparent; }
.rich-editor::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 10px; }
.rich-editor::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

.rich-editor:empty:before {
    content: attr(data-placeholder);
    color: #9CA3AF; pointer-events: none; display: block;
}

/* --- B. TEXT ALIGNMENT & LIST FIXES --- */
.rich-editor ul, .rich-editor ol,
.post-text ul, .post-text ol {
    padding-left: 24px;
    margin-top: 8px;
    margin-bottom: 8px;
}
.rich-editor li, .post-text li {
    margin-bottom: 4px;
    list-style-position: outside;
}


/* --- ANONYMOUS POSTING UI --- */
.anonymous-toggle-container {
    margin-bottom: 15px;
    background: #F9FAFB;
    border-radius: 12px;
    padding: 12px 15px;
    border: 1px solid #E5E7EB;
    transition: all 0.3s ease;
}
.toggle-header {
    display: flex; justify-content: space-between; align-items: center;
}
.toggle-label {
    font-weight: 600; color: var(--dark); display: flex; align-items: center; gap: 8px;
}

/* Modern Toggle Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #D1D5DB; transition: .4s;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white;
    transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

/* Anon Details with smooth slide down */
.anonymous-details { margin-top: 12px; animation: slideDown 0.3s ease forwards; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.anon-info-box {
    background: #E0F2FE; border-left: 3px solid #0284C7;
    padding: 10px; border-radius: 4px; display: flex; gap: 10px; margin-bottom: 10px;
}
.anon-info-box i { color: #0284C7; margin-top: 3px; }
.anon-info-box p { font-size: 0.8rem; color: #0369A1; line-height: 1.4; margin: 0;}
.anon-info-box small { color: #0C4A6E; opacity: 0.8; }

.anon-nickname-input {
    width: 100%; padding: 10px 15px; border: 1px solid #E5E7EB; border-radius: 8px;
    outline: none; font-size: 0.9rem; transition: border-color 0.2s;
}
.anon-nickname-input:focus { border-color: var(--primary); }

/* Mini toggle for feed comments */
.comment-anon-wrapper {
    display: flex; flex-direction: column; width: 100%; margin-bottom: 15px;
    background: white; border: 1px solid #E5E7EB; border-radius: 12px; padding: 10px;
}
.comment-anon-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.85rem; font-weight: 600; color: var(--gray); margin-bottom: 8px;
}
.comment-input-row { display: flex; gap: 10px; width: 100%; }
.comment-anon-details { margin-top: 8px; display: none; animation: slideDown 0.2s ease forwards; }


/* --- DYNAMIC FEED ANIMATIONS --- */
.post-fade-out {
    animation: fadeOutSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes fadeOutSlide {
    0% { opacity: 1; transform: scale(1) translateY(0); }
    50% { opacity: 0; transform: scale(0.95) translateY(-10px); }
    100% { 
        opacity: 0; 
        transform: scale(0.95) translateY(-20px); 
        height: 0; 
        margin-bottom: 0; 
        padding-top: 0; 
        padding-bottom: 0; 
        border: 0; 
        overflow: hidden; 
    }
}


/* --- UNIVERSAL VERIFIED BADGES --- */
.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    margin-left: 4px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* MEDeLIFE Red for Medical Professionals (Doctors/Pharmacy) */
.badge-pro {
    color: var(--primary) !important; 
    filter: drop-shadow(0 2px 2px rgba(239, 68, 68, 0.2));
    cursor: help;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
}

/* MEDeLIFE Green for Patients */
.badge-patient {
    color: var(--secondary) !important; 
    filter: drop-shadow(0 2px 2px rgba(34, 197, 94, 0.2));
    cursor: help;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
}

/* Smooth hover effects */
.badge-pro:hover {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(0 4px 6px rgba(239, 68, 68, 0.4));
}

.badge-patient:hover {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(0 4px 6px rgba(34, 197, 94, 0.4));
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}


/* --- SEARCH MODAL STYLES --- */
.search-result-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    background: white; border: 1px solid #E5E7EB; border-radius: 12px;
    cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
    text-decoration: none; color: var(--dark);
    animation: slideDown 0.3s ease forwards;
}
.search-result-item:hover {
    transform: translateY(-2px); 
    box-shadow: 0 6px 12px rgba(0,0,0,0.05); 
    border-color: #D1D5DB;
}
.search-avatar {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
    background: #F3F4F6; display: flex; justify-content: center; align-items: center; 
    color: var(--gray); flex-shrink: 0; font-size: 1.1rem; border: 1px solid #eee;
}
.search-info { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.search-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.search-meta { font-size: 0.85rem; color: var(--gray); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-section-title { font-size: 0.8rem; font-weight: 700; color: #9CA3AF; text-transform: uppercase; margin-top: 15px; margin-bottom: 5px; letter-spacing: 0.5px; padding-left: 5px; }

/* Custom scrollbar for search results */
#searchResults::-webkit-scrollbar { width: 5px; }
#searchResults::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 10px; }


/* ADD TO THE BOTTOM OF community.css */

/* Modal Overlay & Glassmorphism */
.interest-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.interest-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Smooth Spring Animation for Content */
.interest-modal-content {
    background: white;
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    transform: translateY(40px) scale(0.95);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.interest-modal-overlay.active .interest-modal-content {
    transform: translateY(0) scale(1);
}

.modal-header h2 { font-size: 1.5rem; color: var(--dark); margin-bottom: 8px; }
.modal-header p { color: var(--gray); font-size: 0.9rem; margin-bottom: 20px; }

/* Responsive Grid for Pills */
.interest-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    max-height: 40vh;
    overflow-y: auto;
    padding-bottom: 10px;
}

/* Tactile Interactive Pills */
.interest-pill {
    padding: 10px 18px;
    border-radius: 50px;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    user-select: none;
}

.interest-pill:hover {
    border-color: #D1D5DB;
    transform: translateY(-2px);
}

.interest-pill.active {
    background: rgba(239, 68, 68, 0.1);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
    transform: scale(1.05);
}

/* Modern Button Styling */
.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary-modern {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary-modern:active { transform: scale(0.97); }
.btn-primary-modern.disabled { opacity: 0.5; pointer-events: none; filter: grayscale(100%); }

.btn-skip {
    background: none; border: none; color: var(--gray);
    font-size: 0.9rem; cursor: pointer; padding: 8px;
    transition: color 0.2s;
}
.btn-skip:hover { color: var(--dark); }

/* Ensure Mobile Perfection */
@media (max-width: 600px) {
    .interest-modal-content { padding: 24px 20px; width: 95%; }
    .modal-header h2 { font-size: 1.35rem; }
    .interest-pill { padding: 8px 14px; font-size: 0.8rem; }
}


/* Add to the bottom of community.css */
.interest-pill.blocked {
    background: #374151; /* Dark slate gray */
    color: #F9FAFB;
    border-color: #111827;
    text-decoration: line-through;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: scale(0.95); /* Pushes the button inward */
    opacity: 0.9;
}

/* Subtle animation for the text change in the modal header */
.interest-modal-content .modal-header p {
    transition: all 0.3s ease;
}


/* --- MICRO-INTERACTIONS: COMMENT LIKES & REPLIES --- */
.comment-actions-bar {
    display: flex;
    gap: 15px;
    padding-left: 42px; /* Perfect alignment under the comment text */
    margin-top: 6px;
}

.comment-action-btn {
    background: none;
    border: none;
    color: #9CA3AF;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.comment-action-btn:hover {
    color: var(--dark);
}

.comment-action-btn.liked {
    color: var(--primary);
}

/* Structural Indentation for Nested Replies */
.single-comment.is-reply {
    margin-left: 42px;
    border-left: 3px solid #E5E7EB;
    border-radius: 0 12px 12px 12px;
    background: #F9FAFB;
    padding: 10px 14px;
}

/* Smooth Slide-Down Input Box */
.mini-reply-box {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-left: 42px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.mini-reply-input {
    flex: 1;
    padding: 6px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 20px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    background: #F9FAFB;
}

.mini-reply-input:focus {
    border-color: var(--primary);
    background: white;
}

.mini-btn-send {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}