/* Notification Styles */
#notificationBtn {
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

#notificationBtn:hover {
    transform: scale(1.1);
}

.position-relative {
    position: relative;
}

#notificationDropdown {
    border-radius: 12px !important;
    margin-top: 0.5rem !important;
    left: 0 !important;
    width: 350px !important;
    max-width: calc(100vw - 20px) !important;
    max-height: 500px !important;
    overflow-y: auto !important;
    position: absolute !important;
    top: 100% !important;
    transform: none !important;
    z-index: 1050 !important;
    background: white !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

/* Desktop RTL alignment: respect dropdown-menu-end */
/* @media (min-width: 769px) {
    [dir="rtl"] #notificationDropdown {
        right: 0 !important;
        left: auto !important;
    }
} */

.notification-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: #e3f2fd;
}

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

.notification-title {
    font-weight: 600;
    font-size: 14px;
    color: #212121;
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-message {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.5;
    word-wrap: break-word;
}

.notification-time {
    font-size: 11px;
    color: #999;
}

.notification-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Tablet and Mobile Responsive Styles */
/* @media (max-width: 991px) {
    #notificationDropdown {
        max-width: calc(100vw - 40px) !important;
        width: calc(100vw - 40px) !important;
    }
} */

@media (max-width: 768px) {

    .header-icons,
    .d-flex.align-items-center.gap-3 {
        position: relative;
    }

    #notificationDropdown {
        width: calc(100vw - 30px) !important;
        max-width: calc(100vw - 30px) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        max-height: 70vh !important;
        margin-top: 8px !important;
        top: 100% !important;
        position: absolute !important;
        overflow-x: hidden !important;
        border-radius: 15px !important;
    }

    #notificationDropdown .d-flex .d-flex {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 8px !important;
    }

    #notificationDropdown #notificationCloseBtn {
        order: -1;
    }

    [dir="rtl"] #notificationDropdown {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    .notification-item {
        padding: 10px;
    }

    .notification-title {
        font-size: 13px;
    }

    .notification-message {
        font-size: 12px;
    }

    .notification-time {
        font-size: 10px;
    }

    .notification-icon-small {
        width: 28px;
        height: 28px;
        margin-left: 10px;
    }

    .notification-icon-small i {
        font-size: 12px;
    }

    #notificationDropdown .border-top {
        padding: 8px !important;
    }

    #notificationDropdown .border-top a {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    #notificationDropdown {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        max-height: 65vh !important;
        margin-top: 5px !important;
        top: 100% !important;
        border-radius: 12px !important;
        position: absolute !important;
        overflow-x: hidden !important;
    }

    [dir="rtl"] #notificationDropdown {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    .position-relative {
        position: relative;
    }

    #notificationDropdown .d-flex {
        padding: 12px 15px !important;
        flex-wrap: nowrap;
    }

    #notificationDropdown .d-flex .d-flex {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 6px !important;
    }

    #notificationDropdown #notificationCloseBtn {
        order: -1;
    }

    #notificationDropdown h6 {
        font-size: 0.95rem;
        margin-bottom: 0;
    }

    #notificationDropdown .btn-sm {
        font-size: 0.75rem;
        padding: 4px 8px;
        white-space: nowrap;
    }

    #notificationDropdown small {
        font-size: 0.7rem;
    }

    #notificationDropdown #notificationList {
        padding: 8px !important;
        max-height: calc(65vh - 120px);
        overflow-y: auto;
    }

    #notificationDropdown .border-top {
        padding: 6px !important;
    }

    #notificationDropdown .border-top a {
        font-size: 0.8rem;
    }

    .notification-item {
        padding: 8px;
    }

    .notification-title {
        font-size: 12px;
    }

    .notification-message {
        font-size: 11px;
    }

    .notification-time {
        font-size: 9px;
    }

    .notification-icon-small {
        width: 24px;
        height: 24px;
        margin-left: 8px;
    }

    .notification-icon-small i {
        font-size: 11px;
    }

    .notification-empty {
        padding: 30px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    #notificationDropdown {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: 60vh !important;
        border-radius: 10px !important;
        top: 100% !important;
        transform: translateX(-50%) !important;
        position: absolute !important;
    }

    #notificationDropdown .d-flex {
        padding: 10px 12px !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0;
    }

    #notificationDropdown .d-flex .d-flex {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 4px !important;
    }

    #notificationDropdown h6 {
        font-size: 0.9rem;
    }

    #notificationDropdown .btn-sm {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    #notificationDropdown #notificationCloseBtn {
        order: -1;
        margin-bottom: 4px;
    }

    #notificationDropdown #notificationList {
        max-height: calc(60vh - 110px);
        padding: 6px !important;
    }

    .notification-item {
        padding: 6px;
    }
}

