/* ========================================
   Django Admin 通知 Widget 樣式（原生風格版）
   版本：2.0.0
   修改：改用 Django Admin 原生樣式
   ======================================== */

/* ========== 通知連結 ========== */
#notification-widget {
    position: relative;
    display: inline-block;
}

.notification-link {
    color: var(--header-link-color, #fff);
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.notification-link:hover {
    text-decoration: none;
    border-bottom: 0;
}

#notification-text {
    display: inline;
}

/* ========== 未讀數量 Badge（文字形式）========== */
.notification-badge {
    display: inline;
    color: var(--accent, #f5dd5d);
    font-weight: bold;
    margin-left: 0;
}

/* ========== Toggle 面板 ========== */
.notification-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 400px;
    max-height: 600px;
    background: var(--body-bg);
    border: 1px solid var(--border-color, #ccc);
    z-index: 9999;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
}

/* Dark Mode 支援 */
[data-theme="dark"] .notification-panel {
    background: var(--darkened-bg);
    border-color: var(--border-color);
}

/* ========== Header - 改善對比度 ========== */
.notification-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--hairline-color, #e8e8e8);
    background: var(--body-bg);  /* 改為白色背景，提高對比度 renhao 20251119 */
}

.notification-header h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;  /* 從 400 改為 500，更明顯 renhao 20251119 */
    color: var(--body-fg);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 0;  /* 調整 padding renhao 20251119 */
    margin-bottom: 0;
    border-bottom: none;
    float: left;
}

.btn-mark-all {
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    color: var(--link-fg);  /* 改為連結顏色，更明顯 renhao 20251119 */
    padding: 6px 12px;  /* 增加 padding renhao 20251119 */
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;  /* 加粗 renhao 20251119 */
    float: right;
    border-radius: 4px;  /* 新增圓角 renhao 20251119 */
    transition: all 0.2s ease;  /* 新增過渡效果 renhao 20251119 */
}

.btn-mark-all:hover {
    background: var(--primary);  /* hover 時使用主要色 renhao 20251119 */
    border-color: var(--primary);
    color: var(--button-fg);  /* hover 時文字變白色 renhao 20251119 */
}

.btn-mark-all:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Clear float */
.notification-header::after {
    content: "";
    display: table;
    clear: both;
}

/* ========== 通知列表 ========== */
.notification-list {
    max-height: 450px;
    overflow-y: auto;
    padding: 0;
    background: var(--body-bg);
}

/* 自訂捲軸樣式（保持簡約）*/
.notification-list::-webkit-scrollbar {
    width: 8px;
}

