/* current-user-navbar.css - Global Header, Icon Buttons, 3 Badges, and Master Notification Popover */

.user-info strong,
.user-info small,
#current-user-name,
#current-user-role {
    max-width: 140px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

.notification-badge[hidden] {
    display: none !important;
}

.dashboard-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding-block: 10px;
    background: #f4f6f8;
}

/* =========================================================
   1. UNIFIED GLOBAL HEADER ICON BUTTONS (Cart, Chat, Bell)
   ========================================================= */
.nav-actions .icon-btn,
.topbar-actions .icon-btn,
.cost-account-actions .icon-btn,
.report-account-actions .icon-btn {
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-grid !important;
    place-items: center !important;
    border-radius: 999px !important;
    border: 1px solid #e2e8e2 !important;
    background: #ffffff !important;
    color: #111827 !important;
    font-size: 18px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05) !important;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease !important;
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
}

.nav-actions .icon-btn:hover,
.topbar-actions .icon-btn:hover,
.cost-account-actions .icon-btn:hover,
.report-account-actions .icon-btn:hover {
    color: #ffffff !important;
    background: #111827 !important;
    border-color: #111827 !important;
    transform: translateY(-2px) !important;
}

.nav-actions .icon-btn:active,
.topbar-actions .icon-btn:active,
.cost-account-actions .icon-btn:active,
.report-account-actions .icon-btn:active {
    transform: translateY(0) scale(0.96) !important;
}

.nav-actions .icon-btn:focus-visible,
.topbar-actions .icon-btn:focus-visible,
.cost-account-actions .icon-btn:focus-visible,
.report-account-actions .icon-btn:focus-visible {
    outline: 2px solid #15803d !important;
    outline-offset: 2px !important;
}

.nav-actions .icon-btn > i,
.topbar-actions .icon-btn > i,
.cost-account-actions .icon-btn > i,
.report-account-actions .icon-btn > i {
    font-size: 18px !important;
    line-height: 1 !important;
    pointer-events: none !important;
    color: inherit !important;
}

/* =========================================================
   2. GLOBAL 3 BADGES SYSTEM (LOCKED POSITION & 99+ FORMAT)
   ========================================================= */
.icon-btn .notification-badge {
    position: absolute !important;
    top: -3px !important;
    right: -3px !important;
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ef4444 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    border-radius: 999px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    font-variant-numeric: tabular-nums !important;
    letter-spacing: -0.2px !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4) !important;
    pointer-events: none !important;
    z-index: 10 !important;
    user-select: none !important;
}

.icon-btn .notification-badge[hidden] {
    display: none !important;
}

/* =========================================================
   3. MASTER NOTIFICATION POPOVER (MATCH COST MASTER DESIGN)
   ========================================================= */
.notification-popover {
    position: fixed;
    top: 76px;
    right: 24px;
    z-index: 999999;
    width: min(390px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 96px));
    overflow: hidden;
    color: #1e2920;
    background: #ffffff;
    border: 1px solid #e2e8e2;
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(14, 28, 19, 0.16);
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    font-family: 'Prompt', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.notification-popover.show {
    display: flex !important;
    animation: notifSlideDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.notification-popover-header {
    padding: 14px 16px 11px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #e2e8e2;
    background: #ffffff;
    box-sizing: border-box;
    flex-shrink: 0;
}

.notification-header-titles h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
}

.notification-header-titles p {
    margin: 2px 0 0;
    color: #627267;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
}

.notification-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.notification-header-actions .mark-all-read-btn {
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 600;
    color: #15803d;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.notification-header-actions .mark-all-read-btn:hover {
    background: #f1f5f2;
    color: #0e5b29;
}

.notification-close-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: #4f5b54;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.notification-close-btn:hover {
    background: #f1f5f2;
    color: #111827;
}

.notification-popover-body {
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #ffffff;
}

.notification-popover-body::-webkit-scrollbar {
    width: 6px;
}

.notification-popover-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.notification-popover-item {
    width: 100%;
    padding: 13px 16px;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    gap: 10px;
    color: inherit;
    background: #ffffff;
    border: 0;
    border-bottom: 1px solid #edf0ed;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease, opacity 0.15s ease;
    outline: none;
}

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

.notification-popover-item:hover {
    background: #f7faf8;
}

.notification-popover-item:focus-visible {
    background: #f1f5f2;
    outline: 2px solid #15803d;
    outline-offset: -2px;
}

