/* ==========================================================================
   Yixiang UI / 翊象 UI
   Modal and Overlay Components
   弹层与浮层组件

   Copyright (c) 2026 威海颜翊网络科技有限公司
   Licensed under the MIT License. Commercial use is permitted.
   https://www.weihaiyanyi.com  |  pinenetcn@gmail.com
   ========================================================================== */
.yx-dialog-shade {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--yx-z-overlay, 1020);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.yx-dialog-shade.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 弹窗容器 */
.yx-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    background-color: var(--yx-bg-paper);
    color: var(--yx-text-primary);
    border-radius: var(--yx-radius-lg);
    box-shadow: var(--yx-shadow-float);
    z-index: var(--yx-z-modal, 1030);
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.22s;
    will-change: transform, opacity;
}

.yx-dialog.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.yx-dialog:focus {
    outline: none;
}

/* 拖拽中：取消过渡，避免跟手延迟 */
.yx-dialog.yx-dialog-dragging {
    transition: none;
    user-select: none;
}

/* 1. Dialog (Alert / Confirm) */
.yx-dialog-dialog {
    width: 100%;
    min-width: 300px;
    max-width: 450px;
}

.yx-dialog-title {
    padding: 12px 16px;
    border-bottom: 1px solid var(--yx-border-light);
    font-size: var(--yx-text-base);
    font-weight: 600;
    background-color: var(--yx-bg-hover);
    color: var(--yx-text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--yx-space-3);
    cursor: move;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
}

.yx-dialog-close {
    background: none;
    border: none;
    color: var(--yx-text-tertiary);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    border-radius: var(--yx-radius-sm);
    flex-shrink: 0;
}
.yx-dialog-close:hover {
    color: var(--yx-danger);
}

.yx-dialog-content {
    padding: 24px;
    font-size: var(--yx-text-sm);
    color: var(--yx-text-secondary);
    line-height: 1.7;
    overflow-y: auto;
    overscroll-behavior: contain;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.yx-dialog-content .yx-dialog-text {
    min-width: 0;
}

/* Dialog with Icon */
.yx-dialog-content.has-icon {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.yx-dialog-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
}
.yx-dialog-icon.info { color: var(--yx-info); }
.yx-dialog-icon.success { color: var(--yx-success); }
.yx-dialog-icon.warning { color: var(--yx-warning); }
.yx-dialog-icon.error { color: var(--yx-danger); }
.yx-dialog-icon.question { color: var(--yx-warning); }

.yx-dialog-btn {
    padding: 12px 16px;
    text-align: right;
    border-top: 1px solid var(--yx-border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background-color: var(--yx-bg-paper);
    flex-shrink: 0;
}

/* 2. Message (Msg) */
.yx-dialog-msg {
    background-color: rgba(0, 0, 0, 0.82);
    color: #ffffff;
    border-radius: var(--yx-radius-md);
    padding: 12px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: min(80vw, 480px);
    min-width: 120px;
    text-align: center;
    justify-content: center;
    cursor: pointer;
    transform: translate(-50%, -50%) translateY(16px);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
    overflow: visible;
}

.yx-dialog-msg.open {
    transform: translate(-50%, -50%) translateY(0);
}

.yx-dialog-msg .yx-dialog-icon {
    font-size: 18px;
}

.yx-dialog-msg-text {
    font-size: var(--yx-text-sm);
    line-height: 1.5;
}

/* 3. Loading */
.yx-dialog-loading {
    background: transparent;
    box-shadow: none;
    border: none;
    overflow: visible;
}

.yx-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: yx-spin 0.9s linear infinite;
}

.yx-loading-circle {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(var(--yx-brand-primary-rgb), 0.2);
    border-radius: 50%;
    border-top-color: var(--yx-brand-primary);
    animation: yx-spin 0.9s linear infinite;
}

/* 卡片式加载层 */
.yx-loading-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--yx-space-3);
    padding: 14px 22px;
    background-color: var(--yx-bg-paper);
    color: var(--yx-text-primary);
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    box-shadow: var(--yx-shadow-float);
    font-size: var(--yx-text-sm);
    line-height: 1;
}

.yx-loading-card .yx-loading-spinner,
.yx-loading-card .yx-loading-circle {
    width: 22px;
    height: 22px;
    border-width: 2.5px;
    flex-shrink: 0;
}

