/* Custom styles for the filter bar */
.notification-filters {
    overflow-x: auto; /* Makes it scrollable on small screens */
}

.notification-filters .nav-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    white-space: nowrap;
    position: relative;
}

.notification-filters .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* Badge styles */
.notification-filters .badge {
    margin-left: 5px;
    font-size: 0.75rem;
    vertical-align: middle;
}

/* RTL Badge adjustment */
html[dir="rtl"] .notification-filters .badge {
    margin-left: 0;
    margin-right: 5px;
}

/* Active state badge color adjustment */
.notification-filters .nav-link.active .badge {
    background-color: #fff !important;
    color: var(--primary-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .notification-filters .nav {
        flex-wrap: nowrap;
    }
}

/* Toast notification base styles */
.notification-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    background-color: var(--background-muted);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 4px;
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

/* RTL toast positioning */
html[dir="rtl"] .notification-toast {
    right: auto;
    left: 20px;
    border-left: none;
    border-right: 4px solid var(--primary-color);
    transform: translateX(-100%); /* Change transform direction for RTL */
}

.notification-toast.show {
    transform: translateX(0);
}

.notification-toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.notification-toast-header .close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

/* Adjust close button position for RTL */
html[dir="rtl"] .notification-toast-header {
    flex-direction: row-reverse;
}

.notification-toast-body {
    padding: 15px;
    text-align: left;
}

/* RTL text alignment in toast body */
html[dir="rtl"] .notification-toast-body {
    text-align: right;
}

.notification-item {
    padding: 10px 15px;
    border-bottom: 1px solid hsl(0, 0%, 91%);
    cursor: pointer;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: hwb(186 85% 0%);
}

/* RTL notification item border styling */
html[dir="rtl"] .notification-item {
    border-right: 3px solid transparent;
}

html[dir="rtl"] .notification-item.unread {
    border-right-color: var(--primary-color);
}

.notification-message {
    font-size: 14px;
    margin-bottom: 5px;
    text-align: left;
}

/* RTL notification message text alignment */
html[dir="rtl"] .notification-message {
    text-align: right;
}

.notification-time {
    font-size: 12px;
    color: #6c757d;
}

/* RTL time indicator positioning */
html[dir="rtl"] .notification-time {
    text-align: right;
}

.no-notifications {
    padding: 15px;
    text-align: center;
    color: #6c757d;
}

/* Message notification styles */
.notification-toast.message-notification {
    max-width: 350px;
}

.message-header {
    display: flex;
    align-items: center;
    background-color: var(--primary-color);
    color: white;
}

/* RTL message header */
html[dir="rtl"] .message-header {
    flex-direction: row-reverse;
}

.message-preview {
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: black;
    text-align: left;
}

/* RTL message preview */
html[dir="rtl"] .message-preview {
    text-align: right;
}

.message-actions {
    display: flex;
    justify-content: space-between;
    direction: ltr; /* Keep button order consistent */
}

/* RTL message actions */
html[dir="rtl"] .message-actions {
    direction: rtl;
}

.message-actions button {
    flex: 1;
    margin: 0 4px;
}

/* Adjust margins for RTL */
html[dir="rtl"] .message-actions button:first-child {
    margin-left: 4px;
    margin-right: 0;
}

html[dir="rtl"] .message-actions button:last-child {
    margin-left: 0;
    margin-right: 4px;
}

/* Dropdown notifications list RTL support */
html[dir="rtl"] .dropdown-menu-notifications {
    text-align: right;
}

/* Dropdown header RTL */
html[dir="rtl"] .dropdown-header {
    text-align: right;
}

/* Dropdown items RTL alignment */
html[dir="rtl"] .dropdown-item {
    text-align: right;
}

/* Notification badge positioning for RTL */
html[dir="rtl"] .nav-item .position-absolute {
    right: auto;
    left: 0;
}

/* Notification status indicator RTL */
html[dir="rtl"] .notification-status {
    padding-right: 15px;
    padding-left: 0;
    border-right: 3px solid var(--primary-color);
    border-left: 0;
    text-align: right;
}

/* Toast animation for RTL languages */
@keyframes toastInRTL {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes toastOutRTL {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

html[dir="rtl"] .notification-toast.show {
    animation: toastInRTL 0.3s forwards;
}

html[dir="rtl"] .notification-toast.hide {
    animation: toastOutRTL 0.3s forwards;
}

/* Multiple notification stacking for RTL */
html[dir="rtl"] .notification-toast:nth-child(1) {
    bottom: 20px;
}

html[dir="rtl"] .notification-toast:nth-child(2) {
    bottom: 90px;
}

html[dir="rtl"] .notification-toast:nth-child(3) {
    bottom: 160px;
}

/* Empty state notification RTL */
html[dir="rtl"] .empty-notification {
    text-align: right;
}

/* Make icons flip in RTL where needed */
html[dir="rtl"] .notification-toast .bi-arrow-right,
html[dir="rtl"] .notification-item .bi-arrow-right {
    transform: scaleX(-1);
}


/* ============= NOTIFICATIONS ============= */
.notifications-container {
    margin-top: 8px;
}

.notification-container {
    position: relative;
    z-index: 1000;
    margin: 0 5px;
}

.notification-toggle, .message-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    color: var(--text-overflow);
    padding: 0.4rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    position: relative;
}

.notification-toggle:hover, .message-toggle:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    color: var(--text-color);
}

.notification-toggle i, .message-toggle i {
    font-size: 1.2rem;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: var(--text-color);
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px var(--box-shadow);
    padding: 0 4px;
    z-index: 1001;
}

.notification-badge[style*="display: none"],
.notification-badge:empty {
    display: none !important;
}

.notification-badge.new {
    animation: pulse 1.5s infinite;
}

.message-badge {
    background: #2ecc71; /* Green for messages */
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}
/* Notification dropdown - Enhanced */
.notification-preview {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: 320px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: var(--transition);
    overflow: hidden;
    border: 1px solid var(--border-color);
    z-index: 1050;
}

/* RTL support for notification dropdown positioning */
html[dir="rtl"] .notification-preview {
    right: auto;
    left: 0;
}

.notification-preview.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    animation: dropdownFadeIn 0.3s ease forwards;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 2;
}

