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

body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa; /* 纯色背景 */
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 10;
}

/* ========== 前台页面样式 ========== */

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    position: relative;
}

h1 {
    color: #4a6fa5;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* 后台管理按钮容器 */
.admin-button-container {
    text-align: center;
    margin: 40px 0;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.admin-link {
    display: inline-block;
    background: #4a6fa5;
    color: white;
    padding: 12px 30px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 1.1rem;
}

.admin-link:hover {
    background: #3a5a8a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 111, 165, 0.3);
}

/* 置顶软件区域 - 竖版卡片 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-controls {
    display: flex;
    gap: 10px;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4a6fa5;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    touch-action: manipulation; /* 改善触摸响应 */
}

.nav-btn:hover {
    background: #3a5a8a;
    transform: scale(1.1);
}

.nav-btn:active {
    transform: scale(0.95);
}

.top-software-container {
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background: white;
    margin-bottom: 50px;
    position: relative;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
    padding: 10px 0;
}

/* 滑动容器 - 关键样式 */
.top-software-slider {
    display: flex;
    padding: 10px 20px;
    cursor: grab;
    user-select: none; /* 防止文本选中 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    will-change: transform; /* 优化动画性能 */
    gap: 15px; /* 卡片间距 */
}

.top-software-slider:active {
    cursor: grabbing;
}

/* 竖版卡片样式 */
.top-software-card {
    flex: 0 0 auto;
    width: calc((100% - 30px) / 3); /* 同时显示3个卡片 */
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid transparent;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    touch-action: pan-y; /* 允许垂直滚动 */
    transform: translateZ(0); /* 硬件加速 */
    -webkit-transform: translateZ(0);
    min-height: 320px; /* 固定高度 */
    position: relative;
    cursor: pointer;
}

.top-software-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.top-software-card.active {
    border-color: #4a6fa5;
    box-shadow: 0 6px 18px rgba(74, 111, 165, 0.2);
}

/* 竖版图标 */
.top-software-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #4a6fa5 0%, #3a5a8a 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: white;
    font-size: 2.5rem;
    flex-shrink: 0;
}

.top-software-icon img {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    object-fit: cover;
}

.top-software-info {
    flex: 1;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.top-software-info h3 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3.2em;
}

.top-software-info p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

/* 下载按钮 - 修复：使用button元素 */
.top-software-info .download-btn {
    display: inline-block;
    background: #4a6fa5;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    width: 100%;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: auto; /* 确保按钮在底部 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
    z-index: 10;
    position: relative;
}

.top-software-info .download-btn:hover {
    background: #3a5a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.3);
}

.top-software-info .download-btn:active {
    transform: translateY(0);
}

/* 横幅结构的软件卡片 */
.software-banners {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 50px;
}

.software-banner {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    border-left: 4px solid #4a6fa5;
}

.software-banner:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.banner-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6a89cc 0%, #4a69bd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.2rem;
    flex-shrink: 0;
}

.banner-icon img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.banner-content {
    flex: 1;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0; /* 防止内容溢出 */
}

.banner-info {
    flex: 1;
    margin-right: 20px;
    min-width: 0;
}

.banner-info h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.banner-info p {
    margin: 0;
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.top-badge {
    display: inline-block;
    background: #f1c40f;
    color: #333;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

/* 修复：非置顶软件不显示置顶图标 */
.top-badge.hidden {
    display: none;
}

.banner-actions {
    flex-shrink: 0;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    background: #4a6fa5;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    text-align: center;
    white-space: nowrap;
    touch-action: manipulation; /* 改善触摸响应 */
}

.btn:hover {
    background: #3a5a8a;
}

.btn i {
    margin-right: 8px;
}

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

.btn-secondary:hover {
    background: #545b62;
}

.btn-danger {
    background: #e74c3c;
}

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

.btn-warning {
    background: #f39c12;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-edit {
    background: #3498db;
}

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

.qrcode-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.qrcode-container img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
}

/* 底部样式 */
footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
    margin-top: 40px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* 滑动指示器 */
.slider-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.slider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ddd;
    transition: all 0.3s;
    cursor: pointer;
    touch-action: manipulation;
}

.slider-dot.active {
    background: #4a6fa5;
    transform: scale(1.2);
}

/* ========== 后台管理样式 ========== */

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f7fa;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #4a6fa5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-header nav {
    display: flex;
    gap: 15px;
}

.admin-header nav a {
    color: #4a6fa5;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 6px;
    transition: all 0.3s;
    border: 1px solid #4a6fa5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-header nav a:hover {
    background: #4a6fa5;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.3);
}

.admin-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 992px) {
    .admin-content {
        grid-template-columns: 1fr;
    }
}

.add-software-section, .manage-software-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.add-software-section h2, .manage-software-section h2 {
    color: #4a6fa5;
    margin-bottom: 25px;
    font-size: 1.5rem;
    border-bottom: 2px solid #f0f5ff;
    padding-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
    font-size: 1rem;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    transition: all 0.3s;
    background: white;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    gap: 10px;
    padding: 8px 0;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.btn-primary {
    background: #4a6fa5;
    color: white;
    padding: 15px 25px;
    width: 100%;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover {
    background: #3a5a8a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 111, 165, 0.3);
}

/* 软件管理网格 */
.admin-software-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.admin-software-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.3s;
}

.admin-software-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.admin-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f5ff;
}

