/* 移动端优化样式 - 客户视角改进 */

/* 移动端底部导航栏 */
.mobile-bottom-nav {
    display: none; /* 默认隐藏，移动端显示 */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 8px 0;
    z-index: 1000;
    justify-content: space-around;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    font-size: 11px;
    color: #666;
    border: none;
    background: none;
    cursor: pointer;
    min-width: 60px;
    transition: all 0.2s;
}

.mobile-bottom-nav .nav-item.active {
    color: #1a237e;
}

.mobile-bottom-nav .nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
}

/* 移动端显示底部导航 */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex !important;
    }
    
    /* 内容区域增加底部间距 - 避免被底部导航遮挡 */
    .content {
        padding-bottom: 80px;
    }
    
    /* 隐藏桌面端元素 */
    .header-right {
        display: none;
    }
    
    /* 显示移动端菜单按钮 */
    #mobile-menu-btn {
        display: block !important;
    }
}

/* 手机端顶部优化 - 紧凑设计 */
@media (max-width: 768px) {
    /* 缩小header高度 */
    .header {
        padding: 0 12px !important;
        height: 48px !important;  /* 从64px减至48px */
    }

    /* 隐藏离线横幅 - 如不需要可删除 */
    #offline-banner {
        display: none !important;
    }

    /* 优化header-right在手机端的显示 */
    .header-right {
        display: flex !important;
        gap: 8px !important;
        align-items: center !important;
    }

    /* 优化移动菜单按钮 */
    #mobile-menu-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 18px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255,255,255,0.15) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        border-radius: 6px !important;
        color: white !important;
        cursor: pointer !important;
    }
}

/* 移动端按钮优化 - 让按钮更大更容易点击 */
@media (max-width: 768px) {
    /* 加大按钮尺寸 - 符合手指触摸标准(44px) */
    .btn, button, .header-btn, .nav-item {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* 表单输入框加大 */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    textarea,
    select {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    /* 表单垂直布局 - 不需要左右滑动 */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 16px;
    }
    
    /* 模态框全屏显示（但保留底部按钮可见） */
    .modal {
        width: 100% !important;
        height: auto !important;          /* ← 改为auto，不撑满屏幕 */
        max-height: calc(100vh - 60px) !important; /* ← 预留底部空间 */
        margin: 10px 0 60px 0;           /* ← 底部预留按钮空间 */
        border-radius: 12px;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    .modal .modal-body {
        overflow-y: auto !important;
        flex: 1 !important;
        min-height: 0 !important;
    }
    .modal .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        flex-shrink: 0 !important;
        background: #f8f9fa !important;
        padding: 14px 24px !important;
    }
    
    /* 表格横向滚动 - 保持table布局 */
    .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
    }
    
    /* 卡片布局优化 */
    .card {
        margin: 12px;
        padding: 16px;
    }

    /* 工作台头部 - 手机端按钮布局优化 */
    .workbench-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    .workbench-header > div[style*="flex"] {
        flex-wrap: wrap;
        width: 100%;
    }
    .workbench-header .btn {
        font-size: 13px !important;
        padding: 8px 12px !important;
        min-height: 40px !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* PWA安装提示 - 避免遮挡底部导航栏 */
    #install-prompt,
    #http-install-guide {
        bottom: 80px !important;  /* 在导航栏上方显示 */
    }
    #http-install-guide button {
        font-size: 12px !important;
        padding: 8px 14px !important;
    }
}

/* 上传进度条样式 */
.upload-progress {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin: 12px 0;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

/* 生成进度提示样式 */
.generate-progress {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.generate-progress .step {
    display: flex;
    align-items: center;
    margin: 12px 0;
    color: #999;
}

.generate-progress .step.active {
    color: #1a237e;
    font-weight: 600;
}

.generate-progress .step.done {
    color: #4caf50;
}

.generate-progress .step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 16px;
}

.generate-progress .step.active .step-icon {
    background: #1a237e;
    color: white;
}

.generate-progress .step.done .step-icon {
    background: #4caf50;
    color: white;
}

/* 新手引导样式 */
.guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.guide-step {
    text-align: center;
    display: none;
}

.guide-step.active {
    display: block;
}

.guide-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.guide-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1a237e;
}