.notification-popover-item .notif-dot {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    background: #cbd5e1;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* 🟢 1. เมื่อยังไม่ได้กดดู (Unread): สีเขียว + พื้นหลังเขียวอ่อน */
.notification-popover-item.unread {
    background: #f4fbf6 !important;
}

.notification-popover-item.unread:hover {
    background: #eaf6ee !important;
}

.notification-popover-item.unread .notif-dot {
    background: #16a34a !important; /* จุดสีเขียวสด */
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
}

.notification-popover-item.unread .notification-item-title {
    color: #15803d !important; /* หัวข้อสีเขียวเข้มเด่นชัด */
    font-weight: 700;
}

.notification-popover-item.unread .notification-item-msg {
    color: #374151 !important;
}

/* ⚫ 2. เมื่อกดดูแล้ว (Read): เปลี่ยนเป็นสีเทา */
.notification-popover-item.is-read {
    background: #ffffff !important;
    opacity: 0.85;
}

.notification-popover-item.is-read:hover {
    background: #f8fafc !important;
    opacity: 1;
}

.notification-popover-item.is-read .notif-dot {
    background: #cbd5e1 !important; /* จุดสีเทา */
    box-shadow: none !important;
}

.notification-popover-item.is-read .notification-item-title {
    color: #64748b !important; /* หัวข้อสีเทา */
    font-weight: 600;
}

.notification-popover-item.is-read .notification-item-msg {
    color: #94a3b8 !important; /* ข้อความสีเทา */
}

.notification-item-content {
    min-width: 0;
    display: block;
}

.notification-item-content strong,
.notification-item-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    transition: color 0.15s ease;
}

.notification-item-content span,
.notification-item-msg {
    display: block;
    margin-top: 2px;
    color: #627267;
    font-size: 11px;
    line-height: 1.45;
    word-break: break-word;
    transition: color 0.15s ease;
}

.notification-item-time {
    color: #738078;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-top: 2px;
    margin-top: 0;
}

.notification-popover-empty {
    padding: 36px 20px;
    text-align: center;
    color: #627267;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.notification-popover-empty i {
    font-size: 28px;
    color: #94a3b8;
}

.notification-popover-empty strong {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.notification-popover-empty p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
}

/* =========================================================
   4. BACKDROP & RESPONSIVE BREAKPOINTS (MOBILE ENHANCED)
   ========================================================= */
.notification-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999998;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: none;
    pointer-events: none;
}

.notification-backdrop.show {
    display: block !important;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .notification-popover {
        top: 68px !important;
        right: 12px !important;
        left: 12px !important;
        width: calc(100vw - 24px) !important;
        max-width: none !important;
        max-height: calc(100dvh - 84px) !important;
        border-radius: 16px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    }

    .notification-popover-body {
        max-height: calc(100dvh - 160px);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

@media (max-width: 480px) {
    .nav-actions,
    .topbar-actions,
    .cost-account-actions,
    .report-account-actions {
        gap: 6px !important;
    }

    .nav-actions .icon-btn,
    .topbar-actions .icon-btn,
    .cost-account-actions .icon-btn,
    .report-account-actions .icon-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        font-size: 16px !important;
    }

    .nav-actions .icon-btn > i,
    .topbar-actions .icon-btn > i,
    .cost-account-actions .icon-btn > i,
    .report-account-actions .icon-btn > i {
        font-size: 16px !important;
    }

    .notification-popover {
        top: 62px !important;
        right: 8px !important;
        left: 8px !important;
        width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - 72px) !important;
        border-radius: 14px;
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25);
    }

    .notification-popover-header {
        padding: 12px 14px 10px;
    }

    .notification-header-titles h2 {
        font-size: 15px;
    }

    .notification-header-titles p {
        font-size: 11px;
    }

    .notification-header-actions .mark-all-read-btn {
        padding: 6px 8px;
        font-size: 11.5px;
    }

    .notification-close-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }

    .notification-popover-body {
        max-height: calc(100dvh - 145px);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .notification-popover-item {
        padding: 12px 14px;
        min-height: 48px;
        grid-template-columns: 8px minmax(0, 1fr) auto;
        gap: 10px;
    }

    .notification-item-content strong,
    .notification-item-title {
        font-size: 12.5px;
    }

    .notification-item-content span,
    .notification-item-msg {
        font-size: 11.5px;
    }

    .notification-item-time {
        font-size: 10.5px;
    }
}
