/* =========================================================
   notification.css
   - 헤더 알림 벨(🔔) + 드롭다운 스타일
   - 도란톡 알림 디자인 참조
   ========================================================= */

/* ===== 알림 벨 아이콘 ===== */
.noti-bell-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;   /* 로고 오른쪽으로 밀기 */
    margin-right: 0px;
}

/* 벨이 있을 때 topbar-right의 margin-left:auto 제거 */
.noti-bell-wrap ~ .topbar-right {
    margin-left: 0;
}

.noti-bell-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 1.15rem;
    color: #6d4c41;
    position: relative;
    transition: color 0.2s, transform 0.2s, background 0.2s;
    line-height: 1;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.noti-bell-btn:hover {
    color: #4e342e;
    background: rgba(141, 110, 99, 0.08);
    transform: scale(1.05);
}

.noti-bell-btn:active {
    transform: scale(0.95);
}

/* 미읽음 배지 */
.noti-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    background: #ef5350;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    padding: 0 4px;
    box-shadow: 0 1px 4px rgba(239, 83, 80, 0.45);
    animation: noti-pulse 2s infinite;
    pointer-events: none;
}

@keyframes noti-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.noti-badge.hidden {
    display: none !important;
}

/* 미읽음이 있을 때 벨 흔들림 (도란톡 참조) */
.noti-bell-btn.has-unread i {
    animation: noti-bellRing 4s ease-in-out infinite;
    color: #d84315;
    filter: drop-shadow(0 0 3px rgba(216, 67, 21, 0.4));
}

@keyframes noti-bellRing {
    0%   { transform: rotate(0deg); }
    2%   { transform: rotate(14deg); }
    4%   { transform: rotate(-14deg); }
    6%   { transform: rotate(10deg); }
    8%   { transform: rotate(-10deg); }
    10%  { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* ===== 드롭다운 패널 ===== */
.noti-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: -10px;
    width: 340px;
    max-height: 420px;
    background: #fff;
    border: 1px solid #e8e0d8;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    overflow: hidden;
    display: none;
}

/* ✅ 개선: 드롭다운 화살표 (벨과의 시각적 연결) */
.noti-dropdown::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: #fff8e1;
    border-top: 1px solid #e8e0d8;
    border-left: 1px solid #e8e0d8;
    transform: rotate(45deg);
    z-index: 1;
}

.noti-dropdown.is-open {
    display: block;
    animation: noti-fadeIn 0.22s ease-out;
}

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

/* 헤더 */
.noti-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid #f0ebe6;
    background: linear-gradient(135deg, #fff8e1, #fff3e0);
    border-radius: 14px 14px 0 0;
}

.noti-dropdown-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #4e342e;
}

.noti-read-all-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.73rem;
    color: #8d6e63;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    margin-left: auto;
}

.noti-read-all-btn:hover {
    background: rgba(141, 110, 99, 0.10);
    border-color: rgba(141, 110, 99, 0.2);
    color: #5d4037;
}

/* ✅ 개선: 모두 읽기 클릭 후 성공 피드백 */
.noti-read-all-btn.done {
    color: #43a047;
    border-color: rgba(67, 160, 71, 0.3);
    pointer-events: none;
}

/* 닫기 버튼 */
.noti-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    color: #a1887f;
    padding: 2px 6px;
    margin-left: 2px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.noti-close-btn:hover {
    color: #5d4037;
    background: rgba(141, 110, 99, 0.10);
}

/* 목록 스크롤 */
.noti-dropdown-list {
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.noti-dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.noti-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.noti-dropdown-list::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: #d7ccc8;
}

/* ===== 알림 아이템 ===== */
.noti-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f0ea;
    cursor: pointer;
    /* ✅ 개선: 읽음 전환 시 부드러운 배경색 전환 */
    transition: background 0.25s ease, border-color 0.25s;
    text-decoration: none;
    color: inherit;
}

.noti-item:hover {
    background: #fdf8f0;
    text-decoration: none;
    color: inherit;
}

/* ✅ 개선: 마지막 아이템 border 제거 */
.noti-item:last-child {
    border-bottom: none;
}

/* 미읽음 */
.noti-item.unread {
    background: #fffde7;
    border-left: 3px solid #ffca28;
}

.noti-item.unread:hover {
    background: #fff9c4;
}

