/* 全局样式 - 小程序web-view优化 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    height: 100%;
    width: 100%;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(to bottom left, #a8edea 0%, #fed6e3 100%);
    min-height: 100%;
    height: 100%;
    width: 100%;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* 应用容器 - 小程序适配 */
.app-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(82px + env(safe-area-inset-bottom, 0px));
    height: 100%;
    min-height: 100%;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* 页面样式 */
.page {
    display: none;
    width: 100%;
}

.page:first-child {
    display: block;
}

/* 页面头部 */
.page-header {
    text-align: left;
    margin-bottom: 16px;
    padding-top: 4px;
}

.page-header h1 {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 4px;
    font-weight: 600;
    line-height: 1.3;
}

.page-header p {
    font-size: 13px;
    color: #7f8c8d;
    line-height: 1.4;
}

/* 页面内容 */
.page-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* 选择区域样式 */
section {
    background-color: #fff;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
}

section h2 {
    font-size: 15px;
    color: #2c3e50;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.3;
}

section h3 {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 12px;
    font-weight: 500;
    line-height: 1.3;
}

/* 性别选项样式 */
.gender-options, .type-options {
    display: flex;
    gap: 12px;
    width: 100%;
}

.gender-btn, .type-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 15px;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    background-color: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.gender-btn:active, .type-btn:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.gender-btn:hover, .type-btn:hover {
    border-color: #87CEFA;
    color: #87CEFA;
}

.gender-btn.active, .type-btn.active {
    background-color: rgba(135, 206, 250, 0.2);
    color: #333;
    border-color: #87CEFA;
}

