/* 模块市场样式 */

/* 市场容器 */
.market-container {
    padding: 2.5rem 0;
}

/* ==================== 市场头部 ==================== */
.market-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

/* 遗留市场链接 */
.legacy-market-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: rgba(var(--text-secondary-rgb), 0.05);
    color: var(--text-secondary);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.25s ease;
}

.legacy-market-link:hover {
    background: rgba(var(--text-secondary-rgb), 0.1);
    color: var(--text);
    transform: translateY(-1px);
}

/* 提交模块链接 - 融入分类按钮区域 */
.submit-module-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.3rem;
    border-radius: 50px;
    background: rgba(var(--primary-rgb), 0.04);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb), 0.12);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin-left: auto;
    cursor: pointer;
    font-family: inherit;
}

.submit-module-link:hover {
    background: rgba(var(--primary-rgb), 0.08);
    border-color: rgba(var(--primary-rgb), 0.2);
    transform: translateY(-1px);
}

/* ==================== 搜索框 ==================== */
.search-container {
    position: relative;
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 0.9rem 1.2rem 0.9rem 3.5rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    border-color: rgba(var(--primary-rgb), 0.5);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.06), 0 2px 8px rgba(var(--primary-rgb), 0.08);
    transform: translateY(-1px);
}

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

.search-input::placeholder {
    transition: opacity 0.2s ease;
    color: var(--text-secondary);
}

.search-input:focus::placeholder {
    opacity: 0.6;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: color 0.25s ease;
}

.search-input:focus + .search-icon,
.search-input:focus ~ .search-icon {
    color: var(--primary);
}

/* ==================== 统计信息 ==================== */
.market-stats {
    margin: 2rem 0;
}

.stats-grid {
    background: transparent;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: none;
    border: none;
}

.stat-card {
    background: var(--card-bg);
    text-align: center;
    padding: 1.8rem;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 0;
}

.stat-card:hover {
    background: var(--card-bg);
    box-shadow: var(--shadow-hover);
    border-color: rgba(var(--primary-rgb), 0.12);
    transform: translateY(-2px) scale(1.005);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    line-height: 1;
    color: var(--primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

/* 高亮卡片样式 */
.stat-card-highlight {
    background: var(--card-bg);
    border-color: rgba(var(--primary-rgb), 0.15);
    box-shadow: var(--shadow-card), 0 0 0 0.5px rgba(var(--primary-rgb), 0.08);
}

.stat-card-highlight::before {
    opacity: 0;
}

.stat-card-highlight:hover {
    border-color: rgba(var(--primary-rgb), 0.25);
    box-shadow: var(--shadow-hover), 0 0 0 0.5px rgba(var(--primary-rgb), 0.12);
}


/* ==================== 分类按钮 ==================== */
.module-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.category-btn {
    padding: 0.6rem 1.3rem;
    border-radius: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.01em;
}

.category-btn:hover {
    background: rgba(var(--primary-rgb), 0.04);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
    transform: translateY(-1px);
}

.category-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.18), 0 0 0 0.5px rgba(var(--primary-rgb), 0.1);
}

/* ==================== 模块网格 ==================== */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.8rem;
}

/* ==================== 模块卡片 ==================== */
.module-card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: 1.8rem;
    box-shadow: var(--shadow-card);
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.module-card:hover {
    transform: translateY(-3px) scale(1.005);
    box-shadow: var(--shadow-hover);
    border-color: rgba(var(--primary-rgb), 0.12);
}

/* 模块头部 */
.module-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

/* 模块图标 */
.module-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(var(--primary-rgb), 0.06);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.module-card:hover .module-icon {
    background: rgba(var(--primary-rgb), 0.1);
    transform: scale(1.04);
}

/* 模块名称 */
.module-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--text);
    transition: color 0.25s ease;
}

.module-card:hover .module-name {
    color: var(--primary);
}

/* 模块版本 */
.module-version {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(var(--primary-rgb), 0.08);
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    display: inline-block;
    font-weight: 500;
}

/* 模块描述 */
.module-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 模块标签 */
.module-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.module-tag {
    font-size: 0.75rem;
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    background: rgba(var(--primary-rgb), 0.06);
    color: var(--primary);
    font-weight: 500;
    border: 1px solid rgba(var(--primary-rgb), 0.08);
    transition: all 0.25s ease;
}

.module-tag:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: rgba(var(--primary-rgb), 0.15);
    transform: translateY(-1px);
}

/* 模块底部 */
.module-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: auto;
    flex-shrink: 0;
}

.module-author {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.module-actions {
    display: flex;
    gap: 0.7rem;
}

/* 模块按钮 */
.module-btn {
    padding: 0.5rem 1rem;
    border-radius: 50px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.15), 0 4px 12px rgba(var(--primary-rgb), 0.08);
}

.module-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.18), 0 8px 20px rgba(var(--primary-rgb), 0.12);
}

.module-btn:active {
    transform: scale(0.97) translateY(0);
}

/* 次要按钮 */
.module-btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
}