.notification-header h6 {
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.view-all {
    font-size: 0.8rem;
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.view-all:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.notification-items {
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) var(--background-muted);
}

/* Custom scrollbar for Webkit browsers */
.notification-items::-webkit-scrollbar {
    width: 6px;
}

.notification-items::-webkit-scrollbar-track {
    background: var(--background-muted);
}

.notification-items::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 6px;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    background: var(--notification-bg, var(--card-bg));
    position: relative;
}

.notification-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

html[dir="rtl"] .notification-item::before {
    left: auto;
    right: 0;
}

.notification-item:hover {
    background: var(--notification-hover, var(--background-muted));
}

.notification-item:hover::before {
    background-color: var(--primary-light);
}

.notification-item:active {
    transform: scale(0.98);
}

.notification-item.unread {
    background: var(--notification-unread, rgba(0, 128, 128, 0.08));
}

.notification-item.unread::before {
    background-color: var(--primary-color);
}

.notification-item.unread:hover {
    background: var(--notification-unread-hover, rgba(0, 128, 128, 0.12));
}

.notification-content {
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.4;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
}

.notification-time i {
    font-size: 0.7rem;
    margin-right: 4px;
}

html[dir="rtl"] .notification-time i {
    margin-right: 0;
    margin-left: 4px;
}

.notification-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.notification-loading .spinner-border {
    color: var(--primary-color);
    width: 1.5rem;
    height: 1.5rem;
}

.no-notifications {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-notifications i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

/* Animation for new notifications */
@keyframes newNotificationPulse {
    0% { background-color: var(--primary-light); }
    50% { background-color: rgba(0, 128, 128, 0.2); }
    100% { background-color: var(--notification-unread, rgba(0, 128, 128, 0.08)); }
}

.notification-item.new-notification {
    animation: newNotificationPulse 1.5s ease-in-out;
}

/* Notification footer */
.notification-footer {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    background: var(--card-bg);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .notification-preview {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        transform: translateY(100%);
        max-height: 75vh;
        display: flex;
        flex-direction: column;
    }
    
    .notification-preview.show {
        transform: translateY(0);
    }
    
    .notification-items {
        flex: 1;
        max-height: none;
    }
}

/* Improved notification positioning */
#notification-preview,
#message-preview {
    position: fixed;
    top: 70px; /* Position below top navbar */
    right: 20px;
    width: 320px;
    z-index: 1050;
    transform: translateY(0) !important; /* Override any transform that might conflict */
}

/* Trigger from desktop navbar */
#notification-preview.desktop-trigger,
#message-preview.desktop-trigger {
    top: 70px !important; /* Just below top navbar */
    right: 20px;
    left: auto;
}
/* RTL Desktop notification preview positioning */
html[dir="rtl"] #notification-preview,
html[dir="rtl"] #message-preview {
    right: auto !important;
    left: 20px !important;
    transform: translateY(0) !important;
}

/* RTL specific positioning when triggered from desktop navbar */
html[dir="rtl"] #notification-preview.desktop-trigger,
html[dir="rtl"] #message-preview.desktop-trigger {
    top: 70px !important;
    right: auto !important;
    left: 20px !important;
}

