/**
 * 通用消息通知组件样式
 *
 * 这里是通知外观的【唯一来源】：尺寸、配色、圆角、阴影都在本文件定义，
 * 并通过 html[data-theme] / body.dark-theme 跟随站点主题（站点默认 dark）。
 * notification.js 只负责结构与动效，不再写入内联配色（历史问题：内联样式
 * 会压过样式表，导致画布页需要单独用 !important 打补丁，各页面外观不一致）。
 */

/* 通知容器 */
.app-notification-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
}

.app-notification-container.top-right {
    top: 20px;
    right: 20px;
}

.app-notification-container.top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.app-notification-container.top-left {
    top: 20px;
    left: 20px;
}

.app-notification-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

.app-notification-container.bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.app-notification-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* ---------------------------------------------
 * 通知项
 * ------------------------------------------- */
.app-notification {
    /* 主题令牌（浅色为默认值，深色主题在下方覆盖） */
    --notify-surface: #ffffff;
    --notify-border: rgba(15, 23, 42, 0.08);
    --notify-title-color: #1e293b;
    --notify-text-color: #475569;
    --notify-close-color: #94a3b8;
    --notify-close-hover-bg: rgba(15, 23, 42, 0.06);
    --notify-close-hover-color: #334155;
    --notify-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    --notify-track: rgba(15, 23, 42, 0.08);
    --notify-accent: #1890ff;

    position: relative;
    margin-bottom: 12px;
    padding: 12px 36px 12px 14px;
    border: 1px solid var(--notify-border);
    border-left: 3px solid var(--notify-accent);
    border-radius: 12px;
    background: var(--notify-surface);
    box-shadow: var(--notify-shadow);
    width: min(360px, calc(100vw - 32px));
    max-width: 360px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.app-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.app-notification.hiding {
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.2s ease-in-out;
}

/* 类型 → 强调色 */
.app-notification.success {
    --notify-accent: #52c41a;
}

.app-notification.error {
    --notify-accent: #ff4d4f;
}

.app-notification.warning {
    --notify-accent: #faad14;
}

.app-notification.info {
    --notify-accent: #1890ff;
}

/* 通知内容 */
.app-notification-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.app-notification-icon {
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 17px;
    line-height: 1.4;
    color: var(--notify-accent);
}

.app-notification-body {
    flex: 1;
    min-width: 0;
}

.app-notification-title {
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    color: var(--notify-title-color);
}

.app-notification-message {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--notify-text-color);
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.app-notification-close {
    position: absolute;
    top: 7px;
    right: 7px;
    padding: 4px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--notify-close-color);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.app-notification-close:hover {
    background: var(--notify-close-hover-bg);
    color: var(--notify-close-hover-color);
}

/* 进度条 */
.app-notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--notify-track);
    border-radius: 0 0 0 12px;
}

.app-notification-progress-bar {
    height: 100%;
    width: 100%;
    background: var(--notify-accent);
    border-radius: 0 0 0 12px;
    transition: width linear;
}

/* ---------------------------------------------
 * 深色主题（站点默认 dark，由 base_workspace / workspace_*_shell 设置）
 * ------------------------------------------- */
html[data-theme="dark"] .app-notification,
body.dark-theme .app-notification {
    --notify-surface: #202329;
    --notify-border: #414650;
    --notify-title-color: #f4f6fa;
    --notify-text-color: #e8edf5;
    --notify-close-color: #d5dae3;
    --notify-close-hover-bg: rgba(255, 255, 255, 0.1);
    --notify-close-hover-color: #ffffff;
    --notify-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --notify-track: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .app-notification.success,
body.dark-theme .app-notification.success {
    --notify-accent: #4ade80;
}

html[data-theme="dark"] .app-notification.error,
body.dark-theme .app-notification.error {
    --notify-accent: #f87171;
}

html[data-theme="dark"] .app-notification.warning,
body.dark-theme .app-notification.warning {
    --notify-accent: #fbbf24;
}

html[data-theme="dark"] .app-notification.info,
body.dark-theme .app-notification.info {
    --notify-accent: #60a5fa;
}

/* 跟随系统深色：仅在页面未显式声明主题时生效，避免覆盖 data-theme="light" */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .app-notification {
        --notify-surface: #202329;
        --notify-border: #414650;
        --notify-title-color: #f4f6fa;
        --notify-text-color: #e8edf5;
        --notify-close-color: #d5dae3;
        --notify-close-hover-bg: rgba(255, 255, 255, 0.1);
        --notify-close-hover-color: #ffffff;
        --notify-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
        --notify-track: rgba(255, 255, 255, 0.12);
    }

    html:not([data-theme="light"]) .app-notification.success {
        --notify-accent: #4ade80;
    }

    html:not([data-theme="light"]) .app-notification.error {
        --notify-accent: #f87171;
    }

    html:not([data-theme="light"]) .app-notification.warning {
        --notify-accent: #fbbf24;
    }

    html:not([data-theme="light"]) .app-notification.info {
        --notify-accent: #60a5fa;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-notification {
        width: min(360px, calc(100vw - 40px));
        max-width: calc(100vw - 40px);
        margin-left: 0;
        margin-right: 0;
    }

    .app-notification-container {
        left: 20px !important;
        right: 20px !important;
        transform: none !important;
    }

    .app-notification-container.top-right,
    .app-notification-container.top-left,
    .app-notification-container.bottom-right,
    .app-notification-container.bottom-left {
        left: 20px;
        right: 20px;
        transform: none;
    }

    .app-notification-container.top-center {
        top: 20px;
        left: 20px;
        right: 20px;
        transform: none;
    }

    .app-notification-container.bottom-center {
        bottom: 20px;
        left: 20px;
        right: 20px;
        transform: none;
    }
}

/* 动画关键帧 */
@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* 无障碍支持 */
.app-notification:focus {
    outline: 2px solid #1890ff;
    outline-offset: 2px;
}

.app-notification[role="alert"] {
    outline: none;
}

/* 自定义滚动条 */
.app-notification-container::-webkit-scrollbar {
    width: 6px;
}

.app-notification-container::-webkit-scrollbar-track {
    background: transparent;
}

.app-notification-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.app-notification-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
