/* =============================================================
   ระบบแจ้งเตือนในเว็บ (Bell Notification)
   ============================================================= */

/* ---------- หน้า Bookmark: กรอบเหลือง + N เมื่อมีตอนใหม่ยังไม่ได้อ่าน ---------- */
/* ใช้ box-shadow inset เพราะ .block2 ตั้ง overflow:hidden ไว้ (กรอบนอกจะโดนตัด) */
.block2-pic { position: relative; }
.block2.bm-updated .block2-pic {
    box-shadow: inset 0 0 0 3px #ffd21e;
}
.block2.bm-updated .block2-pic::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 14px rgba(255, 210, 30, 0.55);
    pointer-events: none;
}
.bm-n {
    position: absolute;
    left: 8px;
    top: 8px;
    z-index: 4;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffd21e;
    color: #1a1a1a;
    font-weight: 800;
    font-size: 16px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    font-family: 'Roboto', sans-serif;
    animation: bm-n-pop 0.3s ease;
}
@keyframes bm-n-pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

#notification-bell-wrapper {
    position: relative;
    margin-right: 18px;
    display: inline-block;
}

#notification-bell-btn {
    position: relative;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}
#notification-bell-btn:hover {
    background: rgba(142, 68, 173, 0.12);
}
#notification-bell-btn i {
    font-size: 19px;
    color: var(--primary-color, #8e44ad);
}
/* สั่นเบาๆ เมื่อมีของใหม่ */
#notification-bell-btn.has-new i {
    animation: notif-bell-shake 1.6s ease-in-out infinite;
    transform-origin: top center;
}
@keyframes notif-bell-shake {
    0%, 70%, 100% { transform: rotate(0); }
    75% { transform: rotate(12deg); }
    80% { transform: rotate(-10deg); }
    85% { transform: rotate(8deg); }
    90% { transform: rotate(-6deg); }
    95% { transform: rotate(3deg); }
}

/* ตัวเลขแจ้งเตือน */
#notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ff3b3b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
    font-family: 'Mali', cursive;
}

/* กล่อง dropdown — light theme (default) */
#notification-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 330px;
    max-width: 86vw;
    background: rgba(255, 192, 203, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(242, 127, 181, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 2000;
    overflow: hidden;
    font-family: 'Mali', cursive;
}
#notification-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* dark theme */
.dark-theme #notification-dropdown {
    background: rgba(255, 192, 203, 0.08);
    border-color: rgba(255, 182, 193, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 192, 203, 0.08);
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(180, 60, 110, 0.15);
}
.dark-theme .notif-header { border-bottom-color: rgba(255, 255, 255, 0.08); }

.notif-header span {
    color: #3d1a5c;
    font-weight: 600;
    font-size: 15px;
}
.dark-theme .notif-header span { color: #f9d0e8; }

#notif-mark-all {
    background: none;
    border: none;
    color: #8e44ad;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-family: 'Mali', cursive;
    transition: background 0.2s ease;
}
#notif-mark-all:hover { background: rgba(142, 68, 173, 0.12); }
.dark-theme #notif-mark-all { color: #b388ff; }
.dark-theme #notif-mark-all:hover { background: rgba(179, 136, 255, 0.15); }

/* แท็บแยกประเภท: อัพเดทนิยาย / ข้อความ */
.notif-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(180, 60, 110, 0.15);
}
.dark-theme .notif-tabs { border-bottom-color: rgba(255, 255, 255, 0.08); }

.notif-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px 8px;
    border-radius: 8px;
    font-family: 'Mali', cursive;
    font-size: 13px;
    font-weight: 600;
    color: #6b4f80;
    transition: background 0.2s ease, color 0.2s ease;
}
.notif-tab:hover { background: rgba(142, 68, 173, 0.1); }
.notif-tab.active { background: rgba(142, 68, 173, 0.16); color: #8e44ad; }
.dark-theme .notif-tab { color: #aa9ec9; }
.dark-theme .notif-tab:hover { background: rgba(179, 136, 255, 0.12); }
.dark-theme .notif-tab.active { background: rgba(179, 136, 255, 0.18); color: #d8c5ff; }

/* ตัวเลขแจ้งเตือนบนแท็บ — โชว์เฉพาะตอนมีของใหม่ */
.notif-tab-badge {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    background: #ff3b3b;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
}
.notif-tab-badge.show { display: inline-flex; }

/* รายการ — สูงพอดี 4 แถว (แถวละ ~80px) ที่เหลือเลื่อนดู */
.notif-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: none;
}
.notif-list::-webkit-scrollbar { display: none; }

.notif-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    text-decoration: none;
    border-bottom: 1px solid rgba(180, 60, 110, 0.1);
    transition: background 0.2s ease;
    position: relative;
}
.dark-theme .notif-item { border-bottom-color: rgba(255, 255, 255, 0.05); }

.notif-item:hover { background: rgba(255, 150, 180, 0.18); }
.notif-item.is-new { background: rgba(255, 130, 170, 0.15); }
.notif-item.is-new:hover { background: rgba(255, 130, 170, 0.25); }

/* อ่านแล้ว: ประวัติยังอยู่ แค่หม่นแสงลง */
.notif-item.is-read { opacity: 0.5; }
.notif-item.is-read:hover { opacity: 0.85; }

.dark-theme .notif-item:hover { background: rgba(255, 255, 255, 0.05); }
.dark-theme .notif-item.is-new { background: rgba(142, 68, 173, 0.14); }
.dark-theme .notif-item.is-new:hover { background: rgba(142, 68, 173, 0.22); }

.notif-item img {
    width: 44px;
    height: 58px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #ffe3ee;
}
.dark-theme .notif-item img { background: #2a2440; }

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

.notif-title {
    color: #3d1a5c;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark-theme .notif-title { color: #fff; }

.notif-time {
    color: #6b4f80;
    font-size: 12px;
    margin-top: 3px;
}
.dark-theme .notif-time { color: #aa9ec9; }
.notif-time i { color: #d4770a; margin-right: 3px; }
.dark-theme .notif-time i { color: #ffb300; }

/* จุดแดงบอกเรื่องใหม่ */
.notif-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #e0335a;
    flex-shrink: 0;
}
.dark-theme .notif-dot { background: #ff3b3b; }

.notif-empty {
    padding: 26px 15px;
    text-align: center;
    color: #7a5a8a;
    font-size: 14px;
}

/* Chat reply notification rows */
.notif-chat-row {
    gap: 10px;
    cursor: pointer;
}
.notif-chat-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(125, 82, 244, 0.3);
}
.notif-chat-row .notif-meta {
    flex: 1;
    min-width: 0;
}
.notif-chat-row .notif-title {
    font-size: 13px;
    color: #3d1a5c;
}
.dark-theme .notif-chat-row .notif-title { color: #ddc6ff; }
.notif-chat-row.is-new {
    background: rgba(125, 82, 244, 0.08);
    border-bottom: 1px solid rgba(125, 82, 244, 0.12);
}
.dark-theme .notif-chat-row.is-new {
    background: rgba(125, 82, 244, 0.12);
}
.dark-theme .notif-empty { color: #aa9ec9; }

@media (max-width: 575px) {
    #notification-bell-wrapper { margin-right: 12px; }
    #notification-dropdown { width: 290px; }
}
