/**
 * 全系统统一反馈层样式（Toast / 页面内提示 / 持续状态 / 通知中心）
 * 与 apps/_shared/public/feedback.js 配套。
 * 颜色只引用主题令牌，日间与夜间共用同一套语义色。
 */

:root {
    --feed-panel: var(--rms-panel, var(--pt-panel, #ffffff));
    --feed-panel-2: var(--rms-panel-2, var(--pt-panel-2, #f4f7fa));
    --feed-text: var(--rms-text, var(--pt-text, #1e293b));
    --feed-text-2: var(--rms-text-2, var(--pt-text-2, #334155));
    --feed-muted: var(--rms-muted, var(--pt-muted, #64748b));
    --feed-border: var(--rms-border-soft, var(--pt-border-soft, #cbd5e1));
    --feed-success: #15803d;
    --feed-info: #0b63b8;
    --feed-warning: #b45309;
    --feed-error: #b91c1c;
    --feed-radius: 6px;
    --feed-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
    --feed-gap: 8px;
}

html[data-theme="dark"] {
    --feed-success: #4ade80;
    --feed-info: #7ec8ff;
    --feed-warning: #fbbf24;
    --feed-error: #f87171;
    --feed-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

#feed-root {
    position: fixed;
    inset: 0;
    z-index: 10060;
    pointer-events: none;
}

/* ---------------- Toast ---------------- */

.feed-toast-stack {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: min(520px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--feed-gap);
}

.feed-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--feed-border);
    border-left: 3px solid var(--feed-info);
    border-radius: var(--feed-radius);
    background: var(--feed-panel);
    color: var(--feed-text);
    font-size: 12.5px;
    line-height: 1.5;
    box-shadow: var(--feed-shadow);
    animation: feed-toast-in 0.16s ease-out;
}

.feed-toast.is-leaving { animation: feed-toast-out 0.14s ease-in forwards; }

@keyframes feed-toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes feed-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(6px); }
}

.feed-toast__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: var(--feed-info);
}
.feed-toast__icon svg { width: 15px; height: 15px; }

.feed-toast__body { flex: 1 1 auto; min-width: 0; }
.feed-toast__title { font-weight: 700; font-size: 12.5px; }
.feed-toast__title + .feed-toast__msg { margin-top: 1px; }
.feed-toast__msg {
    color: var(--feed-text-2);
    white-space: pre-wrap;
    word-break: break-word;
}
.feed-toast__action {
    align-self: center;
    flex: 0 0 auto;
    height: 26px;
    padding: 0 9px;
    border: 1px solid var(--feed-border);
    border-radius: 0;
    background: var(--feed-panel-2);
    color: var(--feed-text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.feed-toast__action:hover { border-color: var(--feed-info); color: var(--feed-info); }
.feed-toast__close {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: -2px -4px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--feed-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.feed-toast__close:hover { background: var(--feed-panel-2); color: var(--feed-text); }

.feed-toast.is-success { border-left-color: var(--feed-success); }
.feed-toast.is-success .feed-toast__icon { color: var(--feed-success); }
.feed-toast.is-warning { border-left-color: var(--feed-warning); }
.feed-toast.is-warning .feed-toast__icon { color: var(--feed-warning); }
.feed-toast.is-error { border-left-color: var(--feed-error); }
.feed-toast.is-error .feed-toast__icon { color: var(--feed-error); }
.feed-toast.is-info { border-left-color: var(--feed-info); }

@media (max-width: 767px) {
    /* 让开移动端底部导航与安全区 */
    .feed-toast-stack { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
    .feed-toast { font-size: 13px; padding: 9px 10px; }
    .feed-toast__action { height: 30px; }
}

/* ---------------- 持续状态 ---------------- */

.feed-status-bar {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: min(340px, calc(100vw - 24px));
}
.feed-status-bar:empty { display: none; }

.feed-status {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 9px;
    border: 1px solid var(--feed-border);
    border-radius: 0;
    background: var(--feed-panel);
    color: var(--feed-text-2);
    font-size: 11.5px;
    line-height: 1.4;
    box-shadow: var(--feed-shadow);
}
.feed-status__dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--feed-info);
}
.feed-status.is-warning .feed-status__dot { background: var(--feed-warning); }
.feed-status.is-error .feed-status__dot { background: var(--feed-error); }
.feed-status.is-success .feed-status__dot { background: var(--feed-success); }
.feed-status__link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--feed-info);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

@media (max-width: 767px) {
    .feed-status-bar { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); left: 12px; }
}

/* ---------------- 页面内提示 ---------------- */

.feed-inline {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin: 0 0 8px;
    padding: 7px 9px;
    border: 1px solid var(--feed-border);
    border-left: 3px solid var(--feed-info);
    border-radius: 0;
    background: var(--feed-panel-2);
    color: var(--feed-text);
    font-size: 12px;
    line-height: 1.5;
}
.feed-inline__icon { flex: 0 0 auto; width: 15px; height: 15px; color: var(--feed-info); margin-top: 1px; }
.feed-inline__icon svg { width: 15px; height: 15px; }
.feed-inline__body { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.feed-inline__title { font-weight: 700; }
.feed-inline.is-success { border-left-color: var(--feed-success); }
.feed-inline.is-success .feed-inline__icon { color: var(--feed-success); }
.feed-inline.is-warning { border-left-color: var(--feed-warning); }
.feed-inline.is-warning .feed-inline__icon { color: var(--feed-warning); }
.feed-inline.is-error { border-left-color: var(--feed-error); }
.feed-inline.is-error .feed-inline__icon { color: var(--feed-error); }

/* ---------------- 通知中心入口 ---------------- */

.feed-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(127, 147, 171, 0.45);
    border-radius: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.feed-bell svg { width: 16px; height: 16px; }
.feed-bell:hover { background: rgba(127, 147, 171, 0.16); }
.feed-bell__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 0;
    background: var(--feed-error);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 15px;
    text-align: center;
}
.feed-bell__badge[hidden] { display: none; }

/* ---------------- 通知中心面板 ---------------- */

.feed-nc {
    position: absolute;
    top: 52px;
    right: 12px;
    width: min(380px, calc(100vw - 24px));
    max-height: min(72vh, 620px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--feed-border);
    border-radius: 0;
    background: var(--feed-panel);
    color: var(--feed-text);
    box-shadow: var(--feed-shadow);
    pointer-events: auto;
    overflow: hidden;
}
.feed-nc[hidden] { display: none; }

.feed-nc__hd {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--feed-border);
    background: var(--feed-panel-2);
}
.feed-nc__title { font-size: 13px; font-weight: 800; }
.feed-nc__count { font-size: 11px; color: var(--feed-muted); }
.feed-nc__hd-actions { margin-left: auto; display: flex; gap: 4px; }
.feed-nc__mini {
    height: 24px;
    padding: 0 7px;
    border: 1px solid var(--feed-border);
    border-radius: 0;
    background: var(--feed-panel);
    color: var(--feed-text-2);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.feed-nc__mini:hover { color: var(--feed-info); border-color: var(--feed-info); }

.feed-nc__filters {
    display: flex;
    gap: 6px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--feed-border);
    overflow-x: auto;
    scrollbar-width: none;
}
.feed-nc__filters::-webkit-scrollbar { display: none; }
.feed-nc__chip {
    flex: 0 0 auto;
    height: 24px;
    padding: 0 9px;
    border: 1px solid var(--feed-border);
    border-radius: 0;
    background: transparent;
    color: var(--feed-text-2);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.feed-nc__chip.is-active { background: var(--feed-panel-2); border-color: var(--feed-info); color: var(--feed-info); font-weight: 700; }

.feed-nc__list { flex: 1 1 auto; overflow-y: auto; }
.feed-nc__empty { padding: 28px 12px; text-align: center; color: var(--feed-muted); font-size: 12px; }

.feed-nc__item {
    position: relative;
    display: flex;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-bottom: 1px solid var(--feed-border);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.feed-nc__item:hover { background: var(--feed-panel-2); }
.feed-nc__item.is-unread { background: color-mix(in srgb, var(--feed-info) 7%, transparent); }
.feed-nc__dot { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--feed-info); }
.feed-nc__item.is-warning .feed-nc__dot { background: var(--feed-warning); }
.feed-nc__item.is-error .feed-nc__dot { background: var(--feed-error); }
.feed-nc__item.is-success .feed-nc__dot { background: var(--feed-success); }
.feed-nc__item.is-read .feed-nc__dot { opacity: 0.35; }
.feed-nc__main { flex: 1 1 auto; min-width: 0; }
.feed-nc__line { display: flex; align-items: baseline; gap: 6px; }
.feed-nc__item-title { flex: 1 1 auto; min-width: 0; font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-nc__time { flex: 0 0 auto; font-size: 10.5px; color: var(--feed-muted); }
.feed-nc__item-msg { margin-top: 2px; font-size: 11.5px; color: var(--feed-text-2); word-break: break-word; }
.feed-nc__item-meta { display: flex; gap: 6px; margin-top: 3px; font-size: 10.5px; color: var(--feed-muted); }
.feed-nc__tag { padding: 0 5px; border: 1px solid var(--feed-border); border-radius: 0; }

@media (max-width: 640px) {
    .feed-nc {
        top: 0;
        right: 0;
        bottom: 0;
        width: min(92vw, 380px);
        max-height: none;
        border-radius: 0;
    }
}
