/**
 * Linux命令查询工具样式
 * @author LinuxCommandsQuery
 */

/* 容器 */
.linux-query-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 搜索区域 */
.search-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.search-title {
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 14px 48px 14px 52px; /* 增加左右padding避免遮挡 */
    font-size: 16px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 0.5;
    pointer-events: none; /* 确保不影响输入框点击 */
}

.search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    z-index: 1; /* 确保在输入框之上 */
}

.search-clear:hover {
    background: rgba(0, 0, 0, 0.2);
}

.search-input:not(:placeholder-shown) + .search-clear {
    display: flex;
}

.category-select {
    padding: 14px 20px;
    font-size: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.category-select:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.search-btn {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    background: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.search-btn:focus {
    outline: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

/* 分类标签 */
.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    color: #64748b;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.category-tag:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.category-tag.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.category-tag-icon {
    font-size: 16px;
}

.category-tag-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    margin-left: 2px;
}

.category-tag.active .category-tag-count {
    background: rgba(255, 255, 255, 0.25);
}

/* 结果统计 */
.result-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.result-count {
    font-size: 15px;
    color: #64748b;
}

.result-count strong {
    color: #667eea;
    font-size: 18px;
}

.result-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.favorite-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorite-filter:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #ef4444;
}

.favorite-filter.active {
    background: #fef2f2;
    border-color: #ef4444;
    color: #ef4444;
}

.favorite-filter-icon {
    font-size: 14px;
}

/* 搜索高亮 */
.highlight {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* 命令列表 */
.commands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.command-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #f1f5f9;
    position: relative;
}

.command-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.command-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-right: 40px; /* 为收藏按钮留出空间 */
}

.command-name {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    font-family: 'Consolas', 'Monaco', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.command-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 12px;
    color: #667eea;
    background: #eef2ff;
    border-radius: 20px;
}

.command-desc {
    font-size: 15px;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 16px;
}

.command-syntax {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #334155;
    margin-bottom: 16px;
    border-left: 3px solid #667eea;
}

.command-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.example-tag {
    display: inline-block;
    padding: 6px 12px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: #059669;
    background: #ecfdf5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-tag:hover {
    background: #d1fae5;
    transform: scale(1.02);
}

/* 命令详情弹窗 */
.command-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.command-modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 20px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

/* 自定义滚动条 */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px 20px 0 0;
    position: relative; /* 为移动端关闭按钮提供定位上下文 */
}

.modal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

.modal-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.modal-nav-counter {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    min-width: 50px;
    text-align: center;
}

.modal-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    font-family: 'Consolas', 'Monaco', monospace;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

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

.detail-label {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-content {
    font-size: 15px;
    color: #334155;
    line-height: 1.7;
}

.detail-syntax {
    background: #1e293b;
    border-radius: 10px;
    padding: 16px 20px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 15px;
    color: #22d3ee;
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    font-size: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
    background: #22c55e;
    border-color: #22c55e;
}

.options-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.options-table th,
.options-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.options-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 13px;
}

.options-table th:first-child {
    border-radius: 8px 0 0 0;
}

.options-table th:last-child {
    border-radius: 0 8px 0 0;
}

.options-table tr:last-child td {
    border-bottom: none;
}

.options-table td {
    font-size: 14px;
    color: #334155;
}

.options-table td:first-child {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #667eea;
    font-weight: 600;
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.example-item {
    background: #1e293b;
    border-radius: 8px;
    padding: 14px 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #a5f3fc;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-item:hover {
    background: #334155;
}

.example-item .copy-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #64748b;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.example-item:hover .copy-hint {
    opacity: 1;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #64748b;
}

.empty-desc {
    font-size: 15px;
}

.empty-state .back-link {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 24px;
    background: #667eea;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.empty-state .back-link:hover {
    background: #5a67d8;
}

/* 快捷提示 */
.quick-tips {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tip-icon {
    font-size: 24px;
}

.tip-text {
    font-size: 14px;
    color: #92400e;
    line-height: 1.5;
}

.tip-text strong {
    color: #78350f;
}

.tip-text kbd {
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin: 0 2px;
}

/* 收藏功能 */
.favorite-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
}

.command-card:hover .favorite-btn {
    opacity: 1;
}

.favorite-btn:hover {
    background: #fef2f2;
    transform: scale(1.1);
}

.favorite-btn.active {
    background: #fef2f2;
    opacity: 1;
}

.favorite-btn.active::before {
    content: '❤️';
}

.favorite-btn:not(.active)::before {
    content: '🤍';
}

/* Toast提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    background: #1e293b;
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: #22c55e;
}

.toast.error {
    background: #ef4444;
}

/* 加载状态 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 响应式 */
@media (max-width: 768px) {
    .linux-query-container {
        padding: 12px;
    }
    
    .search-section {
        padding: 20px;
    }
    
    .search-title {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .search-input-wrapper {
        min-width: 100%;
    }
    
    .category-select,
    .search-btn {
        width: 100%;
    }
    
    .category-tags {
        padding: 16px;
        gap: 8px;
    }
    
    .category-tag {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .quick-tips {
        padding: 12px 16px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .result-stats {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .commands-grid {
        grid-template-columns: 1fr;
    }
    
    .command-card {
        padding: 20px;
    }
    
    .modal-content {
        margin: 10px;
        max-height: 95vh;
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 16px 20px;
        padding-top: 48px; /* 为关闭按钮留出空间 */
        flex-wrap: wrap;
        gap: 12px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-title {
        font-size: 22px;
        order: 1;
        flex: 1 0 100%;
    }
    
    .modal-nav {
        order: 2;
    }
    
    .modal-close {
        order: 3;
        position: absolute;
        top: 16px;
        right: 16px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .options-table {
        display: block;
        overflow-x: auto;
    }
    
    .options-table th,
    .options-table td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .example-item {
        font-size: 13px;
        padding: 12px 14px;
    }
}
