/*
 * Notification dropdown styles (#656)
 * Design source: _documentation/ticket_docs/656_notifications_tweaks_1/figma-export
 * Colors: blue #1565C0 (info), amber #DB5F00 (action required),
 *         purple #AB47BC (waiting), green #36873A (completed),
 *         unread dot #0663CD
 */

/* ------ Bell button (styled like the account selector: white, subtle shadow) ------ */
.notif-bell-btn {
    width: 42px;
    height: 42px;
    margin-right: 15px;
    background-color: #fff;
    border: 1px solid #e5e8eb;
    color: #1f3f5f;   /* FlexUp dark blue */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.notif-bell-btn:hover {
    background-color: #f5f5fa;
    color: #1f3f5f;
}

.notif-bell-btn i {
    line-height: 1;
}

.notif-bell-badge {
    display: none;
    font-size: 0.6rem;
    padding: 2px 4px;
    top: -4px;
    right: -4px;
    min-width: 14px;
    min-height: 14px;
    z-index: 2;
}

/* Note: no 'position' override here - Bootstrap/Popper positions the dropdown menu
   (its .dropdown-menu absolute positioning also anchors the legend and tooltip). */
#notification-container {
    width: 420px;
    max-width: 95vw;
    z-index: 1060;
    border-radius: 12px;
    overflow: hidden;
}

/* ------ Header ------ */
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e8eb;
    background-color: #fff;
}

.notif-title {
    font-size: 17px;
    font-weight: 700;
    color: #1f3f5f;
}

.notif-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notif-link-btn {
    border: none;
    background: none;
    padding: 0;
    font-size: 13px;
    color: #586d7d;
    cursor: pointer;
}

.notif-link-btn:hover {
    color: #1f3f5f;
}

.notif-link-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.notif-info-btn {
    border: none;
    background: none;
    padding: 0;
    font-size: 16px;
    color: #586d7d;
    cursor: pointer;
    line-height: 1;
}

.notif-info-btn:hover {
    color: #1f3f5f;
}

/* ------ Color legend popup ------ */
.notif-legend {
    position: absolute;
    top: 42px;
    right: 8px;
    z-index: 10;
    background-color: #f2f3f5;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    padding: 10px 14px;
    font-size: 13px;
    color: #1e262c;
    max-width: 320px;
}

.notif-legend-title {
    font-weight: 600;
    color: #3d4c57;
    margin-bottom: 6px;
}

.notif-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    /* Rows double as color filters (#656) */
    border: none;
    background: none;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 13px;
    color: #1e262c;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.notif-legend-row:hover {
    background-color: #e4e7ea;
}

.notif-legend-row.active {
    background-color: #fff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px #cdd2d6;
}

.notif-legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

.notif-swatch-info { background-color: #1565C0; }
.notif-swatch-action { background-color: #DB5F00; }
.notif-swatch-waiting { background-color: #AB47BC; }
.notif-swatch-completed { background-color: #36873A; }

.notif-legend-hint {
    margin-top: 8px;
    padding: 6px 8px;
    background-color: #fff;
    border-radius: 6px;
    color: #3d4c57;
    font-style: italic;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ------ Tabs + type filter ------ */
.notif-tabs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    border-bottom: 1px solid #e5e8eb;
    background-color: #fff;
}

.notif-tabs {
    display: flex;
    gap: 4px;
}

.notif-tab {
    border: none;
    background: none;
    padding: 8px 12px;
    font-size: 14px;
    color: #586d7d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.notif-tab:hover {
    color: #1f3f5f;
}

.notif-tab.active {
    color: #1f3f5f;
    font-weight: 600;
    border-bottom-color: #1f3f5f;
}

.notif-tab .notif-tab-count {
    font-size: 12px;
    color: #fff;
    background-color: #0663CD;
    border-radius: 8px;
    padding: 0 5px;
    margin-left: 3px;
}

.notif-type-filter {
    width: auto;
    max-width: 150px;
    font-size: 13px;
    margin: 4px 0;
}

/* ------ List ------ */
.notif-list {
    /* Fit below the fixed navbar even on short screens, so the dropdown never flips above it */
    max-height: min(420px, calc(100vh - 250px));
    /* Never show a horizontal scroll bar: long text is trimmed with an ellipsis,
       the full details are available in the notification popup (#656) */
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 250px;
}

.notif-skeleton-avatar {
    width: 40px;
    height: 40px;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e8eb;
    transition: background-color 0.2s;
    cursor: pointer;
}

.notif-item.unread {
    background-color: #f4f7fb;
}

.notif-item:hover {
    background-color: #eef2f7;
}

.notif-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #0663CD;
    margin-top: 20px;
    flex-shrink: 0;
}

.notif-unread-dot.read {
    background-color: transparent;
}

/* Avatar + action icon badge */
.notif-avatar-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.notif-avatar-wrap.clickable {
    cursor: pointer;
}

.notif-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #f0f0f0;
}

.notif-action-icon {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    box-shadow: 1px 2px 2px 0 rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* Details block */
.notif-details {
    flex-grow: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 14px;
    color: #2f3a42;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-title .notif-actor {
    font-weight: 700;
    color: #1e262c;
}

.notif-item-title .notif-actor.clickable {
    cursor: pointer;
    text-decoration: none !important;
}

.notif-item-title .notif-actor.clickable:hover {
    text-decoration: underline !important;
}

.notif-item-detail {
    font-size: 13px;
    color: #4c5f6d;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px solid #edf0f2;
}

.notif-item-time {
    font-size: 12px;
    color: #586d7d;
}

.notif-item-buttons {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
}

.notif-show-link {
    color: #3d4c57;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.notif-show-link:hover {
    color: #1f3f5f;
    text-decoration: underline;
}

.notif-item-buttons .notif-dot-sep {
    color: #cdd2d6;
}

.notif-btn {
    border: none;
    background: none;
    padding: 0;
    font-size: 14px;
    color: #586d7d;
    cursor: pointer;
    line-height: 1;
}

.notif-btn:hover {
    color: #1f3f5f;
}

.notif-empty {
    padding: 24px;
    text-align: center;
    color: #586d7d;
    font-size: 14px;
}

/* ------ Footer ------ */
.notif-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-top: 1px solid #e5e8eb;
    background-color: #fff;
}

.notif-footer-count {
    font-size: 13px;
    color: #586d7d;
}

.notif-footer-link {
    font-size: 13px;
    font-weight: 600;
    color: #0663CD;
    text-decoration: none;
}

.notif-footer-link:hover {
    text-decoration: underline;
}

/* ------ Icon tooltip ------ */
.notif-tooltip {
    position: absolute;
    z-index: 20;
    background-color: #f2f3f5;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    font-size: 13px;
    color: #1e262c;
    max-width: 240px;
    pointer-events: none;
}

.notif-tooltip .notif-tooltip-status {
    display: block;
    font-size: 12px;
    color: #586d7d;
    font-style: italic;
}

/* ------ Notification detail popup ------ */
.notif-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: rgba(30, 38, 44, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.notif-popup-card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    padding: 16px;
    width: 100%;
    max-width: 360px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;   /* wrap text, never show a horizontal scroll bar */
    position: relative;
}

.notif-popup-card * {
    overflow-wrap: anywhere;   /* long labels and emoji strings wrap instead of overflowing */
    white-space: normal;
    min-width: 0;
}

.notif-popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: none;
    font-size: 18px;
    color: #586d7d;
    cursor: pointer;
    line-height: 1;
}

.notif-popup-close:hover {
    color: #1e262c;
}

.notif-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e8eb;
    margin-bottom: 10px;
}

