/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Allow clicking through container */
}

.toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--accent-color);
    min-width: 250px;
    max-width: 350px;
    animation: slideInRight 0.3s ease-out forwards;
    pointer-events: auto; /* Re-enable clicks on toast */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.95rem;
}

.toast.hiding {
    animation: fadeOutRight 0.3s ease-in forwards;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@media (max-width: 600px) {
    .toast-container {
        left: 20px;
        right: 20px;
        bottom: 80px; /* Above mobile nav if exists */
    }
    .toast {
        width: 100%;
        max-width: none;
    }
}

:root {
    /* Light Mode Variables */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #3b82f6; /* Blue-500 */
    --accent-hover: #2563eb; /* Blue-600 */
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --border-radius: 12px;
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
    
    --nav-bg: rgba(255, 255, 255, 0.8);
    --nav-border: rgba(255, 255, 255, 0.3);
}

:root.dark-mode, body.dark-mode {
    /* Dark Mode Variables */
    --bg-primary: #0f172a; /* Slate-900 */
    --bg-secondary: #1e293b; /* Slate-800 */
    --text-primary: #f1f5f9; /* Slate-100 */
    --text-secondary: #94a3b8; /* Slate-400 */
    --accent-color: #60a5fa; /* Blue-400 */
    --accent-hover: #3b82f6; /* Blue-500 */
    
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    
    --input-bg: #334155; /* Slate-700 */
    --input-border: #475569; /* Slate-600 */
    
    --nav-bg: rgba(15, 23, 42, 0.8);
    --nav-border: rgba(255, 255, 255, 0.1);
}

/* Global Reset */
* {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

/* =========================================
   NAVIGATION (Glassmorphism)
   ========================================= */
.navbar {
    background-color: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--nav-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-color), #8b5cf6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-links a:hover {
    background-color: rgba(128, 128, 128, 0.1);
    text-decoration: none;
}

/* Language Select in Navbar */
.lang-select {
    width: auto;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 0.9rem;
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--nav-border);
    cursor: pointer;
}

.lang-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.lang-select:focus {
    box-shadow: none;
    border-color: var(--accent-color);
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    font-size: 1.8rem; /* Bigger icon */
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    width: auto; /* Fix for too wide */
    z-index: 1001; /* Ensure on top */
}

body.mobile-chat-active .navbar {
    display: none !important;
}

body.mobile-chat-active .container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    height: 100dvh !important;
}

body.mobile-chat-active .chat-container {
    height: 100dvh !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
}

/* Ensure mobile chat header is always visible */
body.mobile-chat-active .chat-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-radius: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Slight shadow for separation */
}

/* Push messages down so they don't hide behind fixed header */
body.mobile-chat-active .chat-messages {
    margin-top: 60px; /* Adjusted for header height */
    padding-bottom: 80px; /* Space for input area */
    height: calc(100% - 130px); /* Approximate available space */
    overflow-y: auto;
}

/* Ensure input area is fixed at bottom on mobile */
body.mobile-chat-active .chat-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: var(--bg-secondary);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* Prevent body scroll on mobile chat */
body.mobile-chat-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-secondary);
        flex-direction: column;
        padding: 0; /* Remove padding, use item padding */
        box-shadow: var(--card-shadow);
        border-bottom: 1px solid var(--nav-border);
        gap: 0; /* Remove gap */
        max-height: 80vh;
        overflow-y: auto;
        z-index: 2000; /* Increased z-index */
    }
    .nav-links.active { display: flex; }
    
    /* Common style for all menu items */
    .nav-links > a, 
    .nav-links > .notification-container,
    .nav-links > .profile-dropdown {
        width: 100%;
        padding: 15px 20px;
        border-bottom: 1px solid var(--input-border);
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        color: var(--text-primary);
        flex-wrap: wrap; /* Allow dropdown to break to new line */
    }

    /* Chat Icon -> Text */
    .nav-links a[href="/chat"] {
        gap: 12px;
        font-size: 1.2rem; /* Icon size */
    }
    .nav-links a[href="/chat"]::after {
        content: "Messages";
        font-size: 1rem;
        color: var(--text-primary);
    }

    /* Notification Bell -> Text */
    .notification-container {
        margin-right: 0;
    }
    .notification-btn {
        width: 100%;
        padding: 0;
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 1.2rem;
    }
    .notification-btn::after {
        content: "Notifications";
        font-size: 1rem;
        color: var(--text-primary);
    }
    .notification-dropdown {
        position: static; /* Show inline if needed, or hide */
        width: 100%;
        box-shadow: none;
        border: none;
        background: rgba(0,0,0,0.02);
        display: none;
    }
    .notification-dropdown.show {
        display: block;
    }

    /* Profile Avatar -> Text */
    .profile-dropdown {
        flex-wrap: wrap; /* Allow menu to break */
    }
    .profile-avatar {
        margin-right: 12px;
        width: 32px;
        height: 32px;
    }
    .profile-dropdown::after {
        content: "Profile";
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-primary);
    }
    .profile-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        background: var(--bg-secondary); /* Ensure opaque background */
        padding-left: 0;
        margin-top: 10px;
        border-left: 2px solid var(--accent-color); /* Visual indicator */
    }
    .profile-menu a {
        padding-left: 20px; /* Indent sub-items */
    }
}

