/* ========================================
   扫码前端样式
   ======================================== */

/* ========== CSS 变量（主题配置） ========== */
:root {
    /* 主色调 */
    --primary-color: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;

    /* 背景色 */
    --bg-color: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* 文字色 */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* 其他 */
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ========== 重置样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 防止页面滚动弹性效果 */
    overscroll-behavior: none;
}

body {
    opacity: 1 !important;
    transition: opacity 0.2s ease;
}

/* ========== 视图容器 ========== */
.view {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.view.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== 加载状态 ========== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== 错误提示 ========== */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-message {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.6;
}

/* ========== 图文展示 ========== */
.image-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

/* 默认模式：无文字内容时，图片也有卡片框 */
.image-container.image-only {
    justify-content: flex-start;
    padding: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

.image-container.image-only .image-wrapper {
    width: 100%;
    padding: 8px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.image-container.image-only .scan-image {
    width: 100%;
    border-radius: 12px;
}

/* 有内容模式：图片和文字自动铺满整屏 */
.image-container.with-content {
    justify-content: flex-start;
    padding: 16px;
    gap: 16px;
    height: 100vh;
    min-height: 100vh;
    box-sizing: border-box;
}

.image-container.with-content .image-wrapper {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container.with-content .scan-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.image-container.with-content .content-section {
    flex: 0 0 auto;
}

.image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.image-link {
    display: block;
    width: 100%;
}

.scan-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
    /* 防止图片被长按选中时的高亮 */
    -webkit-touch-callout: default;
    -webkit-user-select: none;
    user-select: none;
}

/* 图片加载动画 */
.scan-image {
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.scan-image.loaded {
    opacity: 1;
}

/* ========== 内容区域（卡片样式） ========== */
.content-section {
    width: 100%;
    padding: 20px 24px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.content-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    letter-spacing: 0.02em;
}

/* ========== 跳转中 ========== */
.redirect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.redirect-text {
    margin-top: 20px;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.redirect-fallback {
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.redirect-fallback a {
    color: var(--primary-color);
    text-decoration: none;
}

.redirect-fallback a:hover {
    text-decoration: underline;
}

/* ========== 微信提示 ========== */
.wechat-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.wechat-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.wechat-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.wechat-message {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== 响应式适配 ========== */
@media screen and (max-width: 375px) {

    .loading-text,
    .error-message,
    .redirect-text {
        font-size: 14px;
    }

    .content-text {
        font-size: 14px;
    }
}

/* ========== 暗色模式支持（可选） ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;
    }

    .image-container {
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    }

    .image-container.image-only {
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    }

    .image-container.image-only .image-wrapper {
        background: #1e293b;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }

    .content-section {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    }

    .image-container.with-content .image-wrapper {
        background: #1e293b;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
}

/* ========== 安全区域适配（iPhone X 及以上） ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {

    .image-container,
    .content-section {
        padding-bottom: env(safe-area-inset-bottom);
    }
}