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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* ===== 加载状态 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* ===== 身份验证区域 ===== */
.auth-container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.user-info-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.user-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 20px;
}

.user-avatar img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
    margin-bottom: 8px;
}

#userStatus {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
}

.user-details {
    flex: 1;
}

.user-details h3 {
    margin-bottom: 12px;
    color: #333;
}

.points-info, .level-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px 0;
}

.points-value {
    font-weight: bold;
    color: #667eea;
    font-size: 18px;
}

.level-value {
    color: #764ba2;
    font-weight: 500;
}

.refresh-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.admin-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}

.admin-btn:hover {
    background: #ff5252;
    transform: translateY(-1px);
}

/* ===== 商品区域 ===== */
.products-container {
    padding: 0 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f5f5f5;
}

.product-info {
    padding: 20px;
}

.product-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.product-description {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.4;
}

.product-value {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.value-label {
    color: #666;
}

.value-amount {
    font-weight: 600;
    color: #27ae60;
}

.stock-status {
    margin-bottom: 10px;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.stock-status.normal {
    background: #d4edda;
    color: #155724;
}

.stock-status.low {
    background: #fff3cd;
    color: #856404;
}

.stock-status.out {
    background: #f8d7da;
    color: #721c24;
}

.product-points {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.points-cost {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

.points-label {
    color: #666;
    font-size: 12px;
}

.exchange-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.exchange-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.exchange-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ===== 弹窗样式 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #333;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== 授权弹窗样式 ===== */
.auth-benefits h3 {
    margin-bottom: 15px;
    color: #333;
}

.benefit-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
}

.benefit-item .icon {
    margin-right: 10px;
    font-size: 16px;
}

.privacy-notice {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    color: #666;
}

.privacy-notice .icon {
    margin-right: 10px;
}

/* ===== 兑换弹窗样式 ===== */
.exchange-product-info {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.exchange-product-info img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 15px;
    background: #e9ecef;
}

.product-details {
    flex: 1;
}

.product-details h3 {
    margin-bottom: 8px;
    color: #333;
}

.product-details p {
    color: #666;
    margin-bottom: 10px;
    font-size: 14px;
}

.exchange-points {
    display: flex;
    align-items: center;
}

.points-highlight {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
    margin-left: 5px;
}

.user-points-info {
    background: #e8f4fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.user-points-info p {
    margin-bottom: 5px;
    color: #333;
}

/* ===== 按钮样式 ===== */
.btn-cancel {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #dee2e6;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel:hover {
    background: #e9ecef;
}

.btn-confirm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ===== 状态提示 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.empty-state h3 {
    margin-bottom: 10px;
    font-size: 24px;
}

.empty-state p {
    color: rgba(255, 255, 255, 0.8);
}

/* ===== 错误提示 ===== */
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    z-index: 1000;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.error-content {
    display: flex;
    align-items: center;
}

.error-icon {
    margin-right: 8px;
}

#errorClose {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    margin-left: 10px;
    cursor: pointer;
}

/* ===== 结果弹窗 ===== */
.result-content {
    text-align: center;
    padding: 20px;
}

.result-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.result-success .result-icon {
    color: #28a745;
}

.result-error .result-icon {
    color: #dc3545;
}

.result-content h3 {
    margin-bottom: 10px;
    color: #333;
}

.result-content p {
    color: #666;
    margin-bottom: 15px;
}

.result-points {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.result-points .current {
    color: #666;
    margin-bottom: 5px;
}

.result-points .remaining {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .auth-container {
        padding: 15px;
    }
    
    .user-info-card {
        flex-direction: column;
        text-align: center;
    }
    
    .user-avatar {
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .products-container {
        padding: 0 15px 20px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .exchange-product-info {
        flex-direction: column;
        text-align: center;
    }
    
    .exchange-product-info img {
        margin-right: 0;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-card {
        margin: 0;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }
}

/* ===== 动画效果 ===== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 二维码相关样式 ===== */

/* 我的兑换码按钮 */
.my-codes-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.3s ease;
}

.my-codes-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* 二维码弹窗样式 */
.qr-code-modal {
    max-width: 500px;
    width: 90%;
}

.qr-code-display {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.qr-code-large {
    width: 200px;
    height: 200px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qr-code-details {
    text-align: left;
}

.verify-code-section,
.expire-info {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.verify-code-section label,
.expire-info label {
    font-weight: 600;
    min-width: 70px;
    color: #333;
}

.verify-code-text {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #dc3545;
    letter-spacing: 2px;
}

.qr-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 兑换成功页面二维码区域 */
.qr-code-section {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
}

.qr-code-section h4 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 18px;
}

.qr-display {
    text-align: center;
    margin-bottom: 15px;
}

.qr-display .qr-code-image {
    width: 150px;
    height: 150px;
    border-radius: 10px;
    background: white;
    padding: 10px;
}

.qr-code-info {
    text-align: center;
}

.verify-code {
    font-size: 16px;
    margin-bottom: 8px;
}

.verify-code strong {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 5px;
}

.expire-time {
    font-size: 14px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.usage-hint {
    font-size: 12px;
    opacity: 0.8;
    font-style: italic;
}

/* 我的兑换码页面 */
.page-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.page-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h2 {
    margin: 0;
    color: #333;
}

.page-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.page-close:hover {
    background: #f5f5f5;
}

.page-body {
    padding: 20px;
}

/* 兑换码列表 */
.codes-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.code-item {
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 15px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.code-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.code-product-name {
    font-weight: 600;
    color: #333;
}

.code-status {
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

.code-status.unused {
    background: #d4edda;
    color: #155724;
}

.code-status.used {
    background: #f8d7da;
    color: #721c24;
}

.code-status.expired {
    background: #fff3cd;
    color: #856404;
}

.code-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
}

.code-verify-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.code-verify-code {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #dc3545;
    font-size: 16px;
}

.code-actions {
    display: flex;
    gap: 10px;
}

.code-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.code-btn.show-qr {
    background: #007bff;
    color: white;
}

.code-btn.show-qr:hover {
    background: #0056b3;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .qr-code-modal {
        width: 95%;
        margin: 10px;
    }
    
    .qr-code-large {
        width: 180px;
        height: 180px;
    }
    
    .page-content {
        width: 95%;
        margin: 10px;
    }
    
    .code-details {
        grid-template-columns: 1fr;
    }
    
    .code-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .my-codes-btn {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
    }
}