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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器 */
.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* 头部 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 20px;
    text-align: center;
}

.title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
}

/* 搜索区域 */
.search-wrapper {
    padding: 20px;
    position: relative;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    height: 50px;
    padding: 0 48px 0 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-btn {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--border-color);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.clear-btn.show {
    display: flex;
}

.clear-btn:hover {
    background: var(--text-secondary);
    color: white;
}

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

/* 建议列表 */
.suggestions {
    margin: 8px 20px 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    min-height: 50px;
    font-size: 15px;
}

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

.suggestion-item:hover,
.suggestion-item.active {
    background: #f1f5f9;
}

.suggestion-item:active {
    background: #e2e8f0;
}

.suggestion-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 8px;
}

.suggestion-desc {
    color: var(--text-secondary);
    font-size: 13px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 分类区域 */
.categories-section {
    padding: 0 20px 20px;
    margin-top: 8px;
}

.categories-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 16px;
    padding-left: 4px;
}

.categories-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.category-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: var(--shadow-sm);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-card:active {
    transform: translateY(0);
}

.category-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.category-count {
    font-size: 12px;
    opacity: 0.9;
}

/* 面包屑导航 */
.breadcrumb {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--text-color);
    font-weight: 500;
}

/* 分类徽章 */
.category-badge {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: transform 0.2s;
}

.category-badge:hover {
    transform: translateY(-2px);
}

/* 相关命令 */
.related-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.related-cmd {
    display: inline-block;
    padding: 8px 16px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.related-cmd:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* 命令详情 */
.command-detail {
    padding: 0 20px 20px;
    display: none;
}

.command-detail.show {
    display: block;
}

.detail-card {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    flex: 1;
}

/* 分享按钮 */
.share-buttons {
    position: relative;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.share-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.share-btn svg {
    flex-shrink: 0;
}

.share-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.share-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

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

.share-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.share-item svg {
    flex-shrink: 0;
}

/* 分享平台颜色 */
.share-item[data-platform="weibo"]:hover {
    color: #e6162d;
}

.share-item[data-platform="twitter"]:hover {
    color: #1da1f2;
}

.share-item[data-platform="facebook"]:hover {
    color: #1877f2;
}

.share-item[data-platform="linkedin"]:hover {
    color: #0a66c2;
}

.share-item[data-platform="copy"]:hover {
    color: var(--primary-color);
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.section-content {
    font-size: 15px;
    color: var(--text-color);
    line-height: 1.7;
}

.syntax-code {
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.options-list,
.examples-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.options-list li,
.examples-list li {
    background: white;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
    font-size: 14px;
    line-height: 1.6;
}

.options-list li:last-child,
.examples-list li:last-child {
    margin-bottom: 0;
}

.example-code {
    font-family: 'Courier New', Courier, monospace;
    color: var(--primary-color);
    font-weight: 600;
}

/* 页脚 */
.footer {
    padding: 16px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

/* 滚动条样式 */
.suggestions::-webkit-scrollbar {
    width: 8px;
}

.suggestions::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.suggestions::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.suggestions::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 平板和桌面端优化 */
@media (min-width: 768px) {
    body {
        padding: 32px;
    }

    .container {
        max-width: 700px;
    }

    .header {
        padding: 32px 24px;
    }

    .title {
        font-size: 32px;
    }

    .subtitle {
        font-size: 16px;
    }

    .search-wrapper {
        padding: 24px;
    }

    .search-input {
        height: 54px;
        font-size: 17px;
    }

    .command-detail {
        padding: 0 24px 24px;
    }

    .detail-card {
        padding: 24px;
    }

    .suggestions {
        margin: 8px 24px 0;
    }

    .categories-section {
        padding: 0 24px 24px;
        margin-top: 8px;
    }

    .categories-container {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

    .category-card {
        padding: 20px 16px;
        min-height: 90px;
    }

    .category-name {
        font-size: 16px;
    }

    .detail-title {
        font-size: 28px;
    }
}

/* 移动端分享按钮优化 */
@media (max-width: 480px) {
    .detail-header {
        flex-wrap: wrap;
    }

    .share-btn span {
        display: none;
    }

    .share-btn {
        padding: 8px;
        min-width: 36px;
        justify-content: center;
    }
}

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

.suggestions.show {
    animation: fadeIn 0.2s ease;
}

.command-detail.show {
    animation: fadeIn 0.3s ease;
}

/* 触摸反馈 */
@media (hover: none) {
    .suggestion-item:active {
        background: #e2e8f0;
    }

    .clear-btn:active {
        transform: scale(0.9);
    }
}