/* Improved notification item in dropdown */
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-bottom: none;
    border-radius: 14px;
    margin: 8px;
    border: 1px solid rgba(39, 58, 65, 0.08);
    background: #fff;
}

.notification-item.unread {
    background: rgba(33, 150, 243, 0.08);
    border-color: rgba(33, 150, 243, 0.22);
    border-right: 4px solid rgba(33, 150, 243, 0.85);
}

.notification-body {
    min-width: 0;
}

.notification-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.notification-title {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-message {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.notification-time {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.notification-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0d6efd;
    flex: 0 0 auto;
}

.notification-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    flex-shrink: 0;
}

.notification-icon-small.login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.notification-icon-small.user-plus {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.notification-icon-small.edit {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.notification-icon-small.check-circle {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.notification-icon-small.x-circle {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.notification-icon-small.bell {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.notification-icon-small i {
    font-size: 14px;
    color: white;
}

/* Close Button Styles */
#notificationCloseBtn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    border-radius: 50%;
}

#notificationCloseBtn:hover {
    color: #333;
    background-color: #f0f0f0;
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    #notificationCloseBtn {
        font-size: 1.3rem;
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 576px) {
    #notificationCloseBtn {
        font-size: 1.2rem;
        width: 26px;
        height: 26px;
    }
}

/* Overlay Background for all screens */
.notification-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notification-overlay.show {
    display: block;
    opacity: 1;
}

/* Apply overlay and scroll lock to all screens when notification is open */
body.notification-open {
    overflow: hidden;
}

#notificationDropdown {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
}

/* Fix for RTL on mobile */
@media (max-width: 576px) {
    [dir="rtl"] #notificationDropdown {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
}

/* Mobile: render dropdown as a fixed sheet so it never clips */
@media (max-width: 768px) {
    #notificationDropdown {
        position: fixed !important;
        top: calc(env(safe-area-inset-top, 0px) + 72px) !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: none !important;
        margin-top: 0 !important;
        transform: none !important;
        max-height: calc(100vh - (env(safe-area-inset-top, 0px) + 84px) - env(safe-area-inset-bottom, 0px)) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}

/* --- Custom Notification Popup Styles (Orange Bell) - From AdminDashboard --- */
.notif-popup {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    width: 380px;
    max-width: calc(100vw - 24px);
    max-height: 520px;
    overflow: hidden;
    z-index: 9999;
    padding: 0;
    direction: rtl;
    display: none;
    /* Changed from opacity/visibility for simple JS toggle, or keep show class logic */
}

/* Use .show class for transitions if needed, but JS often toggles display. 
   Keeping AdminDashboard logic: it uses display:none in HTML and toggles it. 
   We will add a class-based transition if we want, but let's match the existing CSS structure. 
*/
.notif-popup.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notif-popup-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.notif-popup h6 {
    font-weight: 800;
    color: rgba(39, 58, 65, 1);
    margin: 0;
}

.notif-popup-body {
    padding: 8px;
    max-height: 380px;
    overflow: auto;
}

.notif-popup .show-all {
    display: block;
    text-align: center;
    padding: 12px 10px;
    color: #b7924f;
    text-decoration: none;
    font-weight: 700;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.notif-popup .show-all:hover {
    color: #9f7a35;
}

.notif-empty {
    text-align: center;
    color: #999;
    padding: 22px 14px;
    font-size: 14px;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 14px;
    border: 1px solid rgba(39, 58, 65, 0.08);
    background: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
        background 0.15s ease, border-color 0.15s ease;
    margin: 8px;
}

.notif-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(8, 15, 52, 0.12);
    border-color: rgba(183, 146, 79, 0.22);
}

.notif-item--unread {
    background: rgba(33, 150, 243, 0.06);
    border-color: rgba(33, 150, 243, 0.18);
    border-right: 4px solid rgba(33, 150, 243, 0.85);
}

.notif-iconbox {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: rgba(183, 146, 79, 0.12);
    color: rgba(39, 58, 65, 1);
}

.notif-body {
    min-width: 0;
    flex: 1;
}

.notif-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.notif-title {
    font-weight: 800;
    color: rgba(39, 58, 65, 1);
    font-size: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-time {
    font-size: 11px;
    color: #8b8b8b;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notif-message {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* Mobile responsive for custom popup */
@media (max-width: 768px) {
    .notif-popup {
        position: fixed;
        top: 76px !important;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        transform: none !important;
        max-height: calc(100vh - 88px);
    }

    .notif-popup-body {
        max-height: calc(100vh - 180px);
    }
}