.yx-loading-card .yx-loading-spinner {
    border-color: rgba(var(--yx-brand-primary-rgb), 0.2);
    border-top-color: var(--yx-brand-primary);
}

.yx-loading-text {
    white-space: nowrap;
}

@keyframes yx-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Prompt / Tabs / Drawer / Tips / Photos
   ========================================================================== */
.yx-dialog-prompt .yx-dialog-text {
    margin-bottom: var(--yx-space-3);
}

.yx-dialog-input.is-error {
    border-color: var(--yx-danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18);
}

/* Tabs */
.yx-dialog-tabs {
    width: min(720px, calc(100vw - 32px));
}

.yx-dialog-tabs-nav {
    display: flex;
    gap: var(--yx-space-5);
    padding: 0 var(--yx-space-6);
    border-bottom: 1px solid var(--yx-border-light);
    overflow-x: auto;
    flex-shrink: 0;
}

.yx-dialog-tab {
    padding: 14px 0;
    border: none;
    background: none;
    color: var(--yx-text-secondary);
    font-size: var(--yx-text-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}

.yx-dialog-tab.active {
    color: var(--yx-brand-primary);
}

.yx-dialog-tab.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background-color: var(--yx-brand-primary);
}

.yx-dialog-tabs-content {
    padding: 0;
}

.yx-dialog-tab-pane {
    display: none;
    padding: var(--yx-space-5) var(--yx-space-6);
    line-height: 1.8;
}

.yx-dialog-tab-pane.active {
    display: block;
}

/* Drawer */
.yx-dialog.yx-drawer {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: min(420px, 92vw);
    max-width: 92vw;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    transform: translateX(100%);
}

.yx-dialog.yx-drawer.open {
    transform: translateX(0);
}

.yx-dialog.yx-drawer--left {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

.yx-dialog.yx-drawer--left.open {
    transform: translateX(0);
}

.yx-drawer .yx-dialog-content {
    flex: 1;
    overflow-y: auto;
}

/* Tips */
.yx-tips {
    position: fixed;
    z-index: 1095;
    max-width: 260px;
    padding: 8px 12px;
    border-radius: var(--yx-radius-sm);
    background-color: #1f2430;
    color: #ffffff;
    font-size: var(--yx-text-xs);
    line-height: 1.65;
    box-shadow: var(--yx-shadow-float);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    pointer-events: none;
}

.yx-tips.is-in {
    opacity: 1;
    transform: translateY(0);
}

.yx-tips-arrow {
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 8px;
    height: 8px;
    background-color: #1f2430;
    transform: translateX(-50%) rotate(45deg);
}

.yx-tips--bottom .yx-tips-arrow {
    bottom: auto;
    top: -4px;
}

/* Photos */
.yx-photos {
    position: fixed;
    inset: 0;
    z-index: 1095;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(6, 8, 12, 0.9);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.yx-photos.is-visible {
    opacity: 1;
    visibility: visible;
}

.yx-photos-figure {
    margin: 0;
    max-width: 90vw;
    max-height: 84vh;
    text-align: center;
}

.yx-photos-figure img {
    max-width: 90vw;
    max-height: 76vh;
    border-radius: var(--yx-radius-md);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.yx-photos-figure figcaption {
    margin-top: var(--yx-space-3);
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--yx-text-sm);
}

.yx-photos-close,
.yx-photos-nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--yx-transition-fast);
}

.yx-photos-close:hover,
.yx-photos-nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.yx-photos-close {
    top: 20px;
    right: 24px;
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.yx-photos-nav {
    top: 50%;
    width: 46px;
    height: 46px;
    font-size: 30px;
    transform: translateY(-50%);
}

.yx-photos-prev { left: 24px; }
.yx-photos-next { right: 24px; }

.yx-photos-count {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--yx-text-xs);
    letter-spacing: 1px;
}

/* 4. Page / Iframe */
.yx-dialog-page {
    width: 80%;
    max-width: 800px;
    height: 80vh;
}

