/* =================================================================
   SBM NOTIFICATION HUB (Holographic Style)
   ================================================================= */

/* 1. Nút Thông Báo (Chuông) - ĐÃ FIX LỆCH VÀ BADGE */
.sbm-notification-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 12px 0 0 !important; /* Cách nút giỏ hàng bên phải 12px */
    padding: 0 !important;
    height: 100% !important; /* Để tự động canh giữa theo trục dọc của header */
}

button#sbm-notification-button.sbm-notification-button {
    position: relative !important; /* [QUAN TRỌNG] Làm mốc tọa độ để chấm đỏ bám vào */
    background-color: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(4px);
    border: 1px solid #e5e7eb !important;
    color: #374151 !important;
    width: 40px !important;  /* Bằng chuẩn size nút giỏ hàng */
    height: 40px !important; 
    min-height: 40px !important; /* Chặn Flatsome kéo dài nút */
    border-radius: 50% !important;
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin: 0 !important; /* Tiêu diệt margin làm lệch nút */
    padding: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    top: 0 !important;
}

button#sbm-notification-button.sbm-notification-button:hover {
    background-color: #fff !important;
    transform: scale(1.1) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2) !important;
}

.sbm-notification-button svg {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    display: block !important;
}

/* Badge (Chấm đỏ) - Thiết kế dạng viên thuốc co giãn */
span#sbm-notification-count.sbm-notification-count {
    position: absolute !important; 
    top: -4px !important;    /* Ngóc lên khỏi viền nút một chút */
    right: -6px !important;  /* Chồm ra ngoài viền phải một chút */
    background-color: var(--sbm-primary-color, #ef4444) !important;
    color: white !important;
    font-size: 11px !important; 
    font-weight: bold !important;
    line-height: 1 !important;
    min-width: 20px !important; /* Tối thiểu bằng 1 hình tròn */
    height: 20px !important;
    padding: 0 5px !important; /* Đệm 2 bên để chứa số lớn như 29333 */
    border-radius: 10px !important; /* Bo viền thành hình viên thuốc */
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important;
    border: 2px solid #fff !important; /* Viền trắng tách biệt với nút */
    box-sizing: border-box !important;
    z-index: 10 !important;
    margin: 0 !important;
    transform: none !important;
    animation: sbm-bounce 1s infinite;
}

/* 2. Bảng Thông Báo (The Glass Panel) */
.sbm-notifications-panel {
    display: none;
    position: absolute;
    top: calc(100% + 15px);
    right: -10px; /* Căn phải so với nút chuông */
    width: 360px;
    
    /* GLASSMORPHISM */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    
    /* Shadow & Glow */
    box-shadow: 
        0 20px 50px rgba(0,0,0,0.15), 
        0 0 0 1px rgba(255,255,255,0.5) inset;
        
    z-index: 10000;
    overflow: hidden;
    transform-origin: top right;
    animation: notifUnfold 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sbm-notification-wrapper.is-active .sbm-notifications-panel {
    display: block;
}

/* Animation mở bảng */
@keyframes notifUnfold {
    from { opacity: 0; transform: scale(0.9) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* 3. Header & Footer */
.sbm-notifications-panel-header {
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: rgba(255,255,255,0.4);
}
.sbm-notifications-panel-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

/* 4. Dòng Thông Báo (Item) */
.sbm-notification-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
    
    /* Chuẩn bị cho animation bay vào */
    opacity: 0;
    animation: notifSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.sbm-notification-item:hover {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

/* Chấm xanh chưa đọc */
.sbm-notification-item:not(.is-read)::before {
    content: '';
    position: absolute;
    left: 8px; top: 18px;
    width: 8px; height: 8px;
    background: var(--sbm-primary-color, #ef4444);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--sbm-primary-color, #ef4444);
}
.sbm-notification-item:not(.is-read) {
    background: rgba(255, 255, 255, 0.4); 
    padding-left: 24px; 
}

.sbm-notification-item-title {
    font-size: 0.9rem;
    color: #374151;
    line-height: 1.4;
    flex-grow: 1;
}
.sbm-notification-item-time {
    font-size: 0.75rem;
    color: #9ca3af;
    white-space: nowrap;
    margin-top: 4px;
}

/* 5. Staggered Animation (Bay vào lần lượt) */
.sbm-notification-item:nth-child(1) { animation-delay: 0.05s; }
.sbm-notification-item:nth-child(2) { animation-delay: 0.1s; }
.sbm-notification-item:nth-child(3) { animation-delay: 0.15s; }
.sbm-notification-item:nth-child(4) { animation-delay: 0.2s; }
.sbm-notification-item:nth-child(5) { animation-delay: 0.25s; }
.sbm-notification-item:nth-child(n+6) { animation-delay: 0.3s; }

@keyframes notifSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes sbm-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Scrollbar đẹp */
.sbm-notifications-panel-body::-webkit-scrollbar { width: 4px; }
.sbm-notifications-panel-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1); border-radius: 10px;
}

/* Footer (Khu vực nút Đánh dấu đã đọc) */
.sbm-notifications-panel-footer {
    padding: 10px 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    text-align: center;
}

/* Style cho nút/link */
.sbm-notifications-panel-footer a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sbm-primary-color, #ef4444);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    background-color: transparent;
}

.sbm-notifications-panel-footer a:hover {
    background-color: rgba(239, 68, 68, 0.08); 
    transform: translateY(-1px); 
}

.sbm-notifications-panel-footer a::before {
    content: '✓';
    display: inline-block;
    font-weight: bold;
    font-size: 1rem;
}

/* === [FIX MOBILE] Căn giữa Popup Thông báo === */
@media (max-width: 768px) {
    .sbm-notifications-panel {
        position: fixed; 
        top: 80px;       
        left: 50%;       
        right: auto;     
        width: 94%;      
        max-width: 400px;
        
        animation: none; 
        opacity: 0;
        visibility: hidden;
        transform: translate(-50%, -10px); 
        transition: all 0.3s ease;
        max-height: 70vh;
    }

    .sbm-notification-wrapper.is-active .sbm-notifications-panel {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, 0);
    }
    
    .sbm-notifications-panel::before,
    .sbm-notifications-panel::after {
        display: none;
    }
}