/* 아이콘 */
.noti-item-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.noti-item-icon.type-comment {
    background: #e3f2fd;
    color: #1565c0;
}

.noti-item-icon.type-like {
    background: #fce4ec;
    color: #c62828;
}

/* 도란톡 아이콘 */
.noti-item-icon.type-dorantok {
    background: #fff8e1;
    color: #f9a825;
}

/* 예방접종 리마인더 아이콘 */
.noti-item-icon.type-vaccine {
    background: #e8f5e9;
    color: #2e7d32;
}

/* 텍스트 */
.noti-item-body {
    flex: 1;
    min-width: 0;
}

.noti-item-text {
    font-size: 0.82rem;
    line-height: 1.45;
    color: #3e2723;
    margin-bottom: 2px;
}

.noti-item-text strong {
    font-weight: 600;
    color: #4e342e;
}

.noti-item-title {
    font-size: 0.75rem;
    color: #8d6e63;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.noti-item-time {
    font-size: 0.68rem;
    color: #bcaaa4;
    margin-top: 3px;
}

/* 미읽음 점 */
.noti-unread-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #42a5f5;
    margin-top: 8px;
    box-shadow: 0 0 4px rgba(66, 165, 245, 0.4);
    /* ✅ 개선: 미읽음 점 fade-in */
    animation: noti-dotPulse 2s ease-in-out infinite;
}

@keyframes noti-dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 빈 상태 */
.noti-empty {
    text-align: center;
    padding: 40px 20px;
    color: #bcaaa4;
    font-size: 0.85rem;
    line-height: 1.6;
}

.noti-empty i {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 10px;
    color: #d7ccc8;
}

/* ✅ 개선: 로딩 상태 */
.noti-loading {
    text-align: center;
    padding: 30px 20px;
    color: #bcaaa4;
    font-size: 0.82rem;
}

.noti-loading::after {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    margin: 10px auto 0;
    border: 2px solid #e8e0d8;
    border-top-color: #8d6e63;
    border-radius: 50%;
    animation: noti-spin 0.7s linear infinite;
}

@keyframes noti-spin {
    to { transform: rotate(360deg); }
}

/* ===== 모바일 반응형 ===== */
@media (max-width: 768px) {
    .noti-bell-wrap {
        margin-right: 2px;
        /* margin-left:auto는 유지 → 벨이 항상 우측 정렬 */
    }
    .noti-bell-btn {
        font-size: 1.1rem;
        padding: 6px;
        min-width: 44px;
        min-height: 44px;
    }
    .noti-dropdown {
        width: 320px;
        right: -15px;
    }
    .noti-dropdown::before {
        right: 28px;
    }
    .noti-item {
        padding: 10px 14px;
    }
}

@media (max-width: 576px) {
    .noti-bell-wrap {
        margin-right: 4px;
    }
    .noti-dropdown {
        width: 290px;
        right: -30px;
    }
    .noti-dropdown::before {
        right: 42px;
    }
}

@media (max-width: 400px) {
    /* ✅ 벨 아이콘 컴팩트 */
    .noti-bell-wrap {
        margin-right: 2px;
        flex-shrink: 0;
        /* margin-left:auto 유지 → 벨이 항상 우측 끝 정렬 */
    }
    .noti-bell-btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 1rem;
        padding: 4px;
    }
    .noti-badge {
        top: 0;
        right: 0;
        min-width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 0.58rem;
    }
    /* ✅ 로고가 벨을 밀지 않도록 */
    .brand {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }
    .brand-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ✅ 개선: 모바일 배경 오버레이 */
    .noti-bell-wrap::after {
        content: '';
        display: none;
    }
    .noti-bell-wrap.noti-overlay-active::after {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 9998;
        animation: noti-overlayIn 0.2s ease-out;
    }
    @keyframes noti-overlayIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .noti-dropdown {
        position: fixed;
        top: 56px;
        left: 6px;
        right: 6px;
        width: auto;
        max-height: calc(100vh - 70px);
        border-radius: 12px;
        z-index: 10000;
    }
    .noti-dropdown::before {
        display: none;
    }
}

/* 드롭다운 내부 클릭 시 닫히지 않도록 */
.noti-dropdown-header,
.noti-dropdown-list {
    pointer-events: auto;
}