/* =========================================
   LAYOUT & CARDS
   ========================================= */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

.card, .form-box, .event-card, .forum-category, .reply-box, .topic-header, .post {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(128, 128, 128, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative; /* Context for absolute children */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.event-card:hover, .topic-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

/* =========================================
   FORMS & INPUTS
   ========================================= */
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 20px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input:disabled, textarea:disabled, select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
}

body.dark-mode input:disabled, 
body.dark-mode textarea:disabled, 
body.dark-mode select:disabled {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-color: var(--input-border);
}

/* =========================================
   BUTTONS
   ========================================= */
button, .action-btn, .btn-primary {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, box-shadow 0.1s;
}

button:hover, .action-btn:hover, .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    color: white;
}

button:active, .action-btn:active, .btn-primary:active {
    transform: translateY(0);
}

button.secondary {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    box-shadow: none;
}

button.secondary:hover {
    background-color: var(--input-bg);
    color: var(--text-primary);
}

button.danger, .delete-btn, .btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
}

/* =========================================
   EVENTS SPECIFIC
   ========================================= */
.event-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 15px;
}

.event-card h3 {
    margin-top: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.private-badge {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    vertical-align: middle;
    margin-left: 8px;
}

.creator-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--input-border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.creator-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* =========================================
   REACTIONS & ATTENDEES
   ========================================= */
.reactions-container {
    margin-top: 20px;
    background-color: var(--input-bg);
    padding: 15px;
    border-radius: 8px;
}

.reaction-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

button.reaction-btn {
    flex: 0 0 auto;
    min-width: auto;
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
}

button.reaction-btn:hover {
    background-color: var(--input-bg);
    transform: scale(1.05);
}

button.reaction-btn.active {
    background-color: var(--input-bg);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Specific Colors for Reactions with dark mode compatibility */
button.reaction-btn.green { border-color: #22c55e; color: #166534; background: #dcfce7; }
body.dark-mode button.reaction-btn.green { background: #052e16; color: #4ade80; border-color: #166534; }

button.reaction-btn.yellow { border-color: #eab308; color: #854d0e; background: #fef9c3; }
body.dark-mode button.reaction-btn.yellow { background: #422006; color: #facc15; border-color: #a16207; }

button.reaction-btn.red { border-color: #ef4444; color: #991b1b; background: #fee2e2; }
body.dark-mode button.reaction-btn.red { background: #450a0a; color: #f87171; border-color: #991b1b; }

.attendees-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 10px;
    padding-left: 12px; /* Compensate for negative margin of items */
}

.attendee-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    transition: transform 0.2s, z-index 0.2s;
    margin-left: -12px; /* Strong overlap */
    z-index: 1;
}

/* Removed :first-child rule to ensure consistent alignment on wrap */

.attendee-wrapper:hover {
    transform: translateY(-5px) scale(1.1);
    z-index: 100;
}

.attendee-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-secondary); /* Separator */
    box-sizing: border-box; /* Ensure border is inside width/height */
}


/* =========================================
   REACTION SYSTEM (Modern)
   ========================================= */
.reaction-wrapper {
    position: relative;
    display: inline-block;
}

.reaction-trigger {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: none;
    width: auto;
    border-radius: 6px;
}

.reaction-trigger:hover {
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    transform: none;
    box-shadow: none;
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--input-border);
    border-radius: 50px;
    padding: 8px 12px;
    display: none; /* Hidden by default */
    gap: 8px;
    box-shadow: var(--card-hover-shadow);
    z-index: 100;
    margin-bottom: 10px;
    animation: fadeInUp 0.2s ease-out;
    white-space: nowrap;
}

.reaction-picker.show {
    display: flex;
}

.reaction-option {
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    min-width: auto;
    width: auto;
    line-height: 1;
}

.reaction-option:hover {
    transform: scale(1.3);
    background: none;
}

.reactions-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    margin-bottom: 5px;
    padding-top: 10px;
    border-top: 1px solid var(--input-border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.reaction-icons-group {
    display: flex;
    align-items: center;
}

.reaction-icon-small {
    font-size: 1.1rem;
    margin-right: -5px; /* Overlap effect */
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
    background: var(--bg-secondary);
    z-index: 1;
}

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

/* =========================================
   FORUM
   ========================================= */
/* Forum Category List */
.category-header { 
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover)); 
    color: white; 
    padding: 15px 25px; 
    font-size: 1.1em; 
    font-weight: 600; 
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.topic-list { list-style: none; padding: 0; margin: 0; }
.topic-item { 
    padding: 15px 25px; 
    border-bottom: 1px solid var(--input-border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    transition: background 0.2s; 
}
.topic-item:last-child { border-bottom: none; }
.topic-item:hover { background-color: var(--input-bg); }

.topic-title { 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: var(--text-primary); 
    text-decoration: none; 
    display: block; 
    margin-bottom: 5px; 
}
.topic-title:hover { color: var(--accent-color); }
.topic-meta { font-size: 0.85em; color: var(--text-secondary); }
.topic-stats { text-align: right; min-width: 120px; font-size: 0.85em; color: var(--text-secondary); }

/* Forum Posts */
.post { display: flex; overflow: hidden; padding: 0; }
.post-sidebar { 
    width: 150px; 
    background: var(--input-bg); 
    padding: 20px; 
    text-align: center; 
    border-right: 1px solid var(--input-border); 
    flex-shrink: 0;
}
.post-content { flex-grow: 1; padding: 20px; display: flex; flex-direction: column; }

.user-avatar { 
    width: 60px; height: 60px; 
    border-radius: 50%; 
    object-fit: cover; 
    margin-bottom: 10px; 
    background: var(--bg-secondary); 
    border: 2px solid var(--input-border);
}
.user-name { font-weight: bold; color: var(--text-primary); display: block; font-size: 0.9em; margin-bottom: 5px; }
.user-role { font-size: 0.75em; color: var(--text-secondary); background: var(--bg-secondary); padding: 2px 8px; border-radius: 10px; display: inline-block; border: 1px solid var(--input-border); }

.post-body { font-size: 1rem; line-height: 1.6; color: var(--text-primary); min-height: 80px; margin-bottom: 20px; }
.post-footer { 
    margin-top: auto; 
    padding-top: 15px; 
    border-top: 1px solid var(--input-border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap;
    gap: 10px;
}
.post-date { font-size: 0.8em; color: var(--text-secondary); }

/* BBCode & Reply */
.bbcode-toolbar {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-bottom: none;
    padding: 8px;
    border-radius: 8px 8px 0 0;
}

button.bbcode-btn {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    padding: 4px 10px;
    width: auto;
    font-size: 0.8rem;
    margin-right: 4px;
    box-shadow: none;
}

button.bbcode-btn:hover {
    background-color: var(--input-bg);
    transform: none;
}

#newTopicContent, #replyContent {
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-top: 0;
    min-height: 150px;
}

blockquote { border-left: 3px solid var(--accent-color); margin: 10px 0; padding-left: 15px; color: var(--text-secondary); background: var(--input-bg); padding: 10px; border-radius: 0 8px 8px 0; }
pre { background: var(--input-bg); padding: 15px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--input-border); }
code { font-family: monospace; background: rgba(128,128,128,0.1); padding: 2px 5px; border-radius: 4px; color: var(--accent-color); }

/* =========================================
   MODAL
   ========================================= */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(5px);
}

.modal-content { 
    background-color: var(--bg-secondary); 
    margin: 10% auto; 
    padding: 25px; 
    border: 1px solid var(--input-border); 
    width: 90%; 
    max-width: 600px; 
    border-radius: var(--border-radius); 
    box-shadow: var(--card-hover-shadow); 
    color: var(--text-primary);
}

.close { 
    color: var(--text-secondary); 
    float: right; 
    font-size: 28px; 
    font-weight: bold; 
    cursor: pointer; 
}

.close:hover { 
    color: var(--text-primary); 
}

/* =========================================
   NOTIFICATIONS & MESSAGING
   ========================================= */
.notification-container {
    position: relative;
    margin-right: 15px;
}

.notification-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    position: relative;
    padding: 5px;
    box-shadow: none;
    width: auto;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    display: none; /* Hidden by default */
}

.notification-dropdown {
    position: absolute;
    right: 0;
    top: 120%;
    width: 300px;
    background: var(--bg-secondary);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    box-shadow: var(--card-hover-shadow);
    display: none;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.notification-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.notification-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--input-border);
    cursor: pointer;
    transition: background 0.2s;
    word-break: break-word;
}