.notif-popup-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #f0f0f0;
    flex-shrink: 0;
}

.notif-popup-header-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notif-popup-name {
    font-size: 20px;
    font-weight: 700;
    color: #1e262c;
    text-decoration: none;
    line-height: 1.2;
}

.notif-popup-profile-link {
    font-size: 15px;
    font-weight: 600;
    color: #0663CD;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.notif-popup-profile-link:hover {
    text-decoration: underline !important;
}

.notif-popup-title {
    font-size: 14px;
    color: #2f3a42;
    margin-bottom: 6px;
}

.notif-popup-title .notif-actor {
    font-weight: 700;
    color: #1e262c;
}

.notif-popup-title .notif-actor.clickable {
    cursor: pointer;
    color: #0663CD;
    text-decoration: none;
}

.notif-popup-title .notif-actor.clickable:hover {
    text-decoration: underline;
}

.notif-popup-detail {
    font-size: 13px;
    color: #4c5f6d;
    margin-bottom: 6px;
    word-break: break-word;
}

.notif-popup-description {
    font-size: 13px;
    color: #4c5f6d;
    margin-bottom: 6px;
    word-break: break-word;
}

.notif-popup-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    /* Thin separator between the info block and the icon description */
    border-top: 1px solid #e5e8eb;
    padding-top: 10px;
}

.notif-popup-status .notif-action-icon {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 15px;
    cursor: default;
}

.notif-popup-status-text {
    font-size: 13px;
    color: #4c5f6d;
}

.notif-popup-status-text .notif-popup-status-label {
    display: block;
    color: #1e262c;
    font-weight: 600;
}

.notif-popup-meta {
    font-size: 12px;
    color: #586d7d;
    margin-bottom: 10px;
}

.notif-popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #e5e8eb;
    padding-top: 10px;
}

.notif-popup-show-btn {
    border: none;
    background-color: #1f3f5f;
    color: #fff;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.notif-popup-show-btn:hover {
    background-color: #16324e;
    color: #fff;
}

.notif-popup-archive-btn {
    border: 1px solid #ccc;
    background-color: transparent;
    color: #586d7d;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    line-height: normal;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.notif-popup-archive-btn:hover {
    background-color: #f5f5fa;
    border-color: #ed7d31;
    color: #ed7d31;
}

/* ------ Mobile ------ */
@media (max-width: 576px) {
    #notification-container {
        width: 100vw !important;
        max-width: 100vw !important;
        position: fixed !important;
        top: 60px !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    }

    .notif-legend {
        max-width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
    }

    .notif-btn, .notif-show-link {
        padding: 4px 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 32px;
    }
}

@media (max-width: 400px) {
    .notif-type-filter {
        max-width: 115px;
        font-size: 12px;
        padding: 2px 4px;
    }
    .notif-tab {
        padding: 8px 6px;
        font-size: 13px;
    }
    .notif-title {
        font-size: 15px;
    }
}