/* Ensure directional elements are properly flipped in notification items */
html[dir="rtl"] .notification-item {
    text-align: right;
}

html[dir="rtl"] .notification-item .d-flex {
    flex-direction: row-reverse;
}

html[dir="rtl"] .notification-icon {
    margin-left: 10px;
    margin-right: 0;
}

html[dir="rtl"] .notification-content {
    text-align: right;
}

/* Ensure RTL scrollbars position correctly */
html[dir="rtl"] .notification-items::-webkit-scrollbar {
    left: 0;
    right: auto;
}

/* Consolidated mobile notification panel styles */
.mobile-notification-panel {
    position: fixed !important;
    top: var(--mobile-header-height, 60px) !important;
    width: 100% !important;
    height: calc(100% - var(--mobile-header-height, 60px)) !important;
    background-color: var(--background-color) !important;
    z-index: 1060 !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    transition: right 0.3s ease-in-out, left 0.3s ease-in-out !important;
    right: -100% !important;
    left: auto !important;
    overflow: hidden;
}

.mobile-notification-panel.show {
    right: 0 !important;
    visibility: visible !important;
}

.mobile-notification-header {
    padding: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.mobile-notification-items {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* RTL Mobile Panel Positioning */
html[dir="rtl"] .mobile-notification-panel {
    right: auto !important;
    left: -100% !important;
}

html[dir="rtl"] .mobile-notification-panel.show {
    right: auto !important;
    left: 0 !important;
}

/* RTL Message Preview Content */
html[dir="rtl"] .message-preview {
    text-align: right !important;
}

html[dir="rtl"] .message-content {
    text-align: right !important;
}

html[dir="rtl"] .message-sender {
    text-align: right !important;
}

html[dir="rtl"] .message-time {
    text-align: right !important;
}

/* RTL Message Item Layout */
html[dir="rtl"] .message-item {
    text-align: right !important;
}

html[dir="rtl"] .message-item .d-flex {
    flex-direction: row-reverse !important;
}

html[dir="rtl"] .message-icon {
    margin-left: 10px !important;
    margin-right: 0 !important;
}

/* RTL Mobile Header Adjustments */
html[dir="rtl"] .mobile-notification-header {
    flex-direction: row-reverse !important;
}

html[dir="rtl"] .mobile-notification-header h6 {
    text-align: right !important;
}

/* RTL Mobile Message Panel Specific */
html[dir="rtl"] #mobile-message-panel .notification-item,
html[dir="rtl"] #mobile-message-panel .message-item {
    text-align: right !important;
    direction: rtl !important;
}

html[dir="rtl"] #mobile-message-panel .notification-icon,
html[dir="rtl"] #mobile-message-panel .message-icon {
    margin-right: 0 !important;
    margin-left: 10px !important;
}

/* Enhanced RTL support for mobile message preview */

/* Mobile message panel specific RTL positioning */
html[dir="rtl"] #mobile-message-panel {
    right: auto !important; 
    left: -100% !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease, left 0.3s ease !important;
}

html[dir="rtl"] #mobile-message-panel.show {
    right: auto !important;
    left: 0 !important;
    transform: translateX(0) !important;
}

/* Message preview items RTL layout fixes */
html[dir="rtl"] #mobile-message-items .message-item {
    text-align: right !important;
    direction: rtl !important;
    padding-right: 15px !important;
    padding-left: 10px !important;
}

html[dir="rtl"] #mobile-message-items .message-content {
    text-align: right !important;
    direction: rtl !important;
}

/* Message preview content alignment in RTL */
html[dir="rtl"] #mobile-message-items .message-sender {
    text-align: right !important;
}

html[dir="rtl"] #mobile-message-items .message-preview {
    text-align: right !important;
}

html[dir="rtl"] #mobile-message-items .message-time {
    text-align: right !important;
    flex-direction: row-reverse !important;
}

/* Message action buttons in RTL */
html[dir="rtl"] #mobile-message-items .message-actions {
    flex-direction: row-reverse !important;
}

/* Message item layout in RTL */
html[dir="rtl"] #mobile-message-items .d-flex {
    flex-direction: row-reverse !important;
}

/* Fix message avatar/icon position in RTL */
html[dir="rtl"] #mobile-message-items .message-avatar,
html[dir="rtl"] #mobile-message-items .message-icon {
    margin-right: 0 !important;
    margin-left: 12px !important;
}

/* RTL scrollbar for mobile message items */
html[dir="rtl"] #mobile-message-items::-webkit-scrollbar {
    left: 0;
    right: auto;
}

/* Fix any directional icons in message items */
html[dir="rtl"] #mobile-message-items .bi-arrow-right,
html[dir="rtl"] #mobile-message-items .fa-arrow-right {
    transform: scaleX(-1) !important;
}
