/* QR Code Widget 样式 */
#qr-code-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 位置设置 */
.qr-widget-bottom-right {
    bottom: 20px;
    right: 20px;
}

.qr-widget-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* 触发按钮 - 改进版本 */
.qr-trigger-btn {
    min-width: 120px; /* 默认就显示完整按钮 */
    height: 50px;
    border-radius: 25px;
    background-color: #007cba;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    padding: 0 20px;
}

.qr-trigger-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background-color: #005a87;
}

.qr-trigger-btn:active {
    transform: scale(0.98);
}

/* 按钮文字始终显示 */
.qr-trigger-text {
    margin-left: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 1; /* 始终显示 */
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

/* 按钮图标 */
.qr-trigger-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.qr-trigger-btn.active .qr-trigger-icon {
    transform: rotate(180deg);
}

/* 二维码面板 - 改进版本 */
.qr-panel {
    position: absolute;
    bottom: 70px; /* 调整位置 */
    right: 0;
    width: 320px; /* 增加宽度 */
    max-height: 80vh; /* 限制最大高度 */
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s ease;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.qr-widget-bottom-left .qr-panel {
    right: auto;
    left: 0;
}

.qr-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 面板头部 */
.qr-panel-header {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* 防止头部被压缩 */
}

.qr-panel-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.qr-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.qr-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 面板内容 - 改进滚动 */
.qr-panel-content {
    padding: 20px;
    max-height: calc(80vh - 80px); /* 减去头部高度 */
    overflow-y: auto;
    overflow-x: hidden;
}

/* 二维码项目 - 改进布局 */
.qr-item {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.qr-item:hover {
    background: #f1f3f4;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qr-item:last-child {
    margin-bottom: 0;
}

.qr-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007cba;
    position: relative;
}

.qr-item-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 2px;
    background: #007cba;
}

.qr-item-image {
    position: relative;
}

.qr-item-image img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
    background: white;
}

.qr-item-image img:hover {
    transform: scale(1.05);
    border-color: #007cba;
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.2);
}

/* 遮罩层 */
.qr-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: -1;
}

.qr-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* 动画效果 */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(0, 124, 186, 0.4);
    }
    70% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(0, 124, 186, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(0, 124, 186, 0);
    }
}

.qr-trigger-btn.pulse {
    animation: pulse 2s infinite;
}

/* 新增：小屏幕下的圆形按钮 */
@media (max-width: 768px) {
    .qr-trigger-btn {
        min-width: 60px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        padding: 0;
    }
    
    .qr-trigger-btn .qr-trigger-text {
        display: none; /* 移动端隐藏文字 */
    }
    
    .qr-trigger-btn:hover {
        min-width: 140px;
        width: auto;
        border-radius: 30px;
        padding: 0 20px;
    }
    
    .qr-trigger-btn:hover .qr-trigger-text {
        display: inline; /* 悬停时显示文字 */
    }
    
    .qr-panel {
        width: 300px;
        bottom: 80px;
    }
    
    .qr-widget-bottom-right {
        right: 15px;
        bottom: 15px;
    }
    
    .qr-widget-bottom-left {
        left: 15px;
        bottom: 15px;
    }
}

@media (max-width: 480px) {
    .qr-panel {
        width: calc(100vw - 30px);
        right: 15px;
        left: 15px;
        bottom: 80px;
        max-height: 70vh;
    }
    
    .qr-widget-bottom-left .qr-panel {
        left: 15px;
    }
    
    .qr-panel-content {
        padding: 15px;
        max-height: calc(70vh - 80px);
    }
    
    .qr-item-image img {
        width: 140px;
        height: 140px;
    }
}

/* 滚动条样式 */
.qr-panel-content::-webkit-scrollbar {
    width: 6px;
}

.qr-panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.qr-panel-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.qr-panel-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 加载状态 */
.qr-item-image.loading img {
    opacity: 0.6;
    filter: blur(1px);
}

.qr-item-image.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #007cba;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}