/**
 * Toast 提示公共样式
 * 用于 client/index.html 和 zhuotai/7272.html
 */

.toast {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translate(-50%, -20px);
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-radius: 12px;
    font-size: 15px;
    z-index: 20050; /* 高于 pm-longtext-dialog(10002)/auth-dialog(10004)/pm-float(20000)，避免被弹窗内容挡住 */
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    white-space: pre-line; /* 支持 \n 换行符，允许显示多行文本 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: unset;
    width: fit-content;
    max-width: 90vw;
    padding-left: 20px;
    padding-right: 20px;
    margin: 0 auto;
    justify-content: center;
}

/* =========================
 * 微信内置浏览器优化（依赖 wechat-compat.js 给 html/body 加 .wx）
 * - 避免 blur 在微信里偶发黑块/闪烁
 * - 贴合安全区
 * ========================= */
html.wx .toast {
    /* iOS 微信键盘场景：可视区会下移（visualViewport.offsetTop > 0），toast 需要跟随可视区顶端，避免跑到屏幕外 */
    top: calc(var(--vv-offset-top, 0px) + 12px + env(safe-area-inset-top));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

@media (max-width: 768px) {
    html.wx .toast {
        font-size: 14px;
        padding: 12px 16px;
        padding-left: 16px;
        padding-right: 16px;
        max-width: 92vw;
    }
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
    /* 支持 close 按钮点击（默认 toast 不拦截交互） */
    pointer-events: auto;
}

.toast-message {
    display: inline-block;
    min-width: 0;
}

.toast--closeable {
    padding-right: 14px;
}

.toast-close {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    font-size: 18px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.9;
}

.toast-close:active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

/* 自动填充被拦截：红字加粗（不影响其它 toast） */
.toast.toast--autofill-blocked {
    border-color: rgba(255, 59, 48, 0.35) !important;
    /* 强制单行显示（避免在微信小屏被挤换行） */
    white-space: nowrap !important;
}

.toast.toast--autofill-blocked .toast-message {
    font-weight: 800;
    color: #ff3b30; /* iOS system red */
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 自动填充提示：左侧图标与右侧 X 用黄色（仅该提示生效） */
.toast.toast--autofill-blocked::before {
    /* info 图标改为黄色 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffd400'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E") !important;
}

.toast.toast--autofill-blocked .toast-close {
    /* 反色风格：黄色实心圆 + 深色 X（与左侧图标一致的“镂空/反色”观感） */
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 999px;
    background: #ffd400;
    color: rgba(0, 0, 0, 0.88);
    font-weight: 900;
    font-size: 12px;
    line-height: 1;
    padding: 0;
}

.toast.toast--autofill-blocked .toast-close:active {
    background: rgba(255, 212, 0, 0.82);
}

.toast::before {
    content: '';
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.toast.success {
    min-width: unset;
    width: fit-content;
    max-width: 90vw;
    padding-left: 20px;
    padding-right: 20px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.toast.success::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
}

.toast.warn { 
    background: linear-gradient(135deg, #f39c12, #f1c40f);
    border-color: rgba(241, 196, 15, 0.3);
}

.toast.warn::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
}

.toast.error { 
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: rgba(231, 76, 60, 0.3);
}

.toast.error::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
}

.toast.info { 
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: rgba(52, 152, 219, 0.3);
}

.toast.info::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
}