.software-icon-small {
    width: 60px;
    height: 60px;
    background: #4a6fa5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    color: white;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.software-icon-small img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.admin-card-header h3 {
    flex: 1;
    font-size: 1.3rem;
    margin: 0;
    color: #333;
    font-weight: 600;
}

.admin-card-body {
    padding: 15px 0;
}

.admin-card-body p {
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
}

.admin-card-body p strong {
    color: #333;
    margin-right: 8px;
    min-width: 60px;
    display: inline-block;
}

.link-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    background: #f8f9fa;
    padding: 12px 15px;
    border-radius: 6px;
    margin: 15px 0;
    font-family: monospace;
    font-size: 0.9rem;
    border: 1px solid #e9ecef;
}

.admin-card-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #f0f5ff;
}

.admin-card-actions .btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 6px;
    min-height: 44px;
}

.no-data {
    text-align: center;
    padding: 60px 40px;
    color: #999;
    font-style: italic;
    background: white;
    border-radius: 12px;
    border: 2px dashed #e9ecef;
    font-size: 1.1rem;
}

.admin-footer {
    text-align: center;
    padding: 25px;
    color: #666;
    font-size: 0.9rem;
    margin-top: 40px;
    border-top: 1px solid #eee;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* ========== 编辑模态框样式 ========== */
.edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.edit-modal-content {
    background: white;
    border-radius: 15px;
    padding: 35px;
    max-width: 500px;
    width: 90%;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.close-edit-modal {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.close-edit-modal:hover {
    color: #333;
}

.edit-form-group {
    margin-bottom: 25px;
}

.edit-form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
    font-size: 1rem;
}

.edit-form-group input,
.edit-form-group textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    background: white;
}

.edit-form-group input:focus,
.edit-form-group textarea:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.current-files {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.current-files h4 {
    margin-bottom: 15px;
    color: #4a6fa5;
    font-size: 1.1rem;
    padding-bottom: 12px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

.file-preview {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.file-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid #ddd;
    padding: 8px;
    background: white;
    display: block;
}

.file-preview p {
    margin: 10px 0;
    font-size: 0.95rem;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-preview .checkbox-label {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f5ff;
    font-size: 0.95rem;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    /* 前台响应式 */
    .top-software-card {
        width: 280px; /* 手机端固定宽度，可以同时看到部分下一个卡片 */
        min-height: 300px;
        margin-right: 0;
    }
    
    .top-software-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
    
    .top-software-icon img {
        width: 45px;
        height: 45px;
    }
    
    .top-software-info h3 {
        font-size: 1.2rem;
        min-height: 2.8em;
    }
    
    .top-software-info p {
        font-size: 0.9rem;
        -webkit-line-clamp: 2;
    }
    
    .top-software-info .download-btn {
        padding: 14px 20px; /* 增加点击区域 */
        font-size: 1rem;
        min-height: 44px; /* iOS推荐最小点击区域 */
    }
    
    .software-banner {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .banner-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .banner-icon {
        width: 100%;
        height: 60px;
        border-radius: 0;
    }
    
    .banner-actions {
        margin-top: 15px;
        width: 100%;
    }
    
    .banner-actions .btn {
        width: 100%;
        padding: 14px 20px; /* 增加点击区域 */
        min-height: 44px; /* iOS推荐最小点击区域 */
    }
    
    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
        min-height: 44px; /* iOS推荐最小点击区域 */
        min-width: 44px;
    }
    
    /* 后台响应式 */
    .admin-software-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        padding: 20px;
    }
    
    .admin-header nav {
        flex-direction: column;
        width: 100%;
    }
    
    .admin-header nav a {
        justify-content: center;
        padding: 12px;
        min-height: 44px; /* iOS推荐最小点击区域 */
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .admin-card-actions {
        flex-direction: column;
    }
    
    .admin-card-actions .btn {
        width: 100%;
        min-height: 44px; /* iOS推荐最小点击区域 */
    }
    
    .edit-modal-content {
        padding: 25px 20px;
    }
    
    .add-software-section, .manage-software-section {
        padding: 25px 20px;
    }
}

/* 更小的手机屏幕 */
@media (max-width: 480px) {
    .top-software-card {
        width: 260px;
        min-height: 280px;
    }
    
    .top-software-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .top-software-icon img {
        width: 40px;
        height: 40px;
    }
    
    .admin-software-card {
        padding: 20px 15px;
    }
    
    .software-icon-small {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        margin-right: 15px;
    }
    
    .software-icon-small img {
        width: 35px;
        height: 35px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.software-banner, .admin-software-card, .top-software-card {
    animation: fadeIn 0.5s ease-out;
}

/* 滑动动画类 */
.slider-transition {
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 加载动画 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.top-software-card {
    animation: slideInRight 0.4s ease-out;
}

/* 置顶卡片触摸优化 */
.top-software-card * {
    pointer-events: auto; /* 确保所有子元素都可以接收事件 */
}

/* 防止拖动时误触发点击 */
.top-software-slider.dragging .top-software-card {
    pointer-events: none;
}

.top-software-slider.dragging .top-software-card .download-btn {
    pointer-events: none;
}