/* styles.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.header h1 {
    font-size: 1.5rem;
    color: #1a73e8;
    font-weight: 500;
}

/* 工具栏样式 */
.toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    min-width: 44px; /* 确保触控区域足够大 */
    min-height: 44px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover, .btn:active {
    background-color: #1557b0;
    transform: scale(0.95);
}

.btn i {
    font-size: 1.2rem;
}

/* 选择模式工具栏 */
.selection-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: #e8f0fe;
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.selection-toolbar span {
    font-size: 0.9rem;
    color: #4b5563;
}

/* 路径导航样式 */
.path-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch; /* 优化移动端滑动 */
}

.path-item {
    color: #1a73e8;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.path-item:hover {
    background-color: #e8f0fe;
}

.path-separator {
    color: #6b7280;
}

/* 主内容区域 */
.main-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    max-height: calc(100vh - 200px); /* 限制高度，避免滚动条 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 目录和文件列表 */
.directory-list, .file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.directory-item, .file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation; /* 优化触控 */
}

.directory-item:hover, .file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.file-item.selected {
    background-color: #e8f0fe;
    border: 1px solid #1a73e8;
}

.file-checkbox {
    width: 20px;
    height: 20px;
}

.directory-icon, .file-icon {
    font-size: 1.5rem;
    color: #1a73e8;
    flex-shrink: 0;
}

.directory-name, .file-info {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

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

.modal-content {
    background-color: white;
    padding: 1.25rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease-in;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
}

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

.modal-body {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: #4b5563;
}

.modal-body input, .modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    background-color: #f9fafb;
}

.modal-body textarea {
    height: 120px;
    resize: vertical;
}

.file-content {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: #f9fafb;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* 提示消息 */
.result {
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

.result.success {
    background-color: #d4edda;
    color: #155724;
}

.result.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* 右键/长按菜单 */
.context-menu {
    position: fixed;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    list-style: none;
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 150px;
}

.context-menu li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.context-menu li:hover {
    background-color: #e8f0fe;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .toolbar {
        justify-content: center;
        width: 100%;
    }

    .btn {
        flex: 1;
        padding: 0.75rem;
        min-width: 0;
    }

    .directory-list, .file-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
        max-height: 85vh;
    }

    .modal-body input, .modal-body textarea {
        font-size: 1rem; /* 增大字体，方便触控 */
    }

    .file-content {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }

    .path-nav {
        font-size: 0.85rem;
    }

    .btn {
        padding: 0.6rem;
    }

    .directory-item, .file-item {
        padding: 0.6rem;
    }

    .directory-icon, .file-icon {
        font-size: 1.3rem;
    }

    .directory-name, .file-info {
        font-size: 0.85rem;
    }
}