/* =====================================================================
   YouTube 风格全局组件（单点定义）
   引用方：themes/default/header.php、includes/subsite.php、index.php、
   themes/portal/header.php；与 common.css 解耦，供不加载 common.css 的页面复用
   主题：基础=浅色，body.dark 覆盖深色（与全局变量机制一致）
   ===================================================================== */

/* =====================================================================
   YouTube 风格全局组件（单点定义，主站 header 与插件子站共用）
   主题：基础=浅色（:root），body.dark 覆盖深色（与全局变量机制一致）
   ===================================================================== */

/* ---------- 通知铃铛 + 下拉面板 ---------- */
.yt-notif-wrap { position: relative; display: inline-flex; }
.yt-notif-bell {
    width: 38px; height: 38px; border-radius: 50%;
    border: 0; padding: 0; cursor: pointer;
    background: transparent; color: var(--text-secondary, #515154);
    font-size: 17px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s ease;
    position: relative;
}
.yt-notif-bell:hover,
.yt-notif-bell:focus-visible { background: rgba(0,0,0,.06); outline: none; }
.yt-notif-bell .yt-notif-dot {
    position: absolute; top: 1px; right: 1px;
    min-width: 15px; height: 15px; padding: 0 4px;
    border-radius: 999px;
    background: #c00; color: #fff;
    font-size: 9px; font-weight: 700; line-height: 15px;
    text-align: center;
    border: 2px solid var(--bg, #f5f7fa);
    box-sizing: content-box;
}
.yt-notif-bell .yt-notif-dot.is-hidden { display: none; }

.yt-notif-panel {
    display: none;
    position: absolute; top: calc(100% + 10px); right: 0;
    width: 400px; max-width: calc(100vw - 24px);
    background: #fff; color: #0f0f0f;
    border-radius: 12px;
    box-shadow: 0 4px 32px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.10);
    z-index: 1080;
    overflow: hidden;
    white-space: normal; /* 防顶栏容器 nowrap 继承（首页窄屏 .topbar-actions 等）导致通知文本不换行 */
    transform-origin: top right;
}
.yt-notif-panel.yt-open { display: block; animation: ytNotifIn .16s ease; }
@keyframes ytNotifIn {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.yt-notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px;
}
.yt-notif-head h4 { margin: 0; font-size: 16px; font-weight: 600; color: #0f0f0f; }
.yt-notif-readall {
    border: 0; background: transparent; cursor: pointer;
    font-size: 13px; font-weight: 500; color: #065fd4; padding: 4px 8px;
    border-radius: 6px; font-family: inherit;
}
.yt-notif-readall:hover { background: rgba(6,95,212,.08); }
.yt-notif-list {
    max-height: min(440px, 70vh);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.22) transparent;
}
.yt-notif-list::-webkit-scrollbar { width: 8px; }
.yt-notif-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.22);
    border-radius: 8px;
}
.yt-notif-list::-webkit-scrollbar-track { background: transparent; }
.yt-notif-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px;
    text-decoration: none; color: inherit;
    position: relative;
    transition: background .12s ease;
}
.yt-notif-item:hover { background: #f2f2f2; }
.yt-notif-item.is-unread { background: #eef4fd; }
.yt-notif-item.is-unread:hover { background: #e3edfb; }
.yt-notif-item.is-unread::after {
    content: ''; position: absolute; right: 10px; top: 50%;
    width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
    background: #065fd4;
}
.yt-notif-icon {
    width: 40px; height: 40px; border-radius: 50%;
    flex-shrink: 0; margin-left: 2px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px; font-style: normal;
}
.yt-notif-icon.t-blue  { background: #e3eefd; color: #1a56c4; }
.yt-notif-icon.t-red   { background: #fce8e6; color: #c5221f; }
.yt-notif-icon.t-amber { background: #fef3d6; color: #b06000; }
.yt-notif-icon.t-green { background: #e6f4ea; color: #137333; }
.yt-notif-icon.t-cyan  { background: #e2f6fa; color: #0a7d8c; }
.yt-notif-icon.t-gray  { background: #f1f3f4; color: #5f6368; }
.yt-notif-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0; margin-left: 2px;
}
.yt-notif-body { flex: 1; min-width: 0; padding-right: 12px; }
.yt-notif-content {
    font-size: 13.5px; line-height: 1.45; color: #0f0f0f;
    word-break: break-word;
}
.yt-notif-time { font-size: 12px; color: #5f6368; margin-top: 3px; }
.yt-notif-empty {
    padding: 44px 20px; text-align: center;
    color: #5f6368; font-size: 13px;
}
.yt-notif-empty .bell-off { font-size: 34px; display: block; margin-bottom: 10px; opacity: .5; }
.yt-notif-loading { padding: 28px; text-align: center; color: #9aa0a6; font-size: 13px; }
.yt-notif-foot {
    padding: 12px; text-align: center;
    border-top: 1px solid #e5e7eb;
}
.yt-notif-foot a {
    font-size: 13.5px; font-weight: 500; color: #065fd4;
    text-decoration: none; padding: 6px 12px; border-radius: 6px;
}
.yt-notif-foot a:hover { background: rgba(6,95,212,.08); }

/* 深色主题覆盖 */
body.dark .yt-notif-bell { color: var(--text-secondary, #a8b8cc); }
body.dark .yt-notif-bell:hover,
body.dark .yt-notif-bell:focus-visible { background: rgba(255,255,255,.10); }
body.dark .yt-notif-bell .yt-notif-dot { border-color: var(--bg, #0a0e27); }
body.dark .yt-notif-panel {
    background: #282828; color: #fff;
    box-shadow: 0 4px 32px rgba(0,0,0,.55), 0 1px 3px rgba(0,0,0,.4);
}
body.dark .yt-notif-head h4 { color: #fff; }
body.dark .yt-notif-readall { color: #8ab4f8; }
body.dark .yt-notif-readall:hover { background: rgba(138,180,248,.12); }
body.dark .yt-notif-item:hover { background: #3e3e3e; }
body.dark .yt-notif-item.is-unread { background: rgba(95,145,230,.18); }
body.dark .yt-notif-item.is-unread:hover { background: rgba(95,145,230,.28); }
body.dark .yt-notif-item.is-unread::after { background: #8ab4f8; }
body.dark .yt-notif-icon.t-blue  { background: rgba(138,180,248,.18); color: #a8c7fa; }
body.dark .yt-notif-icon.t-red   { background: rgba(242,139,130,.18); color: #f28b82; }
body.dark .yt-notif-icon.t-amber { background: rgba(253,214,99,.16); color: #fdd663; }
body.dark .yt-notif-icon.t-green { background: rgba(129,201,151,.18); color: #81c995; }
body.dark .yt-notif-icon.t-cyan  { background: rgba(130,227,240,.15); color: #82e3f0; }
body.dark .yt-notif-icon.t-gray  { background: rgba(255,255,255,.10); color: #c4c7c5; }
body.dark .yt-notif-content { color: #f1f1f1; }
body.dark .yt-notif-time { color: #9aa0a6; }
body.dark .yt-notif-empty { color: #9aa0a6; }
body.dark .yt-notif-foot { border-top-color: #3c4043; }
body.dark .yt-notif-foot a { color: #8ab4f8; }
body.dark .yt-notif-foot a:hover { background: rgba(138,180,248,.12); }
body.dark .yt-notif-list { scrollbar-color: rgba(255,255,255,.25) transparent; }
body.dark .yt-notif-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); }

/* ---------- YouTube 风格选中态（图片卡 / 图文框 / 列表项） ----------
   用法：给可点击选中的卡片容器加 .yt-select，选中时加 .on
   视觉：中性灰底高亮（无彩色发光边框）+ 右上角圆形对勾 */
.yt-select { position: relative; }
.yt-select.on {
    background: rgba(0,0,0,.06);
    border-color: transparent;
    box-shadow: none;
}
.yt-select.on::after {
    content: '✓';
    position: absolute; top: 8px; right: 8px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #0f0f0f; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; line-height: 1;
    z-index: 2; pointer-events: none;
}
body.dark .yt-select.on { background: rgba(255,255,255,.10); }
body.dark .yt-select.on::after { background: #f1f1f1; color: #0f0f0f; }

/* YouTube 风格 chip 选中态（筛选/模式切换按钮）
   用法：未选中为浅灰胶囊，选中 .yt-chip-on 反转配色（黑底白字 / 深底黑字） */
.yt-chip {
    background: rgba(0,0,0,.06); color: #0f0f0f;
    border: 1px solid transparent;
}
.yt-chip.yt-chip-on,
.yt-chip.on {
    background: #0f0f0f; color: #fff; border-color: transparent;
}
body.dark .yt-chip { background: rgba(255,255,255,.10); color: #f1f1f1; }
body.dark .yt-chip.yt-chip-on,
body.dark .yt-chip.on {
    background: #f1f1f1; color: #0f0f0f;
}

/* 窄屏（手机）：面板改为相对视口的全宽下拉，避免跟随贴左的顶栏图标而溢出屏幕
   （部分主题窄屏下顶栏操作图标靠左排列，absolute+right:0 会把 400px 面板推出视口） */
@media (max-width: 640px) {
    .yt-notif-panel {
        position: fixed;
        top: 8px; left: 8px; right: 8px;
        width: auto; max-width: none;
        transform-origin: top center;
    }
    .yt-notif-list { max-height: min(440px, 60vh); }
}

@media (prefers-reduced-motion: reduce) {
    .yt-notif-panel.yt-open { animation: none; }
}
