/**
 * @fileoverview 轻提示与工具提示样式
 * @description Toast 固定在右上角，按类型着色并自动消失；
 *              Tooltip 挂载到 body，随触发器位置变化，自动避免超出视口。
 * @author calvinliu@hk.chinamobile.com
 * @version V1.0.0
 * @license MIT
 */

.toast-container {
    position: fixed;
    top: calc(var(--shell-h) + 12px);
    right: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-saturate));
    backdrop-filter: blur(calc(var(--glass-blur) + 6px)) saturate(var(--glass-saturate));
    pointer-events: auto;
    animation: toast-in var(--dur-3) var(--ease-out) both;
}

html[data-theme="dark"] .toast {
    background: rgba(13, 27, 50, 0.95);
}

.toast.is-leaving {
    animation: toast-out var(--dur-2) var(--ease-out) both;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translate3d(18px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translate3d(18px, 0, 0);
    }
}

.toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.toast--success .toast__icon {
    color: var(--success);
    background: var(--success-soft);
}

.toast--warning .toast__icon {
    color: var(--warning);
    background: var(--warning-soft);
}

.toast--error .toast__icon {
    color: var(--danger);
    background: var(--danger-soft);
}

.toast__content {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.toast__title {
    font-size: var(--font-sm);
    font-weight: 650;
    color: var(--text-primary);
}

.toast__message {
    margin-top: 1px;
    font-size: var(--font-sm);
    line-height: 1.55;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.toast__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    font-size: var(--font-xs);
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    transition: color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.toast__close:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

/* 工具提示：跟随主题的实色浮层，带指向触发器的箭头 */
.ui-tooltip {
    position: fixed;
    z-index: var(--z-toast);
    max-width: min(280px, calc(100vw - 16px));
    padding: 6px 10px;
    font-size: var(--font-sm);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    white-space: normal;
    overflow-wrap: anywhere;
    animation: tbd-fade-in 120ms var(--ease-out) both;
}

.ui-tooltip::before {
    content: "";
    position: absolute;
    left: var(--tip-arrow-x, 50%);
    width: 8px;
    height: 8px;
    margin-left: -5px;
    background: inherit;
    border: 1px solid var(--border);
    border-radius: 1px;
    transform: rotate(45deg);
}

/* 位于触发器上方时箭头朝下，保留旋转后的左下、右下两条边 */
.ui-tooltip[data-placement="top"]::before {
    bottom: -5px;
    border-top-color: transparent;
    border-left-color: transparent;
}

/* 位于触发器下方时箭头朝上，保留旋转后的左上、右上两条边 */
.ui-tooltip[data-placement="bottom"]::before {
    top: -5px;
    border-bottom-color: transparent;
    border-right-color: transparent;
}

@media (max-width: 640px) {
    .toast-container {
        top: calc(var(--shell-h) + 8px);
        right: 8px;
        width: calc(100vw - 16px);
    }
}