.yx-dialog-page .yx-dialog-content,
.yx-dialog-content.yx-dialog-iframe-wrapper {
    padding: 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.yx-dialog-iframe {
    width: 100%;
    height: 100%;
    min-height: 240px;
    border: none;
    display: block;
    flex: 1;
    background-color: var(--yx-bg-paper);
}

/* Animation variants */
.yx-dialog-anim-up {
    transform: translate(-50%, 100%);
}
.yx-dialog-anim-up.open {
    transform: translate(-50%, -50%);
}

/* Mobile */
@media (max-width: 768px) {
    .yx-dialog-dialog {
        min-width: 0;
        width: calc(100vw - 32px);
    }

    .yx-dialog-page {
        width: calc(100vw - 24px);
        height: 86vh;
    }

    .yx-dialog-content {
        padding: 20px 16px;
    }

    .yx-dialog-title {
        padding: 12px;
    }

    .yx-dialog-btn {
        padding: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yx-dialog,
    .yx-dialog-shade,
    .yx-dialog-msg {
        transition: none;
    }
}

/* Capture overlay / 捕获浮层 */
.yx-capture-shade {
    z-index: 1094;
}

.yx-capture {
    position: fixed;
    z-index: 1096;
    width: 300px;
    max-width: calc(100vw - 16px);
    padding: 16px 18px;
    background-color: var(--yx-bg-paper);
    color: var(--yx-text-primary);
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    box-shadow: var(--yx-shadow-float);
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.yx-capture.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.yx-capture-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: var(--yx-radius-sm);
    background: transparent;
    color: var(--yx-text-tertiary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.yx-capture-close:hover {
    background-color: var(--yx-bg-hover);
    color: var(--yx-text-primary);
}

.yx-capture-body {
    font-size: var(--yx-text-sm);
    line-height: 1.75;
    color: var(--yx-text-secondary);
    padding-right: 12px;
}

.yx-capture-body strong {
    color: var(--yx-text-primary);
}

.yx-capture-arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--yx-bg-paper);
    border-right: 1px solid var(--yx-border-light);
    border-bottom: 1px solid var(--yx-border-light);
    transform: translateX(-50%) rotate(45deg);
    bottom: -6px;
}

.yx-capture--up .yx-capture-arrow {
    bottom: auto;
    top: -6px;
    transform: translateX(-50%) rotate(225deg);
}

/* 加载风格 / Loading styles */
.yx-loading-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.yx-loading-dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--yx-brand-primary);
    animation: yx-dot-bounce 1.2s infinite ease-in-out;
}

.yx-loading-dots i:nth-child(2) { animation-delay: 0.15s; }
.yx-loading-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes yx-dot-bounce {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.45; }
    40% { transform: scale(1); opacity: 1; }
}

.yx-loading-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 24px;
}

.yx-loading-bars i {
    width: 4px;
    height: 10px;
    border-radius: 2px;
    background-color: var(--yx-brand-primary);
    animation: yx-bar-wave 1s infinite ease-in-out;
}

.yx-loading-bars i:nth-child(2) { animation-delay: 0.1s; }
.yx-loading-bars i:nth-child(3) { animation-delay: 0.2s; }
.yx-loading-bars i:nth-child(4) { animation-delay: 0.3s; }

@keyframes yx-bar-wave {
    0%, 100% { height: 8px; opacity: 0.5; }
    50% { height: 24px; opacity: 1; }
}

.yx-loading-pulse {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--yx-brand-primary);
    animation: yx-pulse 1.2s infinite ease-in-out;
}

@keyframes yx-pulse {
    0% { transform: scale(0.65); opacity: 0.55; }
    70% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.65); opacity: 0.55; }
}

/* 全屏 / 顶部弹层 / 图片层 */
.yx-dialog.yx-dialog-full {
    top: 0;
    left: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    transform: none;
}

.yx-dialog.yx-dialog-full.open {
    transform: none;
}

.yx-dialog.yx-dialog-top {
    top: 8%;
    transform: translate(-50%, 0) scale(0.96);
}

.yx-dialog.yx-dialog-top.open {
    transform: translate(-50%, 0) scale(1);
}

.yx-dialog-image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 16px;
}

.yx-dialog-image img {
    max-width: 100%;
    max-height: 62vh;
    border-radius: var(--yx-radius-md);
}

/* Tips 四方向箭头 */
.yx-tips--left .yx-tips-arrow {
    left: auto;
    right: -4px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%) rotate(-45deg);
}

.yx-tips--right .yx-tips-arrow {
    left: -4px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%) rotate(135deg);
}
