/**
 * 微信浏览器兼容性样式
 * 优化在微信内浏览器的显示效果
 */

/* 微信浏览器检测 */
.wechat-browser {
    /* 微信浏览器特定样式 */
}

/* 微信分享按钮样式 */
.wechat-share-btn {
    background: #07C160;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wechat-share-btn:hover {
    background: #06AD56;
    color: white;
}

.wechat-share-btn:active {
    background: #059748;
    transform: scale(0.98);
}

.wechat-share-btn i {
    font-size: 16px;
}

/* 微信浏览器中的图片预览优化 */
.wechat-browser .preview-image {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.wechat-browser .preview-image:hover {
    transform: scale(1.02);
}

/* 微信浏览器中的视频播放优化 */
.wechat-browser video {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* 微信浏览器中的输入框优化 */
.wechat-browser input[type="text"],
.wechat-browser input[type="search"],
.wechat-browser textarea {
    -webkit-appearance: none;
    border-radius: 6px;
    font-size: 16px; /* 防止iOS缩放 */
}

/* 微信浏览器中的按钮优化 */
.wechat-browser button {
    -webkit-appearance: none;
    border-radius: 6px;
    font-size: 16px; /* 防止iOS缩放 */
}

/* 微信浏览器中的滚动优化 */
.wechat-browser {
    -webkit-overflow-scrolling: touch;
}

.wechat-browser .scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* 微信浏览器中的触摸反馈 */
.wechat-browser .touchable {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 微信浏览器中的字体优化 */
.wechat-browser {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* 微信浏览器中的链接优化 */
.wechat-browser a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* 微信浏览器中的表单优化 */
.wechat-browser .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(7, 193, 96, 0.25);
    border-color: #07C160;
}

/* 微信浏览器中的卡片优化 */
.wechat-browser .card {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 微信浏览器中的导航优化 */
.wechat-browser .navbar {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* 微信浏览器中的模态框优化 */
.wechat-browser .modal {
    -webkit-overflow-scrolling: touch;
}

.wechat-browser .modal-content {
    border-radius: 12px;
}

/* 微信浏览器中的提示框优化 */
.wechat-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    max-width: 80%;
    text-align: center;
    word-wrap: break-word;
}

/* 微信浏览器中的加载动画优化 */
.wechat-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #07C160;
    border-radius: 50%;
    animation: wechat-spin 1s linear infinite;
}

@keyframes wechat-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 微信浏览器中的图标优化 */
.wechat-browser .fa-weixin,
.wechat-browser .fab.fa-weixin {
    color: #07C160;
}

/* 微信浏览器中的分享面板 */
.wechat-share-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px 12px 0 0;
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.wechat-share-panel.show {
    transform: translateY(0);
}

.wechat-share-panel .share-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.wechat-share-panel .share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wechat-share-panel .share-option:hover {
    background: #e9ecef;
    transform: scale(1.05);
}

.wechat-share-panel .share-option i {
    font-size: 24px;
    margin-bottom: 8px;
}

.wechat-share-panel .share-option span {
    font-size: 12px;
    color: #666;
}

/* 微信浏览器中的底部安全区域 */
.wechat-browser {
    padding-bottom: env(safe-area-inset-bottom);
}

/* 微信浏览器中的状态栏适配 */
.wechat-browser .navbar {
    padding-top: env(safe-area-inset-top);
}

/* 微信浏览器中的横屏适配 */
@media screen and (orientation: landscape) {
    .wechat-browser .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* 微信浏览器的网站主题适配 */
[data-theme="dark"] .wechat-browser .wechat-share-panel,
.theme-dark .wechat-browser .wechat-share-panel {
    background: var(--bs-dark-bg, #1a1a1a);
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .wechat-browser .wechat-share-panel .share-option,
.theme-dark .wechat-browser .wechat-share-panel .share-option {
    background: var(--bs-dark-bg-subtle, #2a2a2a);
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .wechat-browser .wechat-share-panel .share-option:hover,
.theme-dark .wechat-browser .wechat-share-panel .share-option:hover {
    background: var(--bs-dark-bg-hover, #3a3a3a);
}

/* 微信浏览器的系统主题适配（备用） */
@media (prefers-color-scheme: dark) {
    body:not([data-theme]) .wechat-browser .wechat-share-panel {
        background: #1a1a1a;
        color: white;
    }

    body:not([data-theme]) .wechat-browser .wechat-share-panel .share-option {
        background: #2a2a2a;
        color: white;
    }

    body:not([data-theme]) .wechat-browser .wechat-share-panel .share-option:hover {
        background: #3a3a3a;
    }
}

/* 微信浏览器中的无障碍优化 */
.wechat-browser .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 通用分享面板 */
.mobile-share-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

/* PC端分享面板样式 */
@media (min-width: 768px) {
    .mobile-share-panel {
        align-items: center;
        justify-content: center;
    }

    .mobile-share-panel .share-content {
        width: 480px;
        max-width: 90vw;
        border-radius: 16px;
        transform: scale(0.9);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    }

    .mobile-share-panel.show .share-content {
        transform: scale(1);
    }

    .mobile-share-panel .share-options-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 24px;
    }

    .mobile-share-panel .share-option {
        padding: 20px 12px;
    }

    .mobile-share-panel .share-option-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .mobile-share-panel .share-option-text {
        font-size: 14px;
    }

    .mobile-share-panel .share-header {
        padding: 24px 24px 20px;
    }

    .mobile-share-panel .share-title {
        font-size: 20px;
    }

    .mobile-share-panel .share-preview {
        padding: 20px 24px;
    }

    .mobile-share-panel .share-footer {
        padding: 20px 24px 24px;
    }

    .mobile-share-panel .share-footer .btn {
        height: 44px;
        font-size: 15px;
    }
}

.mobile-share-panel.show {
    opacity: 1;
    visibility: visible;
}

.mobile-share-panel .share-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.mobile-share-panel .share-content {
    position: relative;
    width: 100%;
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.mobile-share-panel.show .share-content {
    transform: translateY(0);
}

.mobile-share-panel .share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-share-panel .share-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mobile-share-panel .share-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    padding: 4px;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-share-panel .share-close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.mobile-share-panel .share-preview {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-share-panel .share-preview-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mobile-share-panel .share-preview-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.mobile-share-panel .share-preview-text {
    flex: 1;
    min-width: 0;
}

.mobile-share-panel .share-preview-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mobile-share-panel .share-preview-desc {
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mobile-share-panel .share-preview-url {
    font-size: 12px;
    color: #999;
}

.mobile-share-panel .share-options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 20px;
}

.mobile-share-panel .share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.mobile-share-panel .share-option:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

.mobile-share-panel .share-option-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: white;
    font-size: 20px;
}

/* 确保微信图标正确显示 */
.mobile-share-panel .share-option-icon .fab.fa-weixin {
    color: white !important;
    font-family: "Font Awesome 6 Brands", "Font Awesome 5 Brands", sans-serif !important;
    font-weight: 400 !important;
}

/* 微信图标备用方案 - 如果字体图标不显示，使用Unicode */
.mobile-share-panel .share-option-icon .fab.fa-weixin:before {
    content: "\f1d7" !important; /* 微信图标的Unicode */
}

/* 确保其他品牌图标也正确显示 */
.mobile-share-panel .share-option-icon .fab {
    font-family: "Font Awesome 6 Brands", "Font Awesome 5 Brands", sans-serif !important;
    font-weight: 400 !important;
}



.mobile-share-panel .share-option-text {
    font-size: 12px;
    color: #666;
    text-align: center;
    font-weight: 500;
}

.mobile-share-panel .share-footer {
    padding: 16px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.mobile-share-panel .share-footer .btn {
    height: 48px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
}

/* 导航栏分享按钮样式 - 与其他nav-action-btn保持一致 */
.nav-action-btn.share-btn {
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-color, #333);
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.nav-action-btn.share-btn:hover {
    color: var(--primary-color, #1890ff);
    background-color: var(--surface-color, rgba(24, 144, 255, 0.1));
    text-decoration: none;
    transform: translateY(-1px);
}

.nav-action-btn.share-btn:focus {
    outline: 2px solid var(--bs-primary, #007bff);
    outline-offset: 2px;
}

.nav-action-btn.share-btn i {
    font-size: 16px;
}

/* 确保分享按钮在移动端导航菜单中显示 */
@media (max-width: 991.98px) {
    .navbar-collapse .nav-action-btn.share-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 16px;
        margin: 4px 0;
        border-radius: 8px;
        background: transparent;
    }

    .navbar-collapse .nav-action-btn.share-btn:hover {
        background: var(--bs-navbar-hover-color, rgba(0,0,0,0.1));
    }

    .navbar-collapse .nav-action-btn.share-btn .btn-text {
        display: inline;
        margin-left: 8px;
    }
}

/* 主题适配 */
[data-theme="dark"] .nav-action-btn.share-btn,
.theme-dark .nav-action-btn.share-btn {
    color: var(--bs-dark-color, #fff);
}

[data-theme="dark"] .nav-action-btn.share-btn:hover,
.theme-dark .nav-action-btn.share-btn:hover {
    background: var(--bs-dark-bg-subtle, rgba(255,255,255,0.1));
    color: var(--bs-dark-color, #fff);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .mobile-share-panel {
        align-items: flex-end;
    }

    .mobile-share-panel .share-content {
        width: 100%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    .mobile-share-panel.show .share-content {
        transform: translateY(0);
    }

    .mobile-share-panel .share-options-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 16px 20px;
    }

    .mobile-share-panel .share-option {
        padding: 12px 4px;
    }

    .mobile-share-panel .share-option-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .mobile-share-panel .share-option-text {
        font-size: 11px;
    }
}

/* 小屏幕设备的导航按钮适配 */
@media (max-width: 576px) {
    .navbar-nav .nav-action-btn .btn-text {
        display: none;
    }

    .navbar-nav .nav-action-btn {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
    }

    /* 但在折叠菜单中显示文本 */
    .navbar-collapse.show .nav-action-btn .btn-text,
    .navbar-collapse.collapsing .nav-action-btn .btn-text {
        display: inline;
    }

    .navbar-collapse.show .nav-action-btn,
    .navbar-collapse.collapsing .nav-action-btn {
        justify-content: flex-start;
        padding: 12px 16px;
        width: 100%;
    }
}

/* 网站主题适配 - 暗色模式 */
[data-theme="dark"] .mobile-share-panel .share-content,
.theme-dark .mobile-share-panel .share-content {
    background: var(--bs-dark-bg, #1a1a1a);
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .mobile-share-panel .share-title,
.theme-dark .mobile-share-panel .share-title {
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .mobile-share-panel .share-close-btn,
.theme-dark .mobile-share-panel .share-close-btn {
    color: var(--bs-dark-color-muted, #ccc);
}

[data-theme="dark"] .mobile-share-panel .share-close-btn:hover,
.theme-dark .mobile-share-panel .share-close-btn:hover {
    background: var(--bs-dark-bg-subtle, #333);
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .mobile-share-panel .share-preview-title,
.theme-dark .mobile-share-panel .share-preview-title {
    color: var(--bs-dark-color, white);
}

[data-theme="dark"] .mobile-share-panel .share-preview-desc,
.theme-dark .mobile-share-panel .share-preview-desc {
    color: var(--bs-dark-color-muted, #ccc);
}

[data-theme="dark"] .mobile-share-panel .share-preview-url,
.theme-dark .mobile-share-panel .share-preview-url {
    color: var(--bs-dark-color-subtle, #999);
}

[data-theme="dark"] .mobile-share-panel .share-option:hover,
.theme-dark .mobile-share-panel .share-option:hover {
    background: var(--bs-dark-bg-subtle, #333);
}

[data-theme="dark"] .mobile-share-panel .share-option-text,
.theme-dark .mobile-share-panel .share-option-text {
    color: var(--bs-dark-color-muted, #ccc);
}

[data-theme="dark"] .mobile-share-panel .share-header,
.theme-dark .mobile-share-panel .share-header {
    border-bottom-color: var(--bs-dark-border-color, #333);
}

[data-theme="dark"] .mobile-share-panel .share-preview,
.theme-dark .mobile-share-panel .share-preview {
    border-bottom-color: var(--bs-dark-border-color, #333);
}

[data-theme="dark"] .mobile-share-panel .share-backdrop,
.theme-dark .mobile-share-panel .share-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

/* 系统主题适配（备用） */
@media (prefers-color-scheme: dark) {
    body:not([data-theme]) .mobile-share-panel .share-content {
        background: #1a1a1a;
        color: white;
    }

    body:not([data-theme]) .mobile-share-panel .share-title {
        color: white;
    }

    body:not([data-theme]) .mobile-share-panel .share-close-btn {
        color: #ccc;
    }

    body:not([data-theme]) .mobile-share-panel .share-close-btn:hover {
        background: #333;
        color: white;
    }

    body:not([data-theme]) .mobile-share-panel .share-preview-title {
        color: white;
    }

    body:not([data-theme]) .mobile-share-panel .share-preview-desc {
        color: #ccc;
    }

    body:not([data-theme]) .mobile-share-panel .share-preview-url {
        color: #999;
    }

    body:not([data-theme]) .mobile-share-panel .share-option:hover {
        background: #333;
    }

    body:not([data-theme]) .mobile-share-panel .share-option-text {
        color: #ccc;
    }

    body:not([data-theme]) .mobile-share-panel .share-header {
        border-bottom-color: #333;
    }

    body:not([data-theme]) .mobile-share-panel .share-preview {
        border-bottom-color: #333;
    }
}

/* 分享提示样式 */
.share-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    max-width: 80%;
    text-align: center;
    word-wrap: break-word;
    animation: shareToastFadeIn 0.3s ease;
}

@keyframes shareToastFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 微信浏览器中的打印样式 */
@media print {
    .wechat-browser .wechat-share-btn,
    .wechat-browser .wechat-share-panel,
    .mobile-share-panel {
        display: none !important;
    }
}