.notification-list::-webkit-scrollbar-track {
    background: var(--darkened-bg, #f8f8f8);
}

.notification-list::-webkit-scrollbar-thumb {
    background: var(--border-color, #ccc);
}

.notification-list::-webkit-scrollbar-thumb:hover {
    background: var(--body-quiet-color, #666);
}

/* ========== 通知項目 ========== */
/* 20260722 renhao add scope 到鈴鐺面板宣告 row：ssdashboard.css 的同名類設 column，
   儀表板頁鈴鐺面板的 ✓ 按鈕會掉到內容下方；裸類名宣告 row 又會反向把
   dashboard 自己面板的直排改壞，故用 #notification-panel 限定範圍 */
#notification-panel .notification-item {
    flex-direction: row;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 10px 12px;
    border-bottom: 1px solid var(--hairline-color, #e8e8e8);
    cursor: pointer;
    position: relative;
    background: var(--body-bg);
    transition: background-color 0.2s ease;
}

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

.notification-item:hover {
    background: var(--darkened-bg, #f8f8f8);
}

/* 未讀通知樣式 - 提高對比度（使用專案 CSS 變數） renhao 20251119 */
.notification-item[data-read="false"] {
    background: var(--message-warning-bg, #ffc);
    border-left: 3px solid var(--accent, #f5dd5d);
    font-weight: 500;
}

[data-theme="dark"] .notification-item[data-read="false"] {
    background: var(--selected-row, #00363a);
    border-left: 3px solid var(--link-fg, #81d4fa);
}

.notification-item[data-read="false"]:hover {
    background: #ffeb9c;  /* 比 --message-warning-bg (#ffc) 稍深 renhao 20251119 */
}

[data-theme="dark"] .notification-item[data-read="false"]:hover {
    background: rgba(65, 118, 144, 0.35);
}

/* ========== 事件圖示 ========== */
.event-icon {
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
    line-height: 1;
}

/* ========== 通知內容 ========== */
.notification-content {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.notification-text {
    font-size: 1rem;  /* 電腦版 16px renhao 20251120 */
    color: var(--body-fg);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;  /* 從 1.4 提升到 1.5，增加行距 renhao 20251119 */
}

.notification-time {
    font-size: 0.75rem;  /* 從 0.6875rem 提升到 0.75rem renhao 20251119 */
    color: var(--body-quiet-color, #666);
}

/* ========== 標記已讀按鈕 ========== */
.btn-mark-read {
    background: none;
    border: none;
    color: var(--link-fg, #417893);
    cursor: pointer;
    font-size: 1.25rem;  /* 20px renhao 20251120 */
    padding: 4px;
    opacity: 0.6;
    flex-shrink: 0;
}

.btn-mark-read:hover {
    opacity: 1;
    color: var(--link-hover-color, #036);
}

/* ========== Footer - 加強「查看所有通知」按鈕樣式 ========== */
.notification-footer {
    padding: 12px;
    border-top: 1px solid var(--hairline-color, #e8e8e8);
    text-align: center;
    background: var(--body-bg);  /* 改為白色背景，提高對比度 renhao 20251119 */
    flex-shrink: 0;  /* 確保 footer 不會被擠壓 renhao 20251119 */
}

.btn-view-all {
    display: inline-block;  /* 改為 inline-block，確保可點擊範圍 renhao 20251119 */
    background: var(--primary);  /* 使用主要按鈕顏色 renhao 20251119 */
    color: var(--button-fg);  /* 按鈕文字顏色（白色） renhao 20251119 */
    text-decoration: none;
    font-weight: 500;  /* 從 normal 改為 500，更明顯 renhao 20251119 */
    font-size: 0.875rem;  /* 從 0.8125rem 提升到 0.875rem renhao 20251119 */
    padding: 8px 16px;  /* 增加 padding，更明顯 renhao 20251119 */
    border-radius: 4px;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);  /* 新增陰影 renhao 20251119 */
}

.btn-view-all:hover {
    text-decoration: none;  /* 移除底線，改用背景色變化 renhao 20251119 */
    background: var(--button-hover-bg);  /* 使用 hover 背景色 renhao 20251119 */
    color: var(--button-fg);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);  /* hover 時陰影加深 renhao 20251119 */
    /* 移除 transform 避免影響容器高度 renhao 20251119 */
}

[data-theme="dark"] .btn-view-all {
    background: var(--primary);
    color: var(--button-fg);
}

[data-theme="dark"] .btn-view-all:hover {
    background: var(--button-hover-bg);
}

/* ========== 空狀態 ========== */
.notification-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--body-quiet-color, #666);
    font-size: 0.8125rem;
}

.notification-empty::before {
    content: "📭";
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
}

/* ========== 載入中狀態 ========== */
.notification-loading {
    padding: 40px 16px;
    text-align: center;
    color: var(--body-quiet-color, #666);
    font-size: 0.8125rem;
}

.notification-loading::before {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    margin: 0 auto 12px;
    border: 3px solid var(--hairline-color, #e8e8e8);
    border-top-color: var(--link-fg, #417893);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== 錯誤狀態 ========== */
.notification-error {
    padding: 40px 16px;
    text-align: center;
    color: var(--error-fg, #ba2121);
    font-size: 0.8125rem;
}

.notification-error::before {
    content: "⚠️";
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
    .notification-panel {
        width: 320px;
        max-height: 500px;
    }

    .notification-list {
        max-height: 380px;
    }

    .notification-item {
        padding: 8px 10px;
    }

    .notification-text {
        font-size: 0.875rem;  /* 手機版 14px renhao 20251120 */
    }

    .event-icon {
        font-size: 18px;
        margin-right: 10px;
    }
}

@media (max-width: 480px) {
    .notification-panel {
        width: calc(100vw - 40px);
        right: -150px;
    }
}

/* ========== 無障礙設計 ========== */
.notification-link:focus,
.btn-mark-all:focus,
.btn-mark-read:focus,
.btn-view-all:focus {
    outline: 2px solid var(--link-fg, #417893);
    outline-offset: 2px;
}

/* 高對比度模式支援 */
@media (prefers-contrast: high) {
    .notification-panel {
        border-width: 2px;
    }
}