.notification-item:hover {
    background-color: var(--input-bg);
}

.notification-item.unread {
    background-color: rgba(59, 130, 246, 0.1); /* Light blue */
}

.notif-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.notif-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 4px;
}

/* Chat Styles */
.chat-container {
    display: flex;
    height: calc(100vh - 100px); /* Fallback */
    height: calc(100dvh - 100px); /* Dynamic Viewport Height for mobile */
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--input-border);
}

.chat-sidebar {
    width: 300px;
    background: var(--input-bg);
    border-right: 1px solid var(--input-border);
    display: flex;
    flex-direction: column;
}

.chat-search {
    padding: 15px;
    border-bottom: 1px solid var(--input-border);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px;
    border-bottom: 1px solid var(--input-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.conversation-item:hover, .conversation-item.active {
    background-color: rgba(128, 128, 128, 0.1);
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.conversation-info h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.conversation-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.chat-header {
    padding: 15px;
    border-bottom: 1px solid var(--input-border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.message-bubble.sent {
    align-self: flex-end;
    background-color: var(--accent-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.message-bubble.received {
    align-self: flex-start;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--input-border);
}

.message-time {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
    display: block;
}

.reaction-trigger-icon {
    position: absolute;
    right: 8px;
    bottom: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    background: var(--bg-secondary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--input-border);
}

.reaction-trigger-icon:hover {
    transform: scale(1.1);
    color: var(--accent-color);
}

.message-bubble:hover .reaction-trigger-icon {
    opacity: 1;
}

/* Always show on mobile/touch */
@media (hover: none) {
    .reaction-trigger-icon {
        opacity: 0.8;
    }
}

.chat-input-area {
    padding: 10px;
    border-top: 1px solid var(--input-border);
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    align-items: center;
}

.chat-input-area input[type="text"] {
    margin-bottom: 0; 
    flex: 1;
    padding: 10px;
    height: 40px; /* Fixed height for alignment */
}

.chat-input-area button {
    height: 40px; /* Match input height */
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto !important; /* Override global width:100% */
    flex: 0 0 auto;
}

#attachBtn {
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 80px);
        height: calc(100dvh - 80px);
        flex-direction: column;
    }
    .chat-sidebar {
        width: 100%;
        height: 100%; /* When no chat selected */
    }
    .chat-sidebar.hidden {
        display: none;
    }
    .chat-main {
        width: 100%;
        height: 100%;
    }
    .chat-main.hidden {
        display: none;
    }
}

.message { text-align: center; margin-top: 15px; font-weight: 600; }

/* =========================================
   MESSAGE LAYOUT (Rows & Avatars)
   ========================================= */

.message-row {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-end; /* Avatar at bottom */
}

.message-row.sent {
    justify-content: flex-end;
}

.message-row.received {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-avatar.sent {
    margin-right: 0;
    margin-left: 8px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    position: relative;
}

.message-row.sent .message-wrapper {
    align-items: flex-end;
}

.message-row.received .message-wrapper {
    align-items: flex-start;
}

.message-sender-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    margin-left: 5px;
}

.message-row.sent .message-sender-name {
    margin-left: 0;
    margin-right: 5px;
    text-align: right;
}

/* Update Bubble Styles */
.message-bubble {
    max-width: 100%; /* Wrapper handles width */
    padding: 10px 15px;
    border-radius: 18px; /* More rounded */
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-bubble.sent {
    background-color: var(--accent-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--input-border);
}

/* Reaction Trigger (Smiley) - Now outside bubble */
.reaction-trigger-icon {
    position: static; /* Flow naturally below bubble */
    margin-top: 2px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    cursor: pointer;
    background: none;
    border: none;
    box-shadow: none;
    width: auto;
    height: auto;
    opacity: 0.6;
    padding: 2px 5px;
    display: inline-block;
}

.reaction-trigger-icon:hover {
    opacity: 1;
    transform: scale(1.1);
    color: var(--accent-color);
}

/* Reaction Container (Badges inside bubble) */
.reaction-container {
    margin-top: 5px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 0.75rem;
}

.reaction-badge {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
}

.reaction-badge.mine {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}
.filters { display: flex; gap: 15px; margin-bottom: 25px; }

/* Profile Dropdown */
.profile-dropdown { 
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-avatar { 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    cursor: pointer; 
    object-fit: cover;
    background-color: var(--text-secondary); /* Fallback */
    border: 1px solid var(--nav-border);
}
.profile-menu {
    position: absolute;
    right: 0;
    top: 120%;
    background: var(--bg-secondary);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    box-shadow: var(--card-hover-shadow);
    width: 200px;
    display: none;
    overflow: hidden;
    z-index: 1000;
}
.profile-menu.show { display: block; animation: fadeIn 0.2s ease; }
.profile-menu a {
    display: block;
    padding: 12px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--input-border);
}
.profile-menu a:hover { background-color: var(--input-bg); }

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

@media (max-width: 600px) {
    .filters { flex-direction: column; gap: 10px; }
    .event-card { padding: 15px; }
    .event-card h3 { padding-right: 140px; } /* Prevent title overlapping absolute buttons */
    .post { flex-direction: column; }
    .post-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--input-border); display: flex; align-items: center; justify-content: flex-start; gap: 15px; padding: 15px; text-align: left; }
    .user-avatar { margin-bottom: 0; width: 40px; height: 40px; }
}
