﻿/* ========================================
   移动端响应式样式 - 修复版
   ======================================== */

/* 移动端专用按钮 */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    /* 1. 顶部导航栏 - 固定且紧凑 */
    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 44px;
        min-height: 44px;
        padding: 0 10px;
        z-index: 1000;
        background: var(--bg-secondary);
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .logo h1 {
        font-size: 14px;
        margin-left: 4px;
    }
    
    /* 恢复导航栏 - 改为底部标签栏 */
    .main-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 50px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }

    .nav-link {
        flex: 1;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        border-radius: 0;
        background: transparent !important;
        color: var(--text-secondary);
        position: relative;
    }

    .nav-link.active {
        color: var(--primary-color);
        font-weight: 600;
    }

    .nav-link.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 40%;
        height: 3px;
        background: var(--primary-color);
        border-radius: 0 0 4px 4px;
    }

    /* 头部动作按钮 */
    .header-actions {
        display: flex !important;
        gap: 8px;
    }
    
    .header-actions .btn-icon {
        width: 32px;
        height: 32px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        background: transparent;
        border: none;
    }

    /* 2. 主内容区域 - 让出头部和底部空间 */
    .main-content {
        padding-top: 44px; /* 头部高度 */
        padding-bottom: 50px; /* 底部导航高度 */
        height: 100vh;
        overflow: hidden;
    }
    
    .page {
        height: 100%;
        overflow: hidden;
    }

    /* 3. 编辑器容器 */
    .editor-container {
        display: flex;
        flex-direction: column;
        height: 100%;
        position: relative;
    }

    /* 4. 顶部工具栏 - 抽屉式 */
    .editor-top-toolbar {
        position: fixed;
        top: 44px;
        left: 0;
        width: 100%;
        background: var(--bg-secondary);
        z-index: 900;
        padding: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        transform: translateY(-150%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        gap: 10px;
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .editor-top-toolbar.show-tools {
        transform: translateY(0);
    }
    
    .toolbar-left, .toolbar-center, .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box input {
        flex: 1;
    }

    /* 5. 消息列表 - 修复底部间隙 */
    .message-list {
        flex: 1;
        height: 100%;
        overflow-y: auto;
        padding: 10px;
        padding-bottom: 20px; /* 减少底部留白 */
        -webkit-overflow-scrolling: touch;
        background: var(--bg-primary);
    }
    
    .message-item {
        margin-bottom: 8px;
        padding: 10px;
        background: var(--card-bg);
        border-radius: 8px;
        box-shadow: var(--shadow-sm);
    }
    
    .message-content {
        font-size: 15px;
        line-height: 1.6;
        word-break: break-word;
    }

    /* 6. 底部浮动工具栏 - 移到左下角，无背景 */
    .floating-toolbar {
        position: fixed;
        bottom: 60px; /* 避开底部导航栏 */
        left: 16px; /* 改为左下角 */
        right: auto;
        transform: none;
        z-index: 800;
        background: transparent !important; /* 无背景 */
        border: none !important;
        box-shadow: none !important;
        padding: 0;
        flex-direction: column-reverse; /* 按钮在上，加号在下 */
        align-items: flex-start;
        gap: 8px;
    }
    
    .toolbar-toggle {
        width: 48px;
        height: 48px;
        font-size: 24px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        background: var(--primary-color);
        border-radius: 50%;
    }
    
    /* 工具按钮 - 垂直排列在加号上方 */
    .toolbar-actions {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 0;
        background: transparent;
    }
    
    /* 折叠时隐藏按钮 */
    .floating-toolbar.collapsed .toolbar-actions {
        display: none;
    }
    
    /* 展开时的加号旋转效果 */
    .floating-toolbar:not(.collapsed) .toolbar-toggle {
        transform: rotate(45deg);
    }
    
    .floating-toolbar .btn {
        padding: 10px 14px;
        border-radius: 20px;
        font-size: 13px;
        white-space: nowrap;
        background: var(--card-bg);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        border: 1px solid var(--border-color);
    }
    
    .floating-toolbar .btn-beautify-small {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
    }
    
    .btn-tool {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* 7. 导出按钮修复 - 允许横向滚动 */
    .export-buttons {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px; /* 滚动条空间 */
        -webkit-overflow-scrolling: touch;
    }
    
    .btn-export {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* 8. 其他面板 */
    .filter-panel, .character-panel {
        top: 44px;
        width: 100%;
        height: calc(100vh - 94px); /* 减去头部和底部导航 */
        border-left: none;
        transform: translateX(100%);
    }
    
    .filter-panel.active, .character-panel.active {
        transform: translateX(0);
    }

    /* 9. 上传页面 */
    .upload-container {
        height: 100%;
        overflow-y: auto;
        padding: 16px;
    }
    
    .upload-area {
        min-height: 200px;
    }
    
    /* 10. 预览页面 */
    .preview-container {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .preview-toolbar {
        padding: 10px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .preview-area {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
    }

    /* 11. 底部分页控件 - 在移动端隐藏 */
    .pagination-container.pagination-bottom {
        display: none !important;
    }
}

/* 深色模式适配 */
@media (max-width: 768px) {
    [data-theme="dark"] .main-header,
    [data-theme="dark"] .editor-top-toolbar,
    [data-theme="dark"] .main-nav {
        background: var(--bg-secondary);
        border-color: var(--border-color);
    }
}
