/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    text-size-adjust: 100%;
}

/* 头部导航样式 */
.header {
    background: #3490dc;
    color: white;
    padding: 0.75rem 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 1.2rem;
    font-weight: bold;
    flex: 1;
    text-align: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
}

.cart-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-btn:hover {
    background: rgba(255,255,255,0.3);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

/* 主要内容区域 */
.main-content {
    margin-top: 30px;
    padding: 0.5rem 1rem;
    min-height: calc(100dvh - 70px);
    min-height: calc(100svh - 70px);
}

.video-player-main {
    margin-top: 70px;
    padding: 1rem;
    min-height: calc(100dvh - 70px);
    min-height: calc(100svh - 70px);
}

.cart-main {
    margin-top: 30px;
    min-height: calc(100dvh - 70px);
    min-height: calc(100svh - 70px);
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

/* 视频网格样式 */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding: 0.25rem 0;
}

.video-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

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

.video-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 3rem;
    position: relative;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    z-index: 10;
}

.delete-btn:hover {
    background: rgba(220, 53, 69, 1);
}

.video-info {
    padding: 1rem;
}

.video-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.video-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
    
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 单行截断用于与按钮同行时更紧凑 */
.video-header-row .video-title {
    margin-bottom: 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-header-row .video-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* 新增：标题居中，按钮一行左右分布 */
.video-title-center {
    text-align: center;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.video-actions-row {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start; /* 两个按钮都靠左排列 */
    align-items: center;
}

/* 保证在flex布局下不被老样式影响，全部靠左 */
.video-actions-row > .btn.btn-primary,
.video-actions-row > .btn.btn-secondary,
.video-actions-row > span {
    margin-right: 0; /* 去除潜在的自适应对齐 */
}

.video-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

.video-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* 视频播放器样式 */
.video-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 2rem;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.video-container video {
    width: 100%;
    height: auto;
    display: block;
}

.video-info {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.video-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #333;
}

.video-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* 购物车样式 */
.cart-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 70px);
    min-height: calc(100svh - 70px);
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

.cart-items {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(200px + env(safe-area-inset-bottom));
    max-width: 100%;
    box-sizing: border-box;
}

.cart-item {
    background: white;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid #eee;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.cart-item-thumbnail {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.5rem;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #333;
}

.cart-item-price {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1.1rem;
}

.cart-item-remove {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.cart-item-remove:hover {
    background: #c82333;
}

/* 购物车商品样式优化 - 合并到上面的.cart-item中 */

.cart-item-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 5px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.5rem;
}

.cart-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.cart-item-thumbnail i {
    font-size: 24px;
    color: #999;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    font-size: 16px;
    font-weight: 600;
    color: #e74c3c;
}

.cart-item-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.cart-item-remove:hover {
    background: #c0392b;
}

.cart-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 5;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    max-width: 100vw;
    box-sizing: border-box;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cart-summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-summary-label {
    color: #666;
    font-size: 0.9rem;
}

.cart-summary-value {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.checkout-btn {
    width: 100%;
    background: #3490dc;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.checkout-btn:hover {
    background: #2980b9;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #3490dc;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    border-radius: 10px;
    margin: 2rem 0;
}

.empty-content {
    max-width: 400px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #666;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #999;
    margin-bottom: 2rem;
}

.empty-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.empty-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - 70px);
    min-height: calc(100svh - 70px);
    text-align: center;
    padding: 1rem;
    background: transparent;
    border-radius: 0;
    margin: 0;
}

.empty-cart-content {
    max-width: 400px;
    margin: 0 auto;
    background: white;
    padding: 2rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.empty-cart-icon {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.empty-cart h3 {
    color: #666;
    margin-bottom: 0.5rem;
}

.empty-cart p {
    color: #999;
    margin-bottom: 2rem;
}

/* 加载指示器 */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.9);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    z-index: 1000;
    display: none;
}

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

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

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
    opacity: 0;
    pointer-events: none;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

.notification.warning {
    background: #ffc107;
    color: #333;
}

/* 支付页面样式 */
.pay-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.pay-page {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(33.33vh + 300px);
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    overflow-y: auto;
}

.pay-page.show {
    transform: translateY(0);
}

.pay-overlay.show {
    display: block;
}

.pay-content {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

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

.close-pay-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.pay-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.order-info, .payment-methods {
    margin-bottom: 20px;
}

.order-info h4, .payment-methods h4 {
    margin-bottom: 10px;
    color: #333;
}

.order-details {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.order-item:last-child {
    margin-bottom: 0;
    font-weight: bold;
    font-size: 1.1rem;
}

.payment-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-option {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.payment-option:hover {
    border-color: #3490dc;
}

.payment-option input[type="radio"] {
    margin-right: 10px;
}

.payment-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.pay-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.pay-btn {
    flex: 1;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: bold;
}

/* 支付成功页面 */
.payment-success {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-content {
    background: white;
    padding: 3rem 2rem;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    margin: 0 1rem;
}

.success-icon {
    font-size: 4rem;
    color: #28a745;
    margin-bottom: 1rem;
}

.success-content h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.success-content p {
    color: #666;
    margin-bottom: 2rem;
}

.success-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* 欢迎页面样式 */
.welcome-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 70px);
    padding: 2rem;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
    background: white;
    padding: 3rem 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.welcome-icon {
    font-size: 4rem;
    color: #3490dc;
    margin-bottom: 1.5rem;
}

.welcome-title {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 1rem;
}

.welcome-description {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-btn {
    min-width: 150px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        padding: 0 0.5rem;
    }
    
    .main-content, .cart-main {
        margin-top: 10px;
        min-height: calc(100dvh - 60px);
        min-height: calc(100svh - 60px);
    }

   .video-player-main {
        margin-top: 70px;
        min-height: calc(100dvh - 60px);
        min-height: calc(100svh - 60px);
    }

    
    .video-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.25rem 0;
    }
    
    .video-card {
        margin-bottom: 0.5rem;
    }
    
    .cart-items {
        padding: 0.5rem;
        padding-bottom: calc(200px + env(safe-area-inset-bottom));
    }
    
    .cart-item {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .cart-item-thumbnail {
        width: 60px;
        height: 45px;
    }
    
    .empty-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .success-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .pay-page {
        height: calc(50dvh + 200px);
        height: calc(50svh + 200px);
    }
}

/* Safari兼容性修复 */
@supports (-webkit-appearance: none) {
    .checkout-btn {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 10px;
        border-radius: 10px;
        display: block;
        visibility: visible;
        opacity: 1;
        position: relative;
        z-index: 10;
        min-height: 50px;
        line-height: 1.2;
    }
    
    .cart-footer {
        min-height: 140px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        position: relative;
        z-index: 5;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
    
    .cart-items {
        position: relative;
        z-index: 1;
        min-height: 0;
    }
}

/* iOS Safari特殊处理 */
@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .cart-items {
        padding-bottom: 250px; /* 为绝对定位的底部区域预留更多空间 */
    }
    
    .cart-footer {
        padding-bottom: calc(1rem + 10px); /* 为Safari底部工具栏预留更多空间 */
        margin-bottom: 0px; /* 保持底部定位，不向上移动 */
        /* 确保绝对定位正确 */
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
    }
    
    .checkout-btn {
        margin-bottom: max(20px, env(safe-area-inset-bottom)); /* 确保按钮不被遮挡 */
    }
}