.module-btn.secondary:hover {
    background: rgba(var(--primary-rgb), 0.04);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--border);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1.3rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* ==================== 加载状态 ==================== */
.loading-state {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .market-container {
        padding: 1.2rem 0;
    }
    
    .market-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .search-container {
        order: -1;
        min-width: 100%;
        max-width: none;
    }
    
    .search-input {
        font-size: 1rem;
        padding: 0.9rem 1rem 0.9rem 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.2rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .module-categories {
        gap: 0.6rem;
    }
    
    .category-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.2rem;
    }
    
    .module-card {
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.2rem;
    }
    
    .stat-card-highlight {
        grid-column: 1 / -1; /* 总模块数占满一行 */
    }
    
    .stat-number {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .module-grid {
        grid-template-columns: 1fr;
    }
    
    .module-header {
        flex-direction: column;
        text-align: center;
    }
    
    .module-icon {
        margin-right: 0;
        margin-bottom: 0.8rem;
    }
    
    .module-footer {
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch;
    }
    
    .module-actions {
        justify-content: stretch;
    }
    
    .module-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ==================== 模块徽章 ==================== */
.module-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 50px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-official {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-unverified {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .badge-official {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

[data-theme="dark"] .badge-unverified {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* ==================== 提交模块模态框 ==================== */
.submit-modal {
    max-width: 640px;
}

.submit-login-state {
    text-align: center;
    padding: 3rem 1rem;
}

.submit-login-icon {
    font-size: 4rem;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.submit-login-state h4 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.submit-login-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.submit-login-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.submit-login-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid var(--border);
    font-family: inherit;
}

.btn-github-login {
    background: #24292e;
    color: white;
    border-color: #24292e !important;
}

.btn-github-login:hover {
    background: #2f363d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(36, 41, 46, 0.3);
}

.btn-codeberg-login {
    background: var(--card-bg);
    color: var(--text);
}

.btn-codeberg-login:hover {
    background: rgba(0, 136, 204, 0.08);
    border-color: #0088cc;
    color: #0088cc;
    transform: translateY(-2px);
}

.btn-codeberg-login .btn-icon-svg {
    width: 18px;
    height: 18px;
}

.btn-yunhu-login {
    background: var(--card-bg);
    color: var(--text);
}

.btn-yunhu-login:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-2px);
}

.btn-yunhu-login img {
    border-radius: 3px;
}

[data-theme="dark"] .btn-codeberg-login:hover {
    background: rgba(0, 136, 204, 0.15);
}

[data-theme="dark"] .btn-yunhu-login:hover {
    background: rgba(59, 130, 246, 0.15);
}

.submit-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(var(--primary-rgb), 0.04);
    border-radius: 14px;
    margin-bottom: 1.5rem;
}

.submit-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.submit-user-name {
    flex: 1;
    font-weight: 600;
    color: var(--text);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.btn-outline:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
}

/* ==================== 提交表单 ==================== */
.submit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.form-group > label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: rgba(var(--primary-rgb), 0.5);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.06);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
    appearance: auto;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-check {
    flex-direction: row;
    align-items: center;
}

.form-check label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400 !important;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.submit-form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ==================== 提交成功/失败 ==================== */
.submit-success-state,
.submit-error-state {
    text-align: center;
    padding: 2.5rem 1rem;
}

.submit-success-icon {
    font-size: 3.5rem;
    color: #22c55e;
    margin-bottom: 1rem;
}

.submit-error-icon {
    font-size: 3.5rem;
    color: #ef4444;
    margin-bottom: 1rem;
}

.submit-success-state h4,
.submit-error-state h4 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.submit-success-state p,
.submit-error-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ==================== 提交按钮响应式 ==================== */
@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .submit-modal {
        max-width: 100%;
    }
}

/* ==================== 提交标签页 ==================== */
.submit-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.submit-tab {
    flex: 1;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.submit-tab:hover {
    color: var(--text);
}

.submit-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==================== 我的模块列表 ==================== */
.my-modules-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.my-modules-loading,
.my-modules-empty,
.my-modules-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.my-modules-empty i,
.my-modules-loading i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    color: var(--border);
}

.my-modules-hint {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

.my-module-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    gap: 0.75rem;
    transition: all 0.25s ease;
}

.my-module-item:hover {
    border-color: rgba(var(--primary-rgb), 0.15);
    box-shadow: var(--shadow-sm);
}

.my-module-info {
    flex: 1;
    min-width: 0;
}

.my-module-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.my-module-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-module-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    opacity: 0.7;
}

.my-module-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.my-module-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 50px;
    font-weight: 600;
}

.badge-verified {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .badge-verified {
    color: #4ade80;
}

[data-theme="dark"] .badge-pending {
    color: #fbbf24;
}

.btn-danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
    color: #ef4444;
}

.btn-edit {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.3);
}

.btn-edit:hover {
    background: rgba(var(--primary-rgb), 0.08);
    border-color: var(--primary);
}

[data-theme="dark"] .btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

@media (max-width: 640px) {
    .my-module-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .my-module-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