/* 标签选项样式 */
.top-type-options, .pants-type-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.top-type-btn {
    padding: 10px 18px;
    font-size: 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    background-color: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.top-type-btn:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.top-type-btn:hover {
    border-color: #87CEFA;
    color: #87CEFA;
}

.top-type-btn.active {
    background-color: rgba(135, 206, 250, 0.2);
    color: #333;
    border-color: #87CEFA;
}

/* 上传区域样式 */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fafafa;
    width: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.upload-area:active {
    transform: scale(0.995);
    opacity: 0.9;
}

.upload-area:hover {
    border-color: #87CEFA;
    background-color: #f0f8ff;
}

.upload-area.dragover {
    border-color: #87CEFA;
    background-color: #e6f3ff;
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.upload-content p {
    color: #999;
    font-size: 14px;
    line-height: 1.4;
}

.preview {
    position: relative;
    display: inline-block;
    width: 100%;
}

.preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

.remove-btn {
    position: absolute;
    top: -8px;
    right: 50%;
    transform: translateX(50%);
    background-color: #ff4757;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.remove-btn:active {
    transform: translateX(50%) scale(0.95);
}

/* 生成按钮样式 */
.generate-btn {
    padding: 14px 32px;
    font-size: 16px;
    border: none;
    border-radius: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
    font-weight: 600;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.generate-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.generate-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    transform: translateY(-1px);
}

.generate-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.status {
    margin-top: 12px;
    text-align: center;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

/* 视频弹窗样式 - 小程序优化 */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.video-modal-content {
    background-color: #fff;
    border-radius: 16px;
    overflow: hidden;
    max-width: 95%;
    max-height: 95%;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.video-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.modal-download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background-color: #667eea;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.modal-download-btn:active {
    background-color: #5a6fd6;
}

.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.modal-close-btn:active {
    background-color: #e9ecef;
}

.video-modal-body {
    padding: 16px;
}

.video-modal-body video {
    width: 100%;
    border-radius: 8px;
    display: block;
}

/* 底部导航栏样式 - 小程序风格 */
.tab-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background-color: #ffffff !important;
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    height: 70px !important;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06) !important;
    z-index: 9999 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 20px !important;
    padding-top: 10px !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #999;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 6px 0;
    box-sizing: border-box;
}

.tab-item:active {
    opacity: 0.7;
}

.tab-item.active {
    color: #667eea;
}

.tab-icon {
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-text {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

/* 历史记录页面样式 */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.history-item {
    background-color: #fff;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
    touch-action: manipulation;
}

.history-item:active {
    opacity: 0.9;
}

.history-thumbnail {
    width: 90px;
    height: 90px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.history-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.history-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
}

.history-time {
    font-size: 13px;
    color: #999;
    line-height: 1.3;
}

.history-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.history-download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #667eea;
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    transition: background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.history-download:active {
    background-color: #5a6fd6;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #999;
    width: 100%;
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.empty-subtitle {
    font-size: 14px;
    margin-top: 8px;
    line-height: 1.4;
}

/* 我的页面样式 */
.user-info-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    width: 100%;
}

.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    flex-shrink: 0;
}

.user-details h3 {
    font-size: 17px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
}

.user-details p {
    font-size: 14px;
    color: #999;
    line-height: 1.4;
}

.menu-list {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:active {
    background-color: #f8f9fa;
}

.menu-icon {
    width: 24px;
    height: 24px;
    margin-right: 14px;
    color: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-text {
    flex: 1;
    font-size: 15px;
    color: #333;
}

.menu-arrow {
    color: #ccc;
    display: flex;
    align-items: center;
}

.version-info {
    text-align: center;
    padding: 24px 20px;
    color: #999;
    font-size: 13px;
    line-height: 1.4;
}

/* 响应式设计 - 小程序web-view优化 */
@media (max-width: 768px) {
    .app-container {
        padding: 10px 14px 66px;
    }
    
    .page-header h1 {
        font-size: 19px;
    }
    
    section {
        padding: 12px 14px;
    }
    
    section h2 {
        font-size: 14px;
    }
    
    section h3 {
        font-size: 13px;
    }
    
    .gender-btn, .type-btn {
        padding: 10px 18px;
        font-size: 14px;
    }
    
    .top-type-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .generate-btn {
        padding: 13px 28px;
        font-size: 15px;
    }
    
    .tab-bar {
        height: 56px;
    }
    
    .history-item {
        padding: 12px;
    }
    
    .history-thumbnail {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 8px 12px 62px;
    }
    
    .page-header {
        margin-bottom: 12px;
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    section {
        padding: 10px 12px;
    }
    
    .gender-btn, .type-btn {
        padding: 9px 16px;
        font-size: 14px;
    }
    
    .top-type-btn {
        padding: 7px 12px;
        font-size: 13px;
    }
    
    .upload-area {
        padding: 20px 14px;
        min-height: 100px;
    }
    
    .upload-icon {
        font-size: 36px;
    }
    
    .generate-btn {
        padding: 12px 24px;
        font-size: 15px;
    }
    
    .history-thumbnail {
        width: 75px;
        height: 75px;
    }
    
    .user-info-card {
        padding: 16px;
    }
    
    .user-avatar {
        width: 56px;
        height: 56px;
    }
    
    .menu-item {
        padding: 14px 16px;
    }
}

/* 小程序web-view专用优化 */
/* 禁用长按选中文本和放大镜 */
img, a, button, input, textarea, select {
    -webkit-touch-callout: none;
    -webkit-user-select: auto;
    user-select: auto;
}

/* 输入框优化 */
input, textarea, select {
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding: 10px 14px;
    background-color: #fff;
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

/* 滚动条美化 - 小程序风格 */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background-color: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.25);
}

/* 防止iOS橡皮筋效果 - 仅应用于body，让容器可滚动 */
body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* 视频全屏优化 - 使用HTML属性实现 */
video {
    max-width: 100%;
    height: auto;
}

/* 图片加载优化 */
img {
    display: block;
    max-width: 100%;
    height: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 按钮禁用状态优化 */
button:disabled, input:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 页面过渡动画 */
.page {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0);
}

/* 底部导航栏安全区域优化 */
.tab-bar {
    padding-top: 2px;
}

/* 安全区域适配 - 增强版 */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-container {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .app-container {
        padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    }
    
    .tab-bar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* 小程序横屏适配 */
@media (orientation: landscape) {
    .app-container {
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    .tab-bar {
        height: 62px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .generate-btn {
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
    }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    /* 预留深色模式样式 */
}

/* 减少动画模式适配 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 信息弹窗样式 - 小程序风格 */
.info-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
}

.info-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.info-modal-content {
    position: relative;
    background-color: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

.info-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fafafa;
}

.info-modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.info-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.info-modal-close:active {
    background-color: #f0f0f0;
    color: #666;
}

.info-modal-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(80vh - 70px);
}

.info-modal-body p {
    margin-bottom: 12px;
    line-height: 1.7;
    color: #555;
    font-size: 15px;
}

.info-modal-body p:last-child {
    margin-bottom: 0;
}

.info-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

.info-modal-body a {
    color: #667eea;
    text-decoration: none;
}

.info-modal-body a:hover {
    text-decoration: underline;
}

/* 弹窗加载状态 */
.info-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #999;
}

.info-modal-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #f0f0f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-top: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 弹窗错误状态 */
.info-modal-error {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.info-modal-error-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