.guide-desc {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
}

.guide-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.guide-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e0e0e0;
    display: inline-block;
    margin: 0 4px;
}

.guide-dot.active {
    background: #1a237e;
}

/* ============ 新增：更完善的移动端优化 ============ */

/* 移动端表格容器 - 横向滚动 */
@media (max-width: 768px) {
    /* 表格外部容器 - 支持横向滚动 */
    .table-container,
    .data-table-container,
    div[style*="overflow-x"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
    }
    
    /* 表格在移动端：保持table布局，外层容器横向滚动 */
    .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 800px;
        width: max-content !important;
        display: table !important;  /* 强制保持table布局，防止变成block */
    }
    
    /* 移动端表头和单元格允许换行 */
    th {
        padding: 10px 8px !important;
        font-size: 12px !important;
        white-space: normal !important;
        word-break: break-word;
    }
    
    td {
        padding: 8px !important;
        font-size: 12px !important;
        white-space: normal !important;
        word-break: break-word;
    }
    
    /* 统计卡片在移动端单列显示 */
    .stats {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* 页面标题在移动端优化 */
    .page h2 {
        font-size: 20px !important;
        margin-bottom: 16px !important;
    }
    
    /* 工具栏在移动端优化 */
    .toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .toolbar .btn {
        width: 100%;
        justify-content: center;
    }
    
    .toolbar input[type="text"],
    .toolbar select {
        width: 100%;
    }
    
    /* 分页在移动端优化 */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .pagination button {
        min-width: 40px;
        min-height: 40px;
    }
    
    /* 内容区域在移动端减少padding */
    .content {
        padding: 16px 12px !important;
    }
    
    /* 卡片在移动端优化 */
    .card {
        margin: 12px 0 !important;
        padding: 16px !important;
        border-radius: 10px !important;
    }
}

/* 移动端横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-overlay .modal {
        max-height: 100vh !important;
        margin: 0 !important;
    }
    
    .mobile-bottom-nav {
        padding: 4px 0 !important;
    }
    
    .mobile-bottom-nav .nav-icon {
        font-size: 18px !important;
        margin-bottom: 2px !important;
    }
}

/* 移动端安全区域适配（iPhone X及以上） */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
    
    .content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
}

/* 移动端触摸优化 */
@media (max-width: 768px) {
    /* 增大点击区域 */
    a, button, .clickable, [onclick] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 禁用长按弹出菜单 */
    * {
        -webkit-touch-callout: none;
    }
    
    /* 优化滚动 */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 防止输入框缩放 */
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* ============ 修复移动端表格和按钮问题 ============ */

@media (max-width: 768px) {
    /* 表格操作按钮不被截断 */
    td .btn,
    td button {
        min-width: auto;
        white-space: nowrap !important;
        padding: 6px 12px !important;
        font-size: 13px !important;
        min-height: 36px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* 表格内标签不被截断 */
    td .tag {
        display: inline-block !important;
        font-size: 11px !important;
        padding: 3px 8px !important;
        white-space: nowrap !important;
    }
    
    /* 确保工具栏不截断按钮 */
    .toolbar .btn-group {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .toolbar .btn-group .btn {
        flex-shrink: 0;
    }
    
    /* 导航栏在移动端优化 */
    .nav {
        display: none !important;  /* 隐藏桌面导航 */
    }
}

/* ============ 紧急修复：确保移动端按钮可见 ============ */

@media (max-width: 768px) {
    /* 强制表格容器可横向滚动 */
    .table-wrap,
    div[class*="table"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
    
    /* 表格最后一行（操作按钮列）不被截断 */
    table tr td:last-child {
        min-width: 120px !important;
        white-space: nowrap !important;
    }
    
    /* 操作按钮组不换行 */
    .btn-group,
    td [class*="btn"],
    td button {
        display: inline-flex !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
    }
    
    /* 确保内容不被底部导航完全挡住 */
    body {
        padding-bottom: 60px !important;
    }
    
    .content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* 弹窗在移动端不被底部导航挡住 */
    .modal-overlay {
        padding-bottom: 60px !important;
    }
